From: Junio C Hamano <gitster@pobox.com>
To: "Sardorbek Imomaliev via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Sardorbek Imomaliev <sardorbek.imomaliev@gmail.com>
Subject: Re: [PATCH] Fix: fix comment for __git_complete_worktree_paths
Date: Fri, 30 Apr 2021 09:42:56 +0900 [thread overview]
Message-ID: <xmqq1rasfvqn.fsf@gitster.g> (raw)
In-Reply-To: <pull.943.git.1619685833872.gitgitgadget@gmail.com> (Sardorbek Imomaliev via GitGitGadget's message of "Thu, 29 Apr 2021 08:43:53 +0000")
"Sardorbek Imomaliev via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> Subject: Re: [PATCH] Fix: fix comment for __git_complete_worktree_paths
In this project, we write what area of the codebase the change
affects before the colon (I'll give you an example later).
> From: Sardorbek Imomaliev <sardorbek.imomaliev@gmail.com>
>
> Completion helper function fails for zsh because of wrongly put comment
Isn't it a bug in zsh that it does not understand that the comment
is about the command placed on the downstream of the pipe, like
this example?
echo a b c |
# upcase the input (a comment about the next line)
tr a-z A-Z
Apparently bash is happy with the existing code, and dash and ksh
seems to be OK with the above construct, too.
Perhaps rephrase the log message like this instead?
[PATCH] completion: work around zsh comment but in __git_complete_worktree_paths
In 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, 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.
It might also be necessary to consider rephrasing the comment
itself, not just "Move the comment", to make sure that it is still
appropriate when used as a comment to cover the whole pipeline---the
original was meant to explain what happens in the downstream only.
Thanks.
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index dfa735ea6299..b2e158edaf6b 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -3268,9 +3268,9 @@ _git_whatchanged ()
> __git_complete_worktree_paths ()
> {
> local IFS=$'\n'
> + # Skip 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')"
> }
>
>
> base-commit: 311531c9de557d25ac087c1637818bd2aad6eb3a
next prev parent reply other threads:[~2021-04-30 0:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-29 8:43 [PATCH] Fix: fix comment for __git_complete_worktree_paths Sardorbek Imomaliev via GitGitGadget
2021-04-30 0:42 ` Junio C Hamano [this message]
2021-05-03 16:29 ` [PATCH v2] work around zsh comment in __git_complete_worktree_paths Sardorbek Imomaliev via GitGitGadget
2021-05-04 3:18 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq1rasfvqn.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=sardorbek.imomaliev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).