Taylor Blau <[email protected]> writes:
> ...' 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.