Re: [PATCH 3/3] transport.c: introduce core.alternateRefsPrefixes
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 21, 2018, 16:45 UTC
- Message-ID
- <xmqqfty2x0iw.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180921140732.GA43093@syl>
Taylor Blau <me@ttaylorr.com> writes:
Show 12 quoted lines
> ...' block with your suggestion above. It's tempting to introduce it as:
>
> expect_haves() {
> printf "%s .have\n" $(git rev-parse -- $@)
> }
>
> And call it as:
>
> expect_haves one three two >expect
>
> But I'm not sure whether I think that this is better or worse than
> writing it twice inline.If the expected pattern is expected to stay to be just a sequence of "<oid> .have" and nothing else for the foreseeable future, I think it is a good idea to introduce such a helper function. Spelling it out at the use site, e.g.
printf "%s .have\n" $(git rev-parse a b c) >expect
will become cumbersome once the set of objects you need to show starts growing.
expect_haves a b c >expect
would be shorter, of course. And as long as we expect to have ONLY "<oid> .have" lines and nothing else, there is no downside that the details of the format is hidden away inside the helper.