git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/2] nd/parseopt-completion fixups
@ 2018-03-03  9:23 Nguyễn Thái Ngọc Duy
  2018-03-03  9:23 ` [PATCH 1/2] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate Nguyễn Thái Ngọc Duy
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-03  9:23 UTC (permalink / raw)
  To: git
  Cc: avarab, gitster, sunshine, szeder.dev,
	Nguyễn Thái Ngọc Duy

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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/2] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate
  2018-03-03  9:23 [PATCH 0/2] nd/parseopt-completion fixups Nguyễn Thái Ngọc Duy
@ 2018-03-03  9:23 ` Nguyễn Thái Ngọc Duy
  2018-03-03  9:34   ` Eric Sunshine
  2018-03-06 10:22   ` Phillip Wood
  2018-03-03  9:23 ` [PATCH 2/2] completion: simplify _git_notes Nguyễn Thái Ngọc Duy
  2018-03-07  1:05 ` [PATCH v2 0/4] nd/parseopt-completion fixups Nguyễn Thái Ngọc Duy
  2 siblings, 2 replies; 15+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-03  9:23 UTC (permalink / raw)
  To: git
  Cc: avarab, gitster, sunshine, szeder.dev,
	Nguyễn Thái Ngọc Duy

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

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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/2] completion: simplify _git_notes
  2018-03-03  9:23 [PATCH 0/2] nd/parseopt-completion fixups Nguyễn Thái Ngọc Duy
  2018-03-03  9:23 ` [PATCH 1/2] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate Nguyễn Thái Ngọc Duy
@ 2018-03-03  9:23 ` Nguyễn Thái Ngọc Duy
  2018-03-03 12:32   ` SZEDER Gábor
  2018-03-03 13:09   ` SZEDER Gábor
  2018-03-07  1:05 ` [PATCH v2 0/4] nd/parseopt-completion fixups Nguyễn Thái Ngọc Duy
  2 siblings, 2 replies; 15+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-03  9:23 UTC (permalink / raw)
  To: git
  Cc: avarab, gitster, sunshine, szeder.dev,
	Nguyễn Thái Ngọc Duy

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,*)
+	*,--*)
+		__gitcomp_builtin notes_$subcommand
 		;;
 	*)
 		case "$prev" in
-- 
2.16.1.435.g8f24da2e1a


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/2] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate
  2018-03-03  9:23 ` [PATCH 1/2] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate Nguyễn Thái Ngọc Duy
@ 2018-03-03  9:34   ` Eric Sunshine
  2018-03-06 10:22   ` Phillip Wood
  1 sibling, 0 replies; 15+ messages in thread
From: Eric Sunshine @ 2018-03-03  9:34 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy
  Cc: Git List, Ævar Arnfjörð Bjarmason, Junio C Hamano,
	SZEDER Gábor

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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/2] completion: simplify _git_notes
  2018-03-03  9:23 ` [PATCH 2/2] completion: simplify _git_notes Nguyễn Thái Ngọc Duy
@ 2018-03-03 12:32   ` SZEDER Gábor
  2018-03-03 13:09   ` SZEDER Gábor
  1 sibling, 0 replies; 15+ messages in thread
From: SZEDER Gábor @ 2018-03-03 12:32 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy
  Cc: Git mailing list, Ævar Arnfjörð Bjarmason,
	Junio C Hamano, Eric Sunshine

On Sat, Mar 3, 2018 at 10:23 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> 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.

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/2] completion: simplify _git_notes
  2018-03-03  9:23 ` [PATCH 2/2] completion: simplify _git_notes Nguyễn Thái Ngọc Duy
  2018-03-03 12:32   ` SZEDER Gábor
@ 2018-03-03 13:09   ` SZEDER Gábor
  2018-03-06 22:42     ` Junio C Hamano
  1 sibling, 1 reply; 15+ messages in thread
From: SZEDER Gábor @ 2018-03-03 13:09 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy
  Cc: Git mailing list, Ævar Arnfjörð Bjarmason,
	Junio C Hamano, Eric Sunshine

On Sat, Mar 3, 2018 at 10:23 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> 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>'.

> +       *,--*)
> +               __gitcomp_builtin notes_$subcommand
>                 ;;
>         *)
>                 case "$prev" in
> --
> 2.16.1.435.g8f24da2e1a
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/2] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate
  2018-03-03  9:23 ` [PATCH 1/2] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate Nguyễn Thái Ngọc Duy
  2018-03-03  9:34   ` Eric Sunshine
@ 2018-03-06 10:22   ` Phillip Wood
  1 sibling, 0 replies; 15+ messages in thread
From: Phillip Wood @ 2018-03-06 10:22 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy, git
  Cc: avarab, gitster, sunshine, szeder.dev

On 03/03/18 09:23, Nguyễn Thái Ngọc Duy 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).
> 
> 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


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/2] completion: simplify _git_notes
  2018-03-03 13:09   ` SZEDER Gábor
@ 2018-03-06 22:42     ` Junio C Hamano
  2018-03-07  1:08       ` SZEDER Gábor
  0 siblings, 1 reply; 15+ messages in thread
From: Junio C Hamano @ 2018-03-06 22:42 UTC (permalink / raw)
  To: SZEDER Gábor
  Cc: Nguyễn Thái Ngọc Duy, Git mailing list,
	Ævar Arnfjörð Bjarmason, Eric Sunshine

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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 0/4] nd/parseopt-completion fixups
  2018-03-03  9:23 [PATCH 0/2] nd/parseopt-completion fixups Nguyễn Thái Ngọc Duy
  2018-03-03  9:23 ` [PATCH 1/2] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate Nguyễn Thái Ngọc Duy
  2018-03-03  9:23 ` [PATCH 2/2] completion: simplify _git_notes Nguyễn Thái Ngọc Duy
@ 2018-03-07  1:05 ` Nguyễn Thái Ngọc Duy
  2018-03-07  1:05   ` [PATCH v2 1/4] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate Nguyễn Thái Ngọc Duy
                     ` (3 more replies)
  2 siblings, 4 replies; 15+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-07  1:05 UTC (permalink / raw)
  To: pclouds; +Cc: avarab, git, gitster, sunshine, szeder.dev, phillip.wood

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'

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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 1/4] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate
  2018-03-07  1:05 ` [PATCH v2 0/4] nd/parseopt-completion fixups Nguyễn Thái Ngọc Duy
@ 2018-03-07  1:05   ` Nguyễn Thái Ngọc Duy
  2018-03-07  1:05   ` [PATCH v2 2/4] completion: simplify _git_notes Nguyễn Thái Ngọc Duy
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 15+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-07  1:05 UTC (permalink / raw)
  To: pclouds; +Cc: avarab, git, gitster, sunshine, szeder.dev, phillip.wood

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

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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 2/4] completion: simplify _git_notes
  2018-03-07  1:05 ` [PATCH v2 0/4] nd/parseopt-completion fixups Nguyễn Thái Ngọc Duy
  2018-03-07  1:05   ` [PATCH v2 1/4] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate Nguyễn Thái Ngọc Duy
@ 2018-03-07  1:05   ` Nguyễn Thái Ngọc Duy
  2018-03-07  1:05   ` [PATCH v2 3/4] completion: complete --{reuse,reedit}-message= for all notes subcmds Nguyễn Thái Ngọc Duy
  2018-03-07  1:05   ` [PATCH v2 4/4] completion: more subcommands in _git_notes() Nguyễn Thái Ngọc Duy
  3 siblings, 0 replies; 15+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-07  1:05 UTC (permalink / raw)
  To: pclouds; +Cc: avarab, git, gitster, sunshine, szeder.dev, phillip.wood

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

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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 3/4] completion: complete --{reuse,reedit}-message= for all notes subcmds
  2018-03-07  1:05 ` [PATCH v2 0/4] nd/parseopt-completion fixups Nguyễn Thái Ngọc Duy
  2018-03-07  1:05   ` [PATCH v2 1/4] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate Nguyễn Thái Ngọc Duy
  2018-03-07  1:05   ` [PATCH v2 2/4] completion: simplify _git_notes Nguyễn Thái Ngọc Duy
@ 2018-03-07  1:05   ` Nguyễn Thái Ngọc Duy
  2018-03-07  1:05   ` [PATCH v2 4/4] completion: more subcommands in _git_notes() Nguyễn Thái Ngọc Duy
  3 siblings, 0 replies; 15+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-07  1:05 UTC (permalink / raw)
  To: pclouds; +Cc: avarab, git, gitster, sunshine, szeder.dev, phillip.wood

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

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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 4/4] completion: more subcommands in _git_notes()
  2018-03-07  1:05 ` [PATCH v2 0/4] nd/parseopt-completion fixups Nguyễn Thái Ngọc Duy
                     ` (2 preceding siblings ...)
  2018-03-07  1:05   ` [PATCH v2 3/4] completion: complete --{reuse,reedit}-message= for all notes subcmds Nguyễn Thái Ngọc Duy
@ 2018-03-07  1:05   ` Nguyễn Thái Ngọc Duy
  3 siblings, 0 replies; 15+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-07  1:05 UTC (permalink / raw)
  To: pclouds; +Cc: avarab, git, gitster, sunshine, szeder.dev, phillip.wood

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

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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/2] completion: simplify _git_notes
  2018-03-06 22:42     ` Junio C Hamano
@ 2018-03-07  1:08       ` SZEDER Gábor
  2018-03-07 18:51         ` Junio C Hamano
  0 siblings, 1 reply; 15+ messages in thread
From: SZEDER Gábor @ 2018-03-07  1:08 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: SZEDER Gábor, Nguyễn Thái Ngọc Duy,
	Git mailing list, Ævar Arnfjörð Bjarmason,
	Eric Sunshine


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

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)

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/2] completion: simplify _git_notes
  2018-03-07  1:08       ` SZEDER Gábor
@ 2018-03-07 18:51         ` Junio C Hamano
  0 siblings, 0 replies; 15+ messages in thread
From: Junio C Hamano @ 2018-03-07 18:51 UTC (permalink / raw)
  To: SZEDER Gábor
  Cc: Nguyễn Thái Ngọc Duy, Git mailing list,
	Ævar Arnfjörð Bjarmason, Eric Sunshine

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.

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-03-07 18:51 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-03  9:23 [PATCH 0/2] nd/parseopt-completion fixups Nguyễn Thái Ngọc Duy
2018-03-03  9:23 ` [PATCH 1/2] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate Nguyễn Thái Ngọc Duy
2018-03-03  9:34   ` Eric Sunshine
2018-03-06 10:22   ` Phillip Wood
2018-03-03  9:23 ` [PATCH 2/2] completion: simplify _git_notes Nguyễn Thái Ngọc Duy
2018-03-03 12:32   ` SZEDER Gábor
2018-03-03 13:09   ` SZEDER Gábor
2018-03-06 22:42     ` Junio C Hamano
2018-03-07  1:08       ` SZEDER Gábor
2018-03-07 18:51         ` Junio C Hamano
2018-03-07  1:05 ` [PATCH v2 0/4] nd/parseopt-completion fixups Nguyễn Thái Ngọc Duy
2018-03-07  1:05   ` [PATCH v2 1/4] completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate Nguyễn Thái Ngọc Duy
2018-03-07  1:05   ` [PATCH v2 2/4] completion: simplify _git_notes Nguyễn Thái Ngọc Duy
2018-03-07  1:05   ` [PATCH v2 3/4] completion: complete --{reuse,reedit}-message= for all notes subcmds Nguyễn Thái Ngọc Duy
2018-03-07  1:05   ` [PATCH v2 4/4] completion: more subcommands in _git_notes() Nguyễn Thái Ngọc Duy

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