Re: [PATCH v2 1/7] fetch: increase test coverage of fetches
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Feb 21, 2022, 07:57 UTC
- Message-ID
- <YhNF1Xc9GwGNXzhC@ncase>
- In-Reply-To
- <CAP8UFD2kr6WJvv7eoDvytx5Q982XBXTpSTUQw5hXmRrDm-UuBw@mail.gmail.com>
On Thu, Feb 17, 2022 at 04:18:07PM +0100, Christian Couder wrote:
Show 25 quoted lines
> On Thu, Feb 17, 2022 at 2:04 PM Patrick Steinhardt <ps@pks.im> wrote: > > > +test_expect_success 'atomic fetch with failing backfill' ' > > + git init clone3 && > > + > > + # We want to test whether a failure when backfilling tags correctly > > + # aborts the complete transaction when `--atomic` is passed: we should > > + # neither create the branch nor should we create the tag when either > > + # one of both fails to update correctly. > > + # > > + # To trigger failure we simply abort when backfilling a tag. > > + write_script clone3/.git/hooks/reference-transaction <<-\EOF && > > + while read oldrev newrev reference > > + do > > + if test "$reference" = refs/tags/tag1 > > + then > > + exit 1 > > + fi > > Maybe the following could save a few lines: > > test "$reference" = refs/tags/tag1 && exit 1 > > It would make the code look a bit different than in another hook > script written below though, so not a big deal.
If `$reference` does not match the tag we want to continue and eventually return successfully from this hook. But:
$ while read foo; do test "$foo" = bar && echo match; done < <(echo bar)
match
$ while read foo; do test "$foo" = bar && echo match; done < <(echo foo)
$ echo $?
1So with the proposed change we'd now exit the hook with an error code instead of returning successfully.
Patrick