From: Patrick Steinhardt <ps@pks.im>
To: Britton Leo Kerin <britton.kerin@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 1/1] completion: don't complete revs when --no-format-patch
Date: Thu, 8 Feb 2024 08:57:29 +0100 [thread overview]
Message-ID: <ZcSJaRczdHApmnVi@tanuki> (raw)
In-Reply-To: <a718b5ee-afb0-44bd-a299-3208fac43506@smtp-relay.sendinblue.com>
[-- Attachment #1: Type: text/plain, Size: 1909 bytes --]
On Mon, Jan 08, 2024 at 04:08:30PM -0900, Britton Leo Kerin wrote:
> In this case the user has specifically said they don't want send-email
> to run format-patch so revs aren't valid argument completions (and it's
> likely revs and dirs do have some same names or prefixes as in
> Documentation/MyFirstContribution.txt 'psuh').
>
> Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
> ---
> contrib/completion/git-completion.bash | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 185b47d802..c983f3b2ab 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1242,10 +1242,12 @@ __git_find_last_on_cmdline ()
> while test $# -gt 1; do
> case "$1" in
> --show-idx) show_idx=y ;;
> + --) shift && break ;;
> *) return 1 ;;
> esac
> shift
> done
> + [ $# -eq 1 ] || return 1 # return 1 if we got wrong # of non-opts
> local wordlist="$1"
>
> while [ $c -gt "$__git_cmd_idx" ]; do
> @@ -2429,7 +2431,9 @@ _git_send_email ()
> return
> ;;
> esac
> - __git_complete_revlist
> + if [ "$(__git_find_last_on_cmdline -- "--format-patch --no-format-patch")" != "--no-format-patch" ]; then
> + __git_complete_revlist
> + fi
> }
While this second hunk here makes perfect sense to me, there is no
explanation why we need to change `__git_find_last_on_cmdline ()`. It's
already used with "--guess --no-guess" in another place, so I would
think that it ought to work alright for this usecase, too. Or is it that
the existing callsite of this function is buggy, too? If so, we should
likely fix that in a separate patch together with a test.
Also, adding a test for git-send-email that exercises this new behaviour
would be very much welcome, too.
Patrick
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-02-08 7:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-08 9:36 [PATCH 0/1] completion: send-email: don't complete revs when --no-format-patch Britton Leo Kerin
2024-01-08 9:40 ` Dragan Simic
2024-01-08 19:34 ` Britton Kerin
2024-01-09 1:08 ` [PATCH v2 0/1] completion: " Britton Leo Kerin
[not found] ` <20240109010830.458775-1-britton.kerin@gmail.com>
2024-01-09 1:08 ` [PATCH v2 1/1] " Britton Leo Kerin
2024-02-07 22:12 ` Junio C Hamano
2024-02-08 7:57 ` Patrick Steinhardt [this message]
2024-02-14 20:49 ` Britton Kerin
2024-02-21 1:34 ` Junio C Hamano
2024-03-05 21:58 ` Junio C Hamano
2024-04-28 22:55 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZcSJaRczdHApmnVi@tanuki \
--to=ps@pks.im \
--cc=britton.kerin@gmail.com \
--cc=git@vger.kernel.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox