Skip to content

fix die_if_checked_out() when ignore_current_worktree

Rubén Justo git 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 2 repliesIn review
  2. v34 patches 13 repliesSuperseded
  3. v23 patches 6 repliesSuperseded

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4worktree: introduce is_shared_symref()worktree.c worktree.h+37 -310 replies
2/4branch: fix die_if_checked_out() when ignore_current_worktreebranch.c worktree.c+10 -70 replies
3/4rebase: refuse to switch to a branch already checked out elsewhere (test)t/t3400-rebase.sh+14 -00 replies
4/4switch: reject if the branch is already checked out elsewhere (test)t/t2060-switch.sh+29 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH v4 0/4] fix die_if_checked_out() when ignore_current_worktree

Since v3, two errors in 4/4 have been fixed:
- "checkout -" must be done before "branch -d"
- "branch -D" instead of "branch -d" because "shared" is a non-merged branch.

Also, '||:' has been used to chain commands in the test_when_finished() block.

Rubén Justo (4):
worktree: introduce is_shared_symref()
branch: fix die_if_checked_out() when ignore_current_worktree
rebase: refuse to switch to a branch already checked out elsewhere (test)
switch: reject if the branch is already checked out elsewhere (test)

 branch.c          | 14 +++++++----
 t/t2060-switch.sh | 29 ++++++++++++++++++++++
 t/t3400-rebase.sh | 14 +++++++++++
 worktree.c        | 63 +++++++++++++++++++++++------------------------
 worktree.h        |  6 +++++
 5 files changed, 89 insertions(+), 37 deletions(-)

Range-diff against v3:

1:  40b5ea54d3 = 1:  22d0944aad worktree: introduce is_shared_symref()
2:  2f1479b354 = 2:  e7ba7b6fdd branch: fix die_if_checked_out() when ignore_current_worktree
3:  81a5b619c3 = 3:  8de8319d0e rebase: refuse to switch to a branch already checked out elsewhere (test)
4:  6559e58344 ! 4:  27d6ae2755 switch: reject if the branch is already checked out elsewhere (test)
    @@ t/t2060-switch.sh: test_expect_success 'tracking info copied with autoSetupMerge
      
     +test_expect_success 'switch back when temporarily detached and checked out elsewhere ' '
     +	test_when_finished "
    -+		git worktree remove wt1 &&
    -+		git worktree remove wt2 &&
    -+		git branch -d shared
    -+		git checkout -
    ++		git worktree remove wt1 ||:
    ++		git worktree remove wt2 ||:
    ++		git checkout - ||:
    ++		git branch -D shared ||:
     +	" &&
     +	git checkout -b shared &&
     +	test_commit shared-first &&
Signature · 1 line
2.39.2