Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2022-08-26 12:39:28 +0300
committerJunio C Hamano <gitster@pobox.com>2022-08-26 19:49:23 +0300
commitedd6a31f46096824f792f0fad5532c8d444c4c05 (patch)
tree3c65eaeb95443507dc34c71285931df40f497a58 /builtin/range-diff.c
parent795ea8776befc95ea2becd8020c7a284677b4161 (diff)
range-diff: reorder argument handling
In d9c66f0b5bf (range-diff: first rudimentary implementation, 2018-08-13), we introduced the argument handling of the `range-diff` command, special-casing three different stanzas based on the argument count. The somewhat unorthodox order (first handling the case of 2 arguments, then 3, then 1) was chosen for clarity: the natural argument number is 2 because that is how many revision ranges are used internally. The code to handle three arguments is relatively trivial, so it was added next. And finally, the code to ungarble a single symmetric range into two separate ones was added, because it was the most complicated (the most inelegant part being about interpreting empty sides of the symmetric range as `HEAD`). In preparation for allowing pathspecs in `git range-diff` invocations, where we no longer have the luxury of using the number of arguments to disambiguate between these three different ways to specify the commit ranges, we need to order these cases by argument count, in descending order. This patch is best viewed with `--color-moved`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/range-diff.c')
-rw-r--r--builtin/range-diff.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index 50318849d6..f8d3869d35 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -55,7 +55,10 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
if (!simple_color)
diffopt.use_color = 1;
- if (argc == 2) {
+ if (argc == 3) {
+ strbuf_addf(&range1, "%s..%s", argv[0], argv[1]);
+ strbuf_addf(&range2, "%s..%s", argv[0], argv[2]);
+ } else if (argc == 2) {
if (!is_range_diff_range(argv[0]))
die(_("not a commit range: '%s'"), argv[0]);
strbuf_addstr(&range1, argv[0]);
@@ -63,9 +66,6 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
if (!is_range_diff_range(argv[1]))
die(_("not a commit range: '%s'"), argv[1]);
strbuf_addstr(&range2, argv[1]);
- } else if (argc == 3) {
- strbuf_addf(&range1, "%s..%s", argv[0], argv[1]);
- strbuf_addf(&range2, "%s..%s", argv[0], argv[2]);
} else if (argc == 1) {
const char *b = strstr(argv[0], "..."), *a = argv[0];
int a_len;