Re: [PATCH v2 1/7] fetch: increase test coverage of fetches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 17, 2022 at 04:18:07PM +0100, Christian Couder wrote:
> On Thu, Feb 17, 2022 at 2:04 PM Patrick Steinhardt <ps@xxxxxx> 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 $?
    1

So with the proposed change we'd now exit the hook with an error code
instead of returning successfully.

Patrick

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux