]> git.ipfire.org Git - thirdparty/git.git/commit
range-diff: reorder argument handling
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 26 Aug 2022 09:39:28 +0000 (09:39 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 Aug 2022 16:49:23 +0000 (09:49 -0700)
commitedd6a31f46096824f792f0fad5532c8d444c4c05
tree3c65eaeb95443507dc34c71285931df40f497a58
parent795ea8776befc95ea2becd8020c7a284677b4161
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>
builtin/range-diff.c