Re: [PATCH v2 2/3] range-diff/format-patch: handle commit ranges other than A..B
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 22, 2021, 20:32 UTC
- Message-ID
- <xmqqv9bo7lwd.fsf@gitster.c.googlers.com>
- In-Reply-To
- <2c2744333ecf5662d4198bdddeee80ff4adf6acd.1611339373.git.gitgitgadget@gmail.com>
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 15 quoted lines
> + i = strlen(range);
> + c = i > 2 ? range[--i] : 0;
> + if (c == '!')
> + i--; /* might be ...^! */
> + else if (isdigit(c)) {
> + /* handle ...^-<n> */
> + while (i > 2 && isdigit(range[--i]))
> + ; /* keep trimming trailing digits */
> + if (i < 2 || range[i--] != '-')
> + return 0;
> + } else
> + return 0;
> +
> + /* Before the `!` or the `-<n>`, we expect `<rev>^` */
> + return i > 0 && range[i] == '^';This is still way too complex for my liking, but at least I cannot immediately spot a glaring off-by-one like the previous round ;-)
This is a tangent ([*1*]), but we often equate an omission to implicitly specified HEAD; e.g. "git log @{u}.." is what we did since we started building on top of our upstream. I wonder if it makes sense to allow similar short-hand so that ^! alone would mean HEAD^!, ^@ alone would mean HEAD^@, and so on.
Thanks.
[Footnote]
*1* read: this has nothing to do with how ready I think this patch
is, but the topic reminds me of it strongly enough that I raise
it here, because I know the opinions on this unrelated thing on
recipients of this response are worth listening to.