{"thread":{"id":"55583","subject":"[PATCH] Fix: fix comment for __git_complete_worktree_paths","startedAt":"2021-04-29T08:43:58Z","lastAt":"2021-05-04T03:18:18Z","messageCount":4,"participants":["Sardorbek Imomaliev via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"423255","messageId":"pull.943.git.1619685833872.gitgitgadget@gmail.com","threadId":"55583","inReplyTo":null,"subject":"[PATCH] Fix: fix comment for __git_complete_worktree_paths","fromName":"Sardorbek Imomaliev via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2021-04-29T08:43:53Z","receivedAt":"2021-04-29T08:43:58Z","isPatch":true,"sender":{"key":"name:Sardorbek Imomaliev","avatar":null},"body":"From: Sardorbek Imomaliev <sardorbek.imomaliev@gmail.com>\n\nCompletion helper function fails for zsh because of wrongly put comment\n\nSigned-off-by: Sardorbek Imomaliev <sardorbek.imomaliev@gmail.com>\n---\n    Fix: wrongly put comment for __git_complete_worktree_paths completion\n    helper function\n    \n    git completion script fails for zsh\n    \n    $ git worktree remove [TAB]\n    $ git worktree remove __git_complete_worktree_paths:7: command not found: #\n    \n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-943%2Fimomaliev%2Ffix%2Fgit-completion-worktree-subcommands-comment-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-943/imomaliev/fix/git-completion-worktree-subcommands-comment-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/943\n\n contrib/completion/git-completion.bash | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex dfa735ea6299..b2e158edaf6b 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -3268,9 +3268,9 @@ _git_whatchanged ()\n __git_complete_worktree_paths ()\n {\n \tlocal IFS=$'\\n'\n+\t# Skip the first entry: it's the path of the main worktree,\n+\t# which can't be moved, removed, locked, etc.\n \t__gitcomp_nl \"$(git worktree list --porcelain |\n-\t\t# Skip the first entry: it's the path of the main worktree,\n-\t\t# which can't be moved, removed, locked, etc.\n \t\tsed -n -e '2,$ s/^worktree //p')\"\n }\n \n\nbase-commit: 311531c9de557d25ac087c1637818bd2aad6eb3a\n-- \ngitgitgadget\n"},{"id":"423307","messageId":"xmqq1rasfvqn.fsf@gitster.g","threadId":"55583","inReplyTo":"pull.943.git.1619685833872.gitgitgadget@gmail.com","subject":"Re: [PATCH] Fix: fix comment for __git_complete_worktree_paths","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-30T00:42:56Z","receivedAt":"2021-04-30T00:43:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sardorbek Imomaliev via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> Subject: Re: [PATCH] Fix: fix comment for __git_complete_worktree_paths\n\nIn this project, we write what area of the codebase the change\naffects before the colon (I'll give you an example later).\n\n> From: Sardorbek Imomaliev <sardorbek.imomaliev@gmail.com>\n>\n> Completion helper function fails for zsh because of wrongly put comment\n\nIsn't it a bug in zsh that it does not understand that the comment\nis about the command placed on the downstream of the pipe, like\nthis example?\n\n\techo a b c |\n\t# upcase the input (a comment about the next line)\n\ttr a-z A-Z\n\nApparently bash is happy with the existing code, and dash and ksh\nseems to be OK with the above construct, too.\n\nPerhaps rephrase the log message like this instead?\n\n    [PATCH] completion: work around zsh comment but in __git_complete_worktree_paths\n\n    In contrib/completion/git-completion.bash, there is a construct\n    where comment lines are placed between the command that is on\n    the upstream of a pipe and the command that is on the downstream\n    of a pipe in __git_complete_worktree_paths function.\n\n    Unfortunately, this script is also used by Zsh completion, but\n    Zsh mishandles this construct, resulting in a breakage:\n\n        $ git worktree remove [TAB]\n        $ git worktree remove __git_complete_worktree_paths:7: command not found: #\n\n    Move the comment, even though it explains what happens on the\n    downstream of the pipe and logically belongs where it is right\n    now, before the entire pipeline, to work around this problem.\n\nIt might also be necessary to consider rephrasing the comment\nitself, not just \"Move the comment\", to make sure that it is still\nappropriate when used as a comment to cover the whole pipeline---the\noriginal was meant to explain what happens in the downstream only.\n\nThanks.\n\n\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index dfa735ea6299..b2e158edaf6b 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -3268,9 +3268,9 @@ _git_whatchanged ()\n>  __git_complete_worktree_paths ()\n>  {\n>  \tlocal IFS=$'\\n'\n> +\t# Skip the first entry: it's the path of the main worktree,\n> +\t# which can't be moved, removed, locked, etc.\n>  \t__gitcomp_nl \"$(git worktree list --porcelain |\n> -\t\t# Skip the first entry: it's the path of the main worktree,\n> -\t\t# which can't be moved, removed, locked, etc.\n>  \t\tsed -n -e '2,$ s/^worktree //p')\"\n>  }\n>  \n>\n> base-commit: 311531c9de557d25ac087c1637818bd2aad6eb3a\n"},{"id":"423508","messageId":"pull.943.v2.git.1620059347674.gitgitgadget@gmail.com","threadId":"55583","inReplyTo":"pull.943.git.1619685833872.gitgitgadget@gmail.com","subject":"[PATCH v2] work around zsh comment in __git_complete_worktree_paths","fromName":"Sardorbek Imomaliev via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2021-05-03T16:29:07Z","receivedAt":"2021-05-03T16:29:13Z","isPatch":true,"sender":{"key":"name:Sardorbek Imomaliev","avatar":null},"body":"From: Sardorbek Imomaliev <sardorbek.imomaliev@gmail.com>\n\n[PATCH]: contrib/completion/git-completion.bash, there is a construct\nwhere comment lines are placed between the command that is on\nthe upstream of a pipe and the command that is on the downstream\nof a pipe in __git_complete_worktree_paths function.\n\nUnfortunately, this script is also used by Zsh completion, but\nZsh mishandles this construct when \"interactive_comments\" option is not\nset (by default it is off on macOS), resulting in a breakage:\n\n$ git worktree remove [TAB]\n$ git worktree remove __git_complete_worktree_paths:7: command not found: #\n\nMove the comment, even though it explains what happens on the\ndownstream of the pipe and logically belongs where it is right\nnow, before the entire pipeline, to work around this problem.\n\nSigned-off-by: Sardorbek Imomaliev <sardorbek.imomaliev@gmail.com>\n---\n    Fix: wrongly put comment for __git_complete_worktree_paths completion\n    helper function\n    \n    git completion script fails for zsh\n    \n    $ git worktree remove [TAB]\n    $ git worktree remove __git_complete_worktree_paths:7: command not found: #\n    \n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-943%2Fimomaliev%2Ffix%2Fgit-completion-worktree-subcommands-comment-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-943/imomaliev/fix/git-completion-worktree-subcommands-comment-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/943\n\nRange-diff vs v1:\n\n 1:  89a2a4d66b73 ! 1:  60ba6801e0f5 Fix: fix comment for __git_complete_worktree_paths\n     @@ Metadata\n      Author: Sardorbek Imomaliev <sardorbek.imomaliev@gmail.com>\n      \n       ## Commit message ##\n     -    Fix: fix comment for __git_complete_worktree_paths\n     +    work around zsh comment in __git_complete_worktree_paths\n      \n     -    Completion helper function fails for zsh because of wrongly put comment\n     +    [PATCH]: contrib/completion/git-completion.bash, there is a construct\n     +    where comment lines are placed between the command that is on\n     +    the upstream of a pipe and the command that is on the downstream\n     +    of a pipe in __git_complete_worktree_paths function.\n     +\n     +    Unfortunately, this script is also used by Zsh completion, but\n     +    Zsh mishandles this construct when \"interactive_comments\" option is not\n     +    set (by default it is off on macOS), resulting in a breakage:\n     +\n     +    $ git worktree remove [TAB]\n     +    $ git worktree remove __git_complete_worktree_paths:7: command not found: #\n     +\n     +    Move the comment, even though it explains what happens on the\n     +    downstream of the pipe and logically belongs where it is right\n     +    now, before the entire pipeline, to work around this problem.\n      \n          Signed-off-by: Sardorbek Imomaliev <sardorbek.imomaliev@gmail.com>\n      \n     @@ contrib/completion/git-completion.bash: _git_whatchanged ()\n       __git_complete_worktree_paths ()\n       {\n       \tlocal IFS=$'\\n'\n     -+\t# Skip the first entry: it's the path of the main worktree,\n     -+\t# which can't be moved, removed, locked, etc.\n     ++\t# Generate completion reply from worktree list skipping the first\n     ++\t# entry: it's the path of the main worktree, which can't be moved,\n     ++\t# removed, locked, etc.\n       \t__gitcomp_nl \"$(git worktree list --porcelain |\n      -\t\t# Skip the first entry: it's the path of the main worktree,\n      -\t\t# which can't be moved, removed, locked, etc.\n\n\n contrib/completion/git-completion.bash | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 49e76e9d08cd..73f9fcf493c4 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -3268,9 +3268,10 @@ _git_whatchanged ()\n __git_complete_worktree_paths ()\n {\n \tlocal IFS=$'\\n'\n+\t# Generate completion reply from worktree list skipping the first\n+\t# entry: it's the path of the main worktree, which can't be moved,\n+\t# removed, locked, etc.\n \t__gitcomp_nl \"$(git worktree list --porcelain |\n-\t\t# Skip the first entry: it's the path of the main worktree,\n-\t\t# which can't be moved, removed, locked, etc.\n \t\tsed -n -e '2,$ s/^worktree //p')\"\n }\n \n\nbase-commit: 7e391989789db82983665667013a46eabc6fc570\n-- \ngitgitgadget\n"},{"id":"423560","messageId":"xmqqlf8v6vbi.fsf@gitster.g","threadId":"55583","inReplyTo":"pull.943.v2.git.1620059347674.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] work around zsh comment in __git_complete_worktree_paths","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-05-04T03:18:09Z","receivedAt":"2021-05-04T03:18:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sardorbek Imomaliev via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 49e76e9d08cd..73f9fcf493c4 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -3268,9 +3268,10 @@ _git_whatchanged ()\n>  __git_complete_worktree_paths ()\n>  {\n>  \tlocal IFS=$'\\n'\n> +\t# Generate completion reply from worktree list skipping the first\n> +\t# entry: it's the path of the main worktree, which can't be moved,\n> +\t# removed, locked, etc.\n>  \t__gitcomp_nl \"$(git worktree list --porcelain |\n> -\t\t# Skip the first entry: it's the path of the main worktree,\n> -\t\t# which can't be moved, removed, locked, etc.\n>  \t\tsed -n -e '2,$ s/^worktree //p')\"\n>  }\n\nMakes sense.  Thanks, will queue.\n"}]}