Skip to content

worktree lock, move, remove and unlock

Nguyễn Thái Ngọc Duy git 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest26 patches 2 repliesIn review
  2. v120 patches 0 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/26usage.c: move format processing out of die_errno()usage.c+15 -100 replies
2/26usage.c: add sys_error() that prints strerror() automaticallygit-compat-util.h usage.c+11 -00 replies
3/26copy.c: import copy_file() from busyboxcopy.c+331 -00 replies
4/26copy.c: delete unused code in copy_file()copy.c+7 -940 replies
5/26copy.c: convert bb_(p)error_msg to (sys_)errorcopy.c+31 -540 replies
6/26copy.c: style fixcopy.c+29 -210 replies
7/26copy.c: convert copy_file() to copy_dir_recursively()cache.h copy.c+179 -380 replies
8/26completion: support git-worktreecontrib/completion/git-completion.bash+23 -00 replies
9/26git-worktree.txt: keep subcommand listing in alphabetical orderDocumentation/git-worktree.txt builtin/worktree.c+6 -60 replies
10/26wrapper.c: allow to create an empty file with write_file()wrapper.c+1 -12 replies
11/26path.c: add git_common_path() and strbuf_git_common_path()cache.h path.c+32 -00 replies
12/26worktree.c: use is_dot_or_dotdot()builtin/worktree.c worktree.c+3 -20 replies
13/26worktree.c: store "id" instead of "git_dir"worktree.c worktree.h+22 -140 replies
14/26worktree.c: add clear_worktree()worktree.c worktree.h+16 -30 replies
15/26worktree.c: add find_worktree_by_path()worktree.c worktree.h+22 -00 replies
16/26worktree.c: add is_main_worktree()worktree.c worktree.h+10 -00 replies
17/26worktree.c: add validate_worktree()worktree.c worktree.h+68 -00 replies
18/26worktree.c: add update_worktree_location()worktree.c worktree.h+31 -00 replies
19/26worktree.c: add is_worktree_locked()worktree.c worktree.h+24 -00 replies
20/26worktree: avoid 0{40}, too many zeroes, hard to readbuiltin/worktree.c+1 -10 replies
21/26worktree: simplify prefixing pathsbuiltin/worktree.c+3 -10 replies
22/26worktree: add "lock" commandDocumentation/git-worktree.txt builtin/worktree.c contrib/completion/git-completion.bash +1 more+89 -30 replies
23/26worktree: add "unlock" commandDocumentation/git-worktree.txt builtin/worktree.c contrib/completion/git-completion.bash +1 more+51 -10 replies
24/26worktree: add "move" commmandDocumentation/git-worktree.txt builtin/worktree.c contrib/completion/git-completion.bash +1 more+95 -20 replies
25/26worktree move: accept destination as directorybuiltin/worktree.c+18 -10 replies
26/26worktree: add "remove" commandDocumentation/git-worktree.txt builtin/worktree.c contrib/completion/git-completion.bash +1 more+124 -100 replies

Reviews trailers per patch

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

Read the v2 thread

Cover letter [PATCH v2 00/26] worktree lock, move, remove and unlock

I think this is good enough to be further polished and maybe released. The series adds four new commands and bash completion for git-worktree.

Remaining work to do on git-worktree:

- "git worktree move --repository", in v1 but left out in v2 because it's trickier.

- .git/config issue and submodule support

A bit off topic, I've been using this script to add "cw" command, to chdir to another worktree with tab-completion. It works wonderfully, but I'm not sure if it can ever be merged to git-completion.bash.

-- 8< --

cw() {
    cd "$(git worktree list --porcelain | grep -B2 refs/heads/$1 | head -n1 | cut -f 2 -d ' ')"
}
_git_cw() {
	local cur words cword prev
	_get_comp_words_by_ref -n =: cur words cword prev

    	local list="$(git worktree list --porcelain | grep '^branch refs/heads/' | cut -c 19-)"
	__gitcomp "$list"
}

complete -o bashdefault -o default -o nospace -F _git_cw cw 2>/dev/null || \
complete -o default -o nospace -F _git_cw cw
-- 8< --

Nguyễn Thái Ngọc Duy (26):
usage.c: move format processing out of die_errno() usage.c: add sys_error() that prints strerror() automatically copy.c: import copy_file() from busybox
copy.c: delete unused code in copy_file()
copy.c: convert bb_(p)error_msg to (sys_)error copy.c: style fix
copy.c: convert copy_file() to copy_dir_recursively()
completion: support git-worktree
git-worktree.txt: keep subcommand listing in alphabetical order wrapper.c: allow to create an empty file with write_file() path.c: add git_common_path() and strbuf_git_common_path() worktree.c: use is_dot_or_dotdot()
worktree.c: store "id" instead of "git_dir" worktree.c: add clear_worktree()
worktree.c: add find_worktree_by_path()
worktree.c: add is_main_worktree()
worktree.c: add validate_worktree()
worktree.c: add update_worktree_location() worktree.c: add is_worktree_locked()
worktree: avoid 0{40}, too many zeroes, hard to read
worktree: simplify prefixing paths
worktree: add "lock" command
worktree: add "unlock" command
worktree: add "move" commmand
worktree move: accept destination as directory
worktree: add "remove" command

 Documentation/git-worktree.txt         |  55 +++--
 builtin/worktree.c                     | 240 ++++++++++++++++++++-
 cache.h                                |   4 +
 contrib/completion/git-completion.bash |  29 +++
 copy.c                                 | 369 +++++++++++++++++++++++++++++++++
 git-compat-util.h                      |   1 +
 path.c                                 |  29 +++
 t/t2028-worktree-move.sh (new +x)      | 103 +++++++++
 usage.c                                |  35 +++-
 worktree.c                             | 171 +++++++++++++--
 worktree.h                             |  40 +++-
 wrapper.c                              |   2 +-
 12 files changed, 1029 insertions(+), 49 deletions(-)
 create mode 100755 t/t2028-worktree-move.sh
Signature · 1 line
2.7.0.377.g4cd97dd