threads / patch / 47967

patch, 2 partsnd/parseopt-completion fixups

Subject: [PATCH 0/2] nd/parseopt-completion fixups

## tl;dr

15 messages between Mar 3, 2018 and Mar 7, 2018. Diffs are folded; open one to read it.

replies: 14people: 5as markdown or json

Nguyễn Thái Ngọc Duy· Mar 3, 2018, 09:23 UTC · lore

This addresses some comments from v3 [1]. Since the series has been merged to 'next', we do incremental updates instead:

- --rerere-autoupdate is completable on am, revert and cherry-pick
- simplification in _git_notes which leads to completion in 'git notes
  remove'
[1] https://public-inbox.org/git/20180209110221.27224-1-pclouds@gmail.com/
Nguyễn Thái Ngọc Duy (2):
  completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate
  completion: simplify _git_notes
 contrib/completion/git-completion.bash | 18 +++---------------
 parse-options.h                        |  4 ++--
 rerere.h                               |  3 +--
 3 files changed, 6 insertions(+), 19 deletions(-)
-- 
2.16.1.435.g8f24da2e1a
Nguyễn Thái Ngọc Duy· Mar 3, 2018, 09:23 UTC · re: Nguyễn Thái Ngọc Duy · lore

[PATCH 1/2] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate

There is not a strong reason to hide this option, and git-merge already completes this one. Let's allow to complete this for all commands (and let git-completion.bash do the suppressing if neede).

This makes --rerere-autoupdate completable for am, cherry-pick and revert.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 contrib/completion/git-completion.bash | 3 +--
 parse-options.h                        | 4 ++--
 rerere.h                               | 3 +--
 3 files changed, 4 insertions(+), 6 deletions(-)
Show changes to 3 files +4 −6

contrib/completion/git-completion.bash, parse-options.h, rerere.h

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 0ddf40063b..c310b241d3 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1754,8 +1754,7 @@ _git_merge ()
 
 	case "$cur" in
 	--*)
-		__gitcomp_builtin merge "--rerere-autoupdate
-				--no-rerere-autoupdate
+		__gitcomp_builtin merge "--no-rerere-autoupdate
 				--no-commit --no-edit --no-ff
 				--no-log --no-progress
 				--no-squash --no-stat
diff --git a/parse-options.h b/parse-options.h
index 0ba08691e6..ab1cc362bf 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -148,8 +148,8 @@ struct option {
 #define OPT_STRING_LIST(s, l, v, a, h) \
 				    { OPTION_CALLBACK, (s), (l), (v), (a), \
 				      (h), 0, &parse_opt_string_list }
-#define OPT_UYN(s, l, v, h, f)      { OPTION_CALLBACK, (s), (l), (v), NULL, \
-				      (h), PARSE_OPT_NOARG|(f), &parse_opt_tertiary }
+#define OPT_UYN(s, l, v, h)         { OPTION_CALLBACK, (s), (l), (v), NULL, \
+				      (h), PARSE_OPT_NOARG, &parse_opt_tertiary }
 #define OPT_DATE(s, l, v, h) \
 	{ OPTION_CALLBACK, (s), (l), (v), N_("time"),(h), 0,	\
 	  parse_opt_approxidate_cb }
diff --git a/rerere.h b/rerere.h
index 5e5a312e4c..c2961feaaa 100644
--- a/rerere.h
+++ b/rerere.h
@@ -37,7 +37,6 @@ extern void rerere_clear(struct string_list *);
 extern void rerere_gc(struct string_list *);
 
 #define OPT_RERERE_AUTOUPDATE(v) OPT_UYN(0, "rerere-autoupdate", (v), \
-	N_("update the index with reused conflict resolution if possible"), \
-	PARSE_OPT_NOCOMPLETE)
+	N_("update the index with reused conflict resolution if possible"))
 
 #endif
-- 
2.16.1.435.g8f24da2e1a
Eric Sunshine· Mar 3, 2018, 09:34 UTC · re: Nguyễn Thái Ngọc Duy · lore

Re: [PATCH 1/2] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate

On Sat, Mar 3, 2018 at 4:23 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> There is not a strong reason to hide this option, and git-merge already
> completes this one. Let's allow to complete this for all commands (and
> let git-completion.bash do the suppressing if neede).
s/neede/needed/
> This makes --rerere-autoupdate completable for am, cherry-pick and
> revert.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Phillip Wood· Mar 6, 2018, 10:22 UTC · re: Nguyễn Thái Ngọc Duy · lore

Re: [PATCH 1/2] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate

On 03/03/18 09:23, Nguyễn Thái Ngọc Duy wrote:
Show 8 quoted lines
> 
> There is not a strong reason to hide this option, and git-merge already
> completes this one. Let's allow to complete this for all commands (and
> let git-completion.bash do the suppressing if neede).
> 
> This makes --rerere-autoupdate completable for am, cherry-pick and
> revert.
> 

This is slightly off topic as it doesn't use OPT_RERERE_AUTOUPDATE but it looks[1] as if rebase is missing completion for --rerere-autoupdate (and --signoff which is definitely off topic)

Best Wishes
Phillip

[1] https://git.kernel.org/pub/scm/git/git.git/tree/contrib/completion/git-completion.bash#n2010

Show 50 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  contrib/completion/git-completion.bash | 3 +--
>  parse-options.h                        | 4 ++--
>  rerere.h                               | 3 +--
>  3 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 0ddf40063b..c310b241d3 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1754,8 +1754,7 @@ _git_merge ()
>  
>  	case "$cur" in
>  	--*)
> -		__gitcomp_builtin merge "--rerere-autoupdate
> -				--no-rerere-autoupdate
> +		__gitcomp_builtin merge "--no-rerere-autoupdate
>  				--no-commit --no-edit --no-ff
>  				--no-log --no-progress
>  				--no-squash --no-stat
> diff --git a/parse-options.h b/parse-options.h
> index 0ba08691e6..ab1cc362bf 100644
> --- a/parse-options.h
> +++ b/parse-options.h
> @@ -148,8 +148,8 @@ struct option {
>  #define OPT_STRING_LIST(s, l, v, a, h) \
>  				    { OPTION_CALLBACK, (s), (l), (v), (a), \
>  				      (h), 0, &parse_opt_string_list }
> -#define OPT_UYN(s, l, v, h, f)      { OPTION_CALLBACK, (s), (l), (v), NULL, \
> -				      (h), PARSE_OPT_NOARG|(f), &parse_opt_tertiary }
> +#define OPT_UYN(s, l, v, h)         { OPTION_CALLBACK, (s), (l), (v), NULL, \
> +				      (h), PARSE_OPT_NOARG, &parse_opt_tertiary }
>  #define OPT_DATE(s, l, v, h) \
>  	{ OPTION_CALLBACK, (s), (l), (v), N_("time"),(h), 0,	\
>  	  parse_opt_approxidate_cb }
> diff --git a/rerere.h b/rerere.h
> index 5e5a312e4c..c2961feaaa 100644
> --- a/rerere.h
> +++ b/rerere.h
> @@ -37,7 +37,6 @@ extern void rerere_clear(struct string_list *);
>  extern void rerere_gc(struct string_list *);
>  
>  #define OPT_RERERE_AUTOUPDATE(v) OPT_UYN(0, "rerere-autoupdate", (v), \
> -	N_("update the index with reused conflict resolution if possible"), \
> -	PARSE_OPT_NOCOMPLETE)
> +	N_("update the index with reused conflict resolution if possible"))
>  
>  #endif
> 
Nguyễn Thái Ngọc Duy· Mar 3, 2018, 09:23 UTC · re: Nguyễn Thái Ngọc Duy · lore

[PATCH 2/2] completion: simplify _git_notes

This also adds completion for 'git notes remove' with two options: --ignore-missing and --stdin.

For some strange reason, 'git notes undefined --<tab>' completes --ref without even running --git-completion-helper. But since this is an error case (and we're not doing anything destructive, it's probably ok for now)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 contrib/completion/git-completion.bash | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
Show changes to contrib/completion/git-completion.bash +2 −13
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c310b241d3..ab80f4e6e8 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1836,19 +1836,8 @@ _git_notes ()
 	add,--reedit-message=*|append,--reedit-message=*)
 		__git_complete_refs --cur="${cur#*=}"
 		;;
-	add,--*)
-		__gitcomp_builtin notes_add
-		;;
-	append,--*)
-		__gitcomp_builtin notes_append
-		;;
-	copy,--*)
-		__gitcomp_builtin notes_copy
-		;;
-	prune,--*)
-		__gitcomp_builtin notes_prune
-		;;
-	prune,*)
+	*,--*)
+		__gitcomp_builtin notes_$subcommand
 		;;
 	*)
 		case "$prev" in
-- 
2.16.1.435.g8f24da2e1a
SZEDER Gábor· Mar 3, 2018, 12:32 UTC · re: Nguyễn Thái Ngọc Duy · lore

Re: [PATCH 2/2] completion: simplify _git_notes

On Sat, Mar 3, 2018 at 10:23 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 5 quoted lines
> This also adds completion for 'git notes remove' with two options:
> --ignore-missing and --stdin.
>
> For some strange reason, 'git notes undefined --<tab>' completes --ref
> without even running --git-completion-helper.

There is nothing strange about it. _git_notes() first looks for the presence of any subcommands on the command line, and if it doesn't find any, it will list 'git notes's subcommands and options for completion. And it does so by running '__gitcomp "$subcommands --ref"'

> But since this is an error
> case (and we're not doing anything destructive, it's probably ok for now)
I agree; and it matches the behaviour before the patch.
Show 34 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  contrib/completion/git-completion.bash | 15 ++-------------
>  1 file changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index c310b241d3..ab80f4e6e8 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1836,19 +1836,8 @@ _git_notes ()
>         add,--reedit-message=*|append,--reedit-message=*)
>                 __git_complete_refs --cur="${cur#*=}"
>                 ;;
> -       add,--*)
> -               __gitcomp_builtin notes_add
> -               ;;
> -       append,--*)
> -               __gitcomp_builtin notes_append
> -               ;;
> -       copy,--*)
> -               __gitcomp_builtin notes_copy
> -               ;;
> -       prune,--*)
> -               __gitcomp_builtin notes_prune
> -               ;;
> -       prune,*)
> +       *,--*)
> +               __gitcomp_builtin notes_$subcommand
>                 ;;
>         *)
>                 case "$prev" in
> --
> 2.16.1.435.g8f24da2e1a
>
SZEDER Gábor· Mar 3, 2018, 13:09 UTC · re: Nguyễn Thái Ngọc Duy · lore

Re: [PATCH 2/2] completion: simplify _git_notes

On Sat, Mar 3, 2018 at 10:23 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 33 quoted lines
> This also adds completion for 'git notes remove' with two options:
> --ignore-missing and --stdin.
>
> For some strange reason, 'git notes undefined --<tab>' completes --ref
> without even running --git-completion-helper. But since this is an error
> case (and we're not doing anything destructive, it's probably ok for now)
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  contrib/completion/git-completion.bash | 15 ++-------------
>  1 file changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index c310b241d3..ab80f4e6e8 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1836,19 +1836,8 @@ _git_notes ()
>         add,--reedit-message=*|append,--reedit-message=*)
>                 __git_complete_refs --cur="${cur#*=}"
>                 ;;
> -       add,--*)
> -               __gitcomp_builtin notes_add
> -               ;;
> -       append,--*)
> -               __gitcomp_builtin notes_append
> -               ;;
> -       copy,--*)
> -               __gitcomp_builtin notes_copy
> -               ;;
> -       prune,--*)
> -               __gitcomp_builtin notes_prune
> -               ;;
> -       prune,*)
There is a minor behaviour change here, though.  This
  prune,*)
    ;;

case arm ensured that we don't list refs for 'git notes prune <TAB>', because it doesn't accept them (and then we take our usual fallback and let Bash complete filenames; yeah, 'git notes prune' doesn't accept filenames either, but, as I said, that's our usual fallback when we can't offer anything for completion).

This patch removes that case arm, and refs will be offered for 'git notes prune <TAB>'.

Show 8 quoted lines
> +       *,--*)
> +               __gitcomp_builtin notes_$subcommand
>                 ;;
>         *)
>                 case "$prev" in
> --
> 2.16.1.435.g8f24da2e1a
>
Junio C Hamano· Mar 6, 2018, 22:42 UTC · re: SZEDER Gábor · lore

Re: [PATCH 2/2] completion: simplify _git_notes

SZEDER Gábor <szeder.dev@gmail.com> writes:
Show 19 quoted lines
> There is a minor behaviour change here, though.  This
>
>   prune,*)
>     ;;
>
> case arm ensured that we don't list refs for 'git notes prune <TAB>',
> because it doesn't accept them (and then we take our usual fallback and
> let Bash complete filenames;  yeah, 'git notes prune' doesn't accept
> filenames either, but, as I said, that's our usual fallback when we
> can't offer anything for completion).
>
> This patch removes that case arm, and refs will be offered for 'git
> notes prune <TAB>'.
>
>> +       *,--*)
>> +               __gitcomp_builtin notes_$subcommand
>>                 ;;
>>         *)
>>                 case "$prev" in

I have this tentatively queued on the topic. Can we wrap the topic up and move it forward, instead of leaving it (and other topics) hanging around and causing conflicts with other topics in flight, please?

Thanks.
Subject: [PATCH] SQUASH???
By Szeder <CAM0VKjmmF2t=B2s3rJoKmO3j6Bk5d6PEfCV==ONRGMcdUMLFpQ@mail.gmail.com>
---
 contrib/completion/git-completion.bash | 5 +++++
 1 file changed, 5 insertions(+)
Show changes to contrib/completion/git-completion.bash +5 −0
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index ab80f4e6e8..5f7495cda3 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1836,6 +1836,11 @@ _git_notes ()
 	add,--reedit-message=*|append,--reedit-message=*)
 		__git_complete_refs --cur="${cur#*=}"
 		;;
+	prune,--*)
+		__gitcomp_builtin notes_prune
+		;;
+	prune,*)
+		;;
 	*,--*)
 		__gitcomp_builtin notes_$subcommand
 		;;
-- 
2.16.2-345-g7e31236f65
SZEDER Gábor· Mar 7, 2018, 01:08 UTC · re: Junio C Hamano · lore

Re: [PATCH 2/2] completion: simplify _git_notes

Show 56 quoted lines
> SZEDER Gábor <szeder.dev@gmail.com> writes:
> 
> > There is a minor behaviour change here, though.  This
> >
> >   prune,*)
> >     ;;
> >
> > case arm ensured that we don't list refs for 'git notes prune <TAB>',
> > because it doesn't accept them (and then we take our usual fallback and
> > let Bash complete filenames;  yeah, 'git notes prune' doesn't accept
> > filenames either, but, as I said, that's our usual fallback when we
> > can't offer anything for completion).
> >
> > This patch removes that case arm, and refs will be offered for 'git
> > notes prune <TAB>'.
> >
> >> +       *,--*)
> >> +               __gitcomp_builtin notes_$subcommand
> >>                 ;;
> >>         *)
> >>                 case "$prev" in
> 
> I have this tentatively queued on the topic.  Can we wrap the topic
> up and move it forward, instead of leaving it (and other topics)
> hanging around and causing conflicts with other topics in flight,
> please?
> 
> Thanks.
> 
> 
> Subject: [PATCH] SQUASH???
> 
> By Szeder <CAM0VKjmmF2t=B2s3rJoKmO3j6Bk5d6PEfCV==ONRGMcdUMLFpQ@mail.gmail.com>
> ---
>  contrib/completion/git-completion.bash | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index ab80f4e6e8..5f7495cda3 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1836,6 +1836,11 @@ _git_notes ()
>  	add,--reedit-message=*|append,--reedit-message=*)
>  		__git_complete_refs --cur="${cur#*=}"
>  		;;
> +	prune,--*)
> +		__gitcomp_builtin notes_prune
> +		;;
> +	prune,*)
> +		;;
>  	*,--*)
>  		__gitcomp_builtin notes_$subcommand
>  		;;
> -- 
> 2.16.2-345-g7e31236f65
> 

That works fine, but this would work just as well and has one less case arm:

Show changes to contrib/completion/git-completion.bash +2 −0
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index ab80f4e6e8..038af63c1a 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1839,6 +1839,8 @@ _git_notes ()
 	*,--*)
 		__gitcomp_builtin notes_$subcommand
 		;;
+	prune,*)
+		;;
 	*)
 		case "$prev" in
 		-m|-F)
Junio C Hamano· Mar 7, 2018, 18:51 UTC · re: SZEDER Gábor · lore

Re: [PATCH 2/2] completion: simplify _git_notes

SZEDER Gábor <szeder.dev@gmail.com> writes:
> That works fine, but this would work just as well and has one less
> case arm:

OK, I missed that "obvious optimization" opportunity. I agree that would work.

Show 14 quoted lines
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index ab80f4e6e8..038af63c1a 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1839,6 +1839,8 @@ _git_notes ()
>  	*,--*)
>  		__gitcomp_builtin notes_$subcommand
>  		;;
> +	prune,*)
> +		;;
>  	*)
>  		case "$prev" in
>  		-m|-F)
Nguyễn Thái Ngọc Duy· Mar 7, 2018, 01:05 UTC · re: Nguyễn Thái Ngọc Duy · lore

[PATCH v2 0/4] nd/parseopt-completion fixups

v2 fixes the comments from v1 and adds to new patches to improve _git_notes() (sorry I couldn't resist)

Interdiff with what's on 'pu'
Show changes to contrib/completion/git-completion.bash +6 −8
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 5f7495cda3..2e30950299 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1815,7 +1815,7 @@ _git_name_rev ()
 
 _git_notes ()
 {
-	local subcommands='add append copy edit list prune remove show'
+	local subcommands='add append copy edit get-ref list merge prune remove show'
 	local subcommand="$(__git_find_on_cmdline "$subcommands")"
 
 	case "$subcommand,$cur" in
@@ -1832,18 +1832,15 @@ _git_notes ()
 			;;
 		esac
 		;;
-	add,--reuse-message=*|append,--reuse-message=*|\
-	add,--reedit-message=*|append,--reedit-message=*)
+	*,--reuse-message=*|*,--reedit-message=*)
 		__git_complete_refs --cur="${cur#*=}"
 		;;
-	prune,--*)
-		__gitcomp_builtin notes_prune
-		;;
-	prune,*)
-		;;
 	*,--*)
 		__gitcomp_builtin notes_$subcommand
 		;;
+	prune,*|get-ref,*)
+		# this command does not take a ref, do not complete it
+		;;
 	*)
 		case "$prev" in
 		-m|-F)
@@ -1956,6 +1953,7 @@ _git_rebase ()
 			--autostash --no-autostash
 			--verify --no-verify
 			--keep-empty --root --force-rebase --no-ff
+			--rerere-autoupdate
 			--exec
 			"
 

Nguyễn Thái Ngọc Duy (4):
  completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate
  completion: simplify _git_notes
  completion: complete --{reuse,reedit}-message= for all notes subcmds
  completion: more subcommands in _git_notes()

 contrib/completion/git-completion.bash | 25 ++++++++-----------------
 parse-options.h                        |  4 ++--
 rerere.h                               |  3 +--
 3 files changed, 11 insertions(+), 21 deletions(-)
-- 
2.16.2.785.g429c04a1b9
Nguyễn Thái Ngọc Duy· Mar 7, 2018, 01:05 UTC · re: Nguyễn Thái Ngọc Duy · lore

[PATCH v2 1/4] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate

There is not a strong reason to hide this option, and git-merge already completes this one. Let's allow to complete this for all commands (and let git-completion.bash do the suppressing if needed).

This makes --rerere-autoupdate completable for am, cherry-pick and revert. rebase completion is fixed manually because it's a shell script and does not benefit from --git-completion-helper.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 contrib/completion/git-completion.bash | 4 ++--
 parse-options.h                        | 4 ++--
 rerere.h                               | 3 +--
 3 files changed, 5 insertions(+), 6 deletions(-)
Show changes to 3 files +5 −6

contrib/completion/git-completion.bash, parse-options.h, rerere.h

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 0ddf40063b..0d858cacce 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1754,8 +1754,7 @@ _git_merge ()
 
 	case "$cur" in
 	--*)
-		__gitcomp_builtin merge "--rerere-autoupdate
-				--no-rerere-autoupdate
+		__gitcomp_builtin merge "--no-rerere-autoupdate
 				--no-commit --no-edit --no-ff
 				--no-log --no-progress
 				--no-squash --no-stat
@@ -1963,6 +1962,7 @@ _git_rebase ()
 			--autostash --no-autostash
 			--verify --no-verify
 			--keep-empty --root --force-rebase --no-ff
+			--rerere-autoupdate
 			--exec
 			"
 
diff --git a/parse-options.h b/parse-options.h
index 0ba08691e6..ab1cc362bf 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -148,8 +148,8 @@ struct option {
 #define OPT_STRING_LIST(s, l, v, a, h) \
 				    { OPTION_CALLBACK, (s), (l), (v), (a), \
 				      (h), 0, &parse_opt_string_list }
-#define OPT_UYN(s, l, v, h, f)      { OPTION_CALLBACK, (s), (l), (v), NULL, \
-				      (h), PARSE_OPT_NOARG|(f), &parse_opt_tertiary }
+#define OPT_UYN(s, l, v, h)         { OPTION_CALLBACK, (s), (l), (v), NULL, \
+				      (h), PARSE_OPT_NOARG, &parse_opt_tertiary }
 #define OPT_DATE(s, l, v, h) \
 	{ OPTION_CALLBACK, (s), (l), (v), N_("time"),(h), 0,	\
 	  parse_opt_approxidate_cb }
diff --git a/rerere.h b/rerere.h
index 5e5a312e4c..c2961feaaa 100644
--- a/rerere.h
+++ b/rerere.h
@@ -37,7 +37,6 @@ extern void rerere_clear(struct string_list *);
 extern void rerere_gc(struct string_list *);
 
 #define OPT_RERERE_AUTOUPDATE(v) OPT_UYN(0, "rerere-autoupdate", (v), \
-	N_("update the index with reused conflict resolution if possible"), \
-	PARSE_OPT_NOCOMPLETE)
+	N_("update the index with reused conflict resolution if possible"))
 
 #endif
-- 
2.16.2.785.g429c04a1b9
Nguyễn Thái Ngọc Duy· Mar 7, 2018, 01:05 UTC · re: Nguyễn Thái Ngọc Duy · lore

[PATCH v2 2/4] completion: simplify _git_notes

This also adds completion for 'git notes remove' and 'git notes edit'.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 contrib/completion/git-completion.bash | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
Show changes to contrib/completion/git-completion.bash +3 −11
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 0d858cacce..37bf4a64d3 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1836,19 +1836,11 @@ _git_notes ()
 	add,--reedit-message=*|append,--reedit-message=*)
 		__git_complete_refs --cur="${cur#*=}"
 		;;
-	add,--*)
-		__gitcomp_builtin notes_add
-		;;
-	append,--*)
-		__gitcomp_builtin notes_append
-		;;
-	copy,--*)
-		__gitcomp_builtin notes_copy
-		;;
-	prune,--*)
-		__gitcomp_builtin notes_prune
+	*,--*)
+		__gitcomp_builtin notes_$subcommand
 		;;
 	prune,*)
+		# this command does not take a ref, do not complete it
 		;;
 	*)
 		case "$prev" in
-- 
2.16.2.785.g429c04a1b9
Nguyễn Thái Ngọc Duy· Mar 7, 2018, 01:05 UTC · re: Nguyễn Thái Ngọc Duy · lore

[PATCH v2 3/4] completion: complete --{reuse,reedit}-message= for all notes subcmds

The new subcommand that takes these options is 'git notes edit'. Just accept the options from subcommands since we handle them the same way in builtin/notes.c anyway. If a user does

    git prune --reuse-message=...
just let the command catches that error when it's executed.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 contrib/completion/git-completion.bash | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Show changes to contrib/completion/git-completion.bash +1 −2
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 37bf4a64d3..dc3ec43b65 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1832,8 +1832,7 @@ _git_notes ()
 			;;
 		esac
 		;;
-	add,--reuse-message=*|append,--reuse-message=*|\
-	add,--reedit-message=*|append,--reedit-message=*)
+	*,--reuse-message=*|*,--reedit-message=*)
 		__git_complete_refs --cur="${cur#*=}"
 		;;
 	*,--*)
-- 
2.16.2.785.g429c04a1b9
Nguyễn Thái Ngọc Duy· Mar 7, 2018, 01:05 UTC · re: Nguyễn Thái Ngọc Duy · lore

[PATCH v2 4/4] completion: more subcommands in _git_notes()

Two subcommands are added for completion: merge and get-ref. get-ref is more like plumbing. But since it does not share the prefix with any other subcommands, it won't slow anybody down.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 contrib/completion/git-completion.bash | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to contrib/completion/git-completion.bash +2 −2
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index dc3ec43b65..2e30950299 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1815,7 +1815,7 @@ _git_name_rev ()
 
 _git_notes ()
 {
-	local subcommands='add append copy edit list prune remove show'
+	local subcommands='add append copy edit get-ref list merge prune remove show'
 	local subcommand="$(__git_find_on_cmdline "$subcommands")"
 
 	case "$subcommand,$cur" in
@@ -1838,7 +1838,7 @@ _git_notes ()
 	*,--*)
 		__gitcomp_builtin notes_$subcommand
 		;;
-	prune,*)
+	prune,*|get-ref,*)
 		# this command does not take a ref, do not complete it
 		;;
 	*)
-- 
2.16.2.785.g429c04a1b9

← back to recent threads