range-diff/format-patch: refactor check for commit range

Currently, when called with exactly two arguments, `git range-diff`
tests for a literal `..` in each of the two. Likewise, the argument
provided via `--range-diff` to `git format-patch` is checked in the same
manner.

However, `<commit>^!` is a perfectly valid commit range, equivalent to
`<commit>^..<commit>` according to the `SPECIFYING RANGES` section of
gitrevisions[7].

In preparation for allowing more sophisticated ways to specify commit
ranges, let's refactor the check into its own function.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin
2021-01-27 16:37:22 +00:00
committed by Junio C Hamano
parent 66e871b664
commit 679b5916cd
4 changed files with 19 additions and 5 deletions

View File

@ -564,3 +564,8 @@ int show_range_diff(const char *range1, const char *range2,
return res;
}
int is_range_diff_range(const char *arg)
{
return !!strstr(arg, "..");
}