Skip to content

branch: fix branch operations with multiple working trees

Kazuki Yamaguchi git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest5 patches 5 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5refs: add new flag RESOLVE_REF_COMMON_DIR to resolve_ref_unsaferefs.h refs/files-backend.c worktree.c+41 -730 replies
2/5refs: add REF_COMMON_DIR flagrefs.h refs/files-backend.c+14 -20 replies
3/5refs: add create_symref_common_dir as a variation of create_symrefrefs.h refs/files-backend.c+17 -30 replies
4/5branch -m: update all per-worktree HEADsbranch.c branch.h builtin/branch.c +1 more+62 -30 replies
5/5branch -d: refuse deleting a branch which is currently checked outbuiltin/branch.c t/t3200-branch.sh+13 -59 replies

Reviews trailers per patch

1 of 5 patches has a Reviewed-by or Acked-by.

PatchEric Sunshine
1/5
2/5
3/5
4/5
5/5Helped-by R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/5] branch: fix branch operations with multiple working trees

[1/5]
Adds RESOLVE_REF_COMMON_DIR to resolve_ref_unsafe(). The second - fourth patch depend on this. At the same time, this allows us to remove reimplementation of resolve_ref_unsafe() in worktree.c: parse_ref().

[2/5]
Adds REF_COMMON_DIR flag to lock_ref_sha1_basic().

[3/5]
Adds create_symref_common_dir(). Same as create_symref() except it doesn't consider $GIT_DIR. create_symref_common_dir("HEAD", some) always updates .git/HEAD. The next patch uses this.

[4/5]
Fixes the issue of git branch -m.
The behavior when one failed has changed from v1: print an error and continue.

% git branch -m oldname newname
error: Unable to create '/path/to/.git/worktrees/wt/HEAD.lock': Permission denied
error: HEAD of working tree /path/to/wt is not updated.
error: Unable to create '/path/to/.git/worktrees/wt2/HEAD.lock': Permission denied
error: HEAD of working tree /path/to/wt2 is not updated.
fatal: Branch renamed to newname, but HEAD is not updated!

[5/5]
Fixes an issue of git branch -d, v1 didn't include this.
I noticed git branch -d has same issue and this is for it. This patch is unrelated to the above 4 patches, but the cause is same. This can be applied separately.

Kazuki Yamaguchi (5):
refs: add new flag RESOLVE_REF_COMMON_DIR to resolve_ref_unsafe
refs: add REF_COMMON_DIR flag
refs: add create_symref_common_dir as a variation of create_symref branch -m: update all per-worktree HEADs
branch -d: refuse deleting a branch which is currently checked out

 branch.c             |  32 ++++++++++++++++
 branch.h             |   7 ++++
 builtin/branch.c     |  15 ++++----
 refs.h               |  11 ++++++
 refs/files-backend.c |  34 ++++++++++++++---
 t/t3200-branch.sh    |  29 +++++++++++++-
 worktree.c           | 105 ++++++++++++++++-----------------------------------
 7 files changed, 147 insertions(+), 86 deletions(-)
Signature · 1 line
2.8.0.rc4.21.g05df949