Re: [PATCH v2] bisect: fix "reset" when branch is checked out elsewhere
- From
Rubén Justo <rjusto@gmail.com>
- Date
- Feb 15, 2023, 22:20 UTC
- Message-ID
- <1008f790-d2af-3b1f-50a3-6ce27f3b3df4@gmail.com>
- In-Reply-To
- <CAPig+cQPVMKui=AiXBHEfNWY5e4fMbxixdnzvZmXsSkW9ZMLyg@mail.gmail.com>
On 14-feb-2023 23:52:08, Eric Sunshine wrote:
Show 36 quoted lines
> On Sat, Feb 4, 2023 at 6:02 PM Rubén Justo <rjusto@gmail.com> wrote:
> > Since 1d0fa89 (checkout: add --ignore-other-wortrees, 2015-01-03) we
> > have a safety valve in checkout/switch to prevent the same branch from
> > being checked out simultaneously in multiple worktrees.
> >
> > If a branch is bisected in a worktree while also being checked out in
> > another worktree; when the bisection is finished, checking out the
> > branch back in the current worktree may fail.
> >
> > Let's teach bisect to use the "--ignore-other-worktrees" flag.
> >
> > Signed-off-by: Rubén Justo <rjusto@gmail.com>
> > ---
> > diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
> > @@ -122,6 +122,29 @@ test_expect_success 'bisect start without -- takes unknown arg as pathspec' '
> > +test_expect_success 'bisect reset: back in a branch checked out also elsewhere' '
> > + echo "shared" > branch.expect &&
> > + test_bisect_reset() {
> > + git -C $1 bisect start &&
> > + git -C $1 bisect good $HASH1 &&
> > + git -C $1 bisect bad $HASH3 &&
> > + git -C $1 bisect reset &&
> > + git -C $1 branch --show-current > branch.output &&
> > + cmp branch.expect branch.output
> > + } &&
> > + test_when_finished "
> > + git worktree remove wt1 &&
> > + git worktree remove wt2 &&
> > + git branch -d shared
> > + " &&
>
> As mentioned in my review[1] of one of your other patches, &&-chaining
> within the argument to test_when_finished() is probably undesirable in
> this case since failure of any cleanup command would cause
> test_when_finish() to fail, which would cause the test to fail
> overall.As I said in my other response, if there is no argument against this change, I'll reroll with it.
Thanks.
Show 10 quoted lines
> > [1]: https://lore.kernel.org/git/CAPig+cQpizjmhmDKb=HPrcYqqRq7JpvC-NZvY7B9eBbG+NrfKw@mail.gmail.com/ > > > + git worktree add wt1 -b shared && > > + git worktree add wt2 -f shared && > > + # we test in both worktrees to ensure that works > > + # as expected with "first" and "next" worktrees > > + test_bisect_reset wt1 && > > + test_bisect_reset wt2 > > +'