]> git.ipfire.org Git - thirdparty/git.git/commitdiff
work around zsh comment in __git_complete_worktree_paths
authorSardorbek Imomaliev <sardorbek.imomaliev@gmail.com>
Mon, 3 May 2021 16:29:07 +0000 (16:29 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 May 2021 03:17:23 +0000 (12:17 +0900)
[PATCH]: contrib/completion/git-completion.bash, there is a construct
where comment lines are placed between the command that is on
the upstream of a pipe and the command that is on the downstream
of a pipe in __git_complete_worktree_paths function.

Unfortunately, this script is also used by Zsh completion, but
Zsh mishandles this construct when "interactive_comments" option is not
set (by default it is off on macOS), resulting in a breakage:

$ git worktree remove [TAB]
$ git worktree remove __git_complete_worktree_paths:7: command not found: #

Move the comment, even though it explains what happens on the
downstream of the pipe and logically belongs where it is right
now, before the entire pipeline, to work around this problem.

Signed-off-by: Sardorbek Imomaliev <sardorbek.imomaliev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash

index 7dc6cd8eb8381d66a75e443970adb768befe866c..7ef7385d12a482d6ef95ced24269aae4a3bd3c6a 100644 (file)
@@ -3268,9 +3268,10 @@ _git_whatchanged ()
 __git_complete_worktree_paths ()
 {
        local IFS=$'\n'
+       # Generate completion reply from worktree list skipping the first
+       # entry: it's the path of the main worktree, which can't be moved,
+       # removed, locked, etc.
        __gitcomp_nl "$(git worktree list --porcelain |
-               # Skip the first entry: it's the path of the main worktree,
-               # which can't be moved, removed, locked, etc.
                sed -n -e '2,$ s/^worktree //p')"
 }