Re: [PATCH v2 2/2] ref-filter: 'contents:trailers' show error if `:` is missing
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 21, 2020, 19:17 UTC
- Message-ID
- <xmqqeenz95bj.fsf@gitster.c.googlers.com>
- In-Reply-To
- <CAPig+cRxCvHG70Nd00zBxYFuecu6+Z6uDP8ooN3rx9vPagoYBA@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 12 quoted lines
> ...an alternative would have been something like:
>
> else if (!strcmp(arg, "trailers")) {
> if (trailers_atom_parser(format, atom, NULL, err))
> return -1;
> } else if (skip_prefix(arg, "trailers:", &arg)) {
> if (trailers_atom_parser(format, atom, arg, err))
> return -1;
> }
>
> which is quite simple to reason about (though has the cost of a tiny
> bit of duplication).Yeah, that looks quite simple and straight-forward.
Show 5 quoted lines
>> diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh >> @@ -823,6 +823,15 @@ test_expect_success '%(trailers) rejects unknown trailers arguments' ' >> +test_expect_success 'if arguments, %(contents:trailers) shows error if semicolon is missing' ' > > s/semicolon/colon/
Definitely.
Show 5 quoted lines
> >> + # error message cannot be checked under i18n > > What is this comment about? I realize that you copied it from other > nearby tests, but I find that it muddies rather than clarifies.
Yup. If a patch changes test_cmp with test_i18ncmp, the above message belongs to its commit log message, but it is overkill to have it as an in-line comment in every place where test_i18ncmp gets used.
Thanks for a review.
Show 6 quoted lines
>> + cat >expect <<-EOF && >> + fatal: unrecognized %(contents) argument: trailersonly >> + EOF >> + test_must_fail git for-each-ref --format="%(contents:trailersonly)" 2>actual && >> + test_i18ncmp expect actual >> +'