# [PATCH 0/1] completion: send-email: don't complete revs when --no-format-patch

11 messages from 2024-01-08 to 2024-04-28. Participants: Britton Leo Kerin, Dragan Simic, Britton Kerin, Junio C Hamano, Patrick Steinhardt.
Thread: https://gitlist.dev/t/60699

## Britton Leo Kerin, 2024-01-08 09:36

Subject: [PATCH 0/1] completion: send-email: don't complete revs when --no-format-patch
Message-ID: <9627364b-c0c9-4b85-a81a-ba1ef0735c9a@smtp-relay.sendinblue.com>
URL: https://gitlist.dev/e/9627364b-c0c9-4b85-a81a-ba1ef0735c9a%40smtp-relay.sendinblue.com

```
Along the way I taught __git_find_last_on_cmdline to understand '--', which
isn't stricly necessary but I think reads more clearly at the call sites.
__git_find_on_cmdline could be changed to work the same, or this part dropped
if people don't like it.

Britton Leo Kerin (1):
  completion: don't comp revs when --no-format-patch

 contrib/completion/git-completion.bash | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)


base-commit: e79552d19784ee7f4bbce278fe25f93fbda196fa
--
2.43.0



```

## Dragan Simic, 2024-01-08 09:40

Subject: Re: [PATCH 0/1] completion: send-email: don't complete revs when --no-format-patch
Message-ID: <0e8a1572100faae72db54becefe19f6b@manjaro.org>
URL: https://gitlist.dev/e/0e8a1572100faae72db54becefe19f6b%40manjaro.org
In-Reply-To: <9627364b-c0c9-4b85-a81a-ba1ef0735c9a@smtp-relay.sendinblue.com>

```
On 2024-01-08 10:36, Britton Leo Kerin wrote:
> Along the way I taught __git_find_last_on_cmdline to understand '--', 
> which
> isn't stricly necessary but I think reads more clearly at the call 
> sites.
> __git_find_on_cmdline could be changed to work the same, or this part 
> dropped
> if people don't like it.

If I may suggest, there's no need for a cover letter for a single patch. 
  If you want to include some notes in the patch submission, which aren't 
supposed to be part of the commit summary, you can do that in the patch 
itself.

> Britton Leo Kerin (1):
>   completion: don't comp revs when --no-format-patch
> 
>  contrib/completion/git-completion.bash | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> 
> base-commit: e79552d19784ee7f4bbce278fe25f93fbda196fa
> --
> 2.43.0

```

## Britton Kerin, 2024-01-08 19:34

Subject: Re: [PATCH 0/1] completion: send-email: don't complete revs when --no-format-patch
Message-ID: <CAC4O8c8Evt1XEggVWoVCFCQ-mUkS-=dBYEKM8uuq9WEi-sMdwg@mail.gmail.com>
URL: https://gitlist.dev/e/CAC4O8c8Evt1XEggVWoVCFCQ-mUkS-%3DdBYEKM8uuq9WEi-sMdwg%40mail.gmail.com
In-Reply-To: <0e8a1572100faae72db54becefe19f6b@manjaro.org>

```
On Mon, Jan 8, 2024 at 12:40 AM Dragan Simic <dsimic@manjaro.org> wrote:
>
> On 2024-01-08 10:36, Britton Leo Kerin wrote:
> > Along the way I taught __git_find_last_on_cmdline to understand '--',
> > which
> > isn't stricly necessary but I think reads more clearly at the call
> > sites.
> > __git_find_on_cmdline could be changed to work the same, or this part
> > dropped
> > if people don't like it.
>
> If I may suggest, there's no need for a cover letter for a single patch.
>   If you want to include some notes in the patch submission, which aren't
> supposed to be part of the commit summary, you can do that in the patch
> itself.

Ok thanks, I'll do it that way in future.

Britton

```

## Britton Leo Kerin, 2024-01-09 01:08

Subject: [PATCH v2 0/1] completion: don't complete revs when --no-format-patch
Message-ID: <c9656f53-daa1-4e4e-852c-31997cef6ba5@smtp-relay.sendinblue.com>
URL: https://gitlist.dev/e/c9656f53-daa1-4e4e-852c-31997cef6ba5%40smtp-relay.sendinblue.com
In-Reply-To: <9627364b-c0c9-4b85-a81a-ba1ef0735c9a@smtp-relay.sendinblue.com>

```
Improve commit message

Britton Leo Kerin (1):
  completion: don't complete revs when --no-format-patch

 contrib/completion/git-completion.bash | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Range-diff against v1:
1:  ff4d2e55e3 ! 1:  e56dbbacd9 completion: don't comp revs when --no-format-patch
    @@ Metadata
     Author: Britton Leo Kerin <britton.kerin@gmail.com>

      ## Commit message ##
    -    completion: don't comp revs when --no-format-patch
    +    completion: don't complete revs when --no-format-patch

         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
--
2.43.0



```

## Britton Leo Kerin, 2024-01-09 01:08

Subject: [PATCH v2 1/1] completion: don't complete revs when --no-format-patch
Message-ID: <a718b5ee-afb0-44bd-a299-3208fac43506@smtp-relay.sendinblue.com>
URL: https://gitlist.dev/e/a718b5ee-afb0-44bd-a299-3208fac43506%40smtp-relay.sendinblue.com
In-Reply-To: <20240109010830.458775-1-britton.kerin@gmail.com>

```
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
 }
 
 _git_stage ()
-- 
2.43.0



```

## Junio C Hamano, 2024-02-07 22:12

Subject: Re: [PATCH v2 1/1] completion: don't complete revs when --no-format-patch
Message-ID: <xmqq4jej6i1b.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq4jej6i1b.fsf%40gitster.g
In-Reply-To: <a718b5ee-afb0-44bd-a299-3208fac43506@smtp-relay.sendinblue.com>

```
"Britton Leo Kerin" <britton.kerin@gmail.com> writes:

> 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(-)

Any reviews people want to offer to this one?

Thanks.

> 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
>  }
>  
>  _git_stage ()

```

## Patrick Steinhardt, 2024-02-08 07:57

Subject: Re: [PATCH v2 1/1] completion: don't complete revs when --no-format-patch
Message-ID: <ZcSJaRczdHApmnVi@tanuki>
URL: https://gitlist.dev/e/ZcSJaRczdHApmnVi%40tanuki
In-Reply-To: <a718b5ee-afb0-44bd-a299-3208fac43506@smtp-relay.sendinblue.com>

```
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

```

## Britton Kerin, 2024-02-14 20:49

Subject: Re: [PATCH v2 1/1] completion: don't complete revs when --no-format-patch
Message-ID: <CAC4O8c88Z3ZqxH2VVaNPpEGB3moL5dJcg3cOWuLWwQ_hLrJMtA@mail.gmail.com>
URL: https://gitlist.dev/e/CAC4O8c88Z3ZqxH2VVaNPpEGB3moL5dJcg3cOWuLWwQ_hLrJMtA%40mail.gmail.com
In-Reply-To: <ZcSJaRczdHApmnVi@tanuki>

```
On Wed, Feb 7, 2024 at 10:57 PM Patrick Steinhardt <ps@pks.im> wrote:
>
> 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.

I'll look this one over again and add some tests eventually.

Britton

```

## Junio C Hamano, 2024-02-21 01:34

Subject: Re: [PATCH v2 1/1] completion: don't complete revs when --no-format-patch
Message-ID: <xmqqa5nusiqv.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqa5nusiqv.fsf%40gitster.g
In-Reply-To: <CAC4O8c88Z3ZqxH2VVaNPpEGB3moL5dJcg3cOWuLWwQ_hLrJMtA@mail.gmail.com>

```
Britton Kerin <britton.kerin@gmail.com> writes:

>> 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.
>
> I'll look this one over again and add some tests eventually.

Thank you, both.


```

## Junio C Hamano, 2024-03-05 21:58

Subject: Re: [PATCH v2 1/1] completion: don't complete revs when --no-format-patch
Message-ID: <xmqqfrx4z6gg.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqfrx4z6gg.fsf%40gitster.g
In-Reply-To: <CAC4O8c88Z3ZqxH2VVaNPpEGB3moL5dJcg3cOWuLWwQ_hLrJMtA@mail.gmail.com>

```
Britton Kerin <britton.kerin@gmail.com> writes:

> On Wed, Feb 7, 2024 at 10:57 PM Patrick Steinhardt <ps@pks.im> wrote:
>> ...
>> Also, adding a test for git-send-email that exercises this new behaviour
>> would be very much welcome, too.
>
> I'll look this one over again and add some tests eventually.

Just pinging the thread to keep it visible in the list of recent
topics I need to keep an eye on.  No rush.

Thanks.

```

## Junio C Hamano, 2024-04-28 22:55

Subject: Re: [PATCH v2 1/1] completion: don't complete revs when --no-format-patch
Message-ID: <xmqqplu92j3e.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqplu92j3e.fsf%40gitster.g
In-Reply-To: <CAC4O8c88Z3ZqxH2VVaNPpEGB3moL5dJcg3cOWuLWwQ_hLrJMtA@mail.gmail.com>

```
Britton Kerin <britton.kerin@gmail.com> writes:

> On Wed, Feb 7, 2024 at 10:57 PM Patrick Steinhardt <ps@pks.im> wrote:
>>
>> On Mon, Jan 08, 2024 at 04:08:30PM -0900, Britton Leo Kerin wrote:
>> ...
>> 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.
>
> I'll look this one over again and add some tests eventually.

It has been a while, but is there any progress on this topic?

Thanks.

```
