Subject: [PATCH v2 00/26] worktree lock, move, remove and unlock

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Tue, 16 Feb 2016 20:29:01 +0700

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

-- 
2.7.0.377.g4cd97dd