Skip to contentSkip to conversation

completion: use __gitcomp_builtin for format-patch

PATCH In review Nguyễn Thái Ngọc Duy 3 participants 4 messages Oct 21, 2018 – Oct 22, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 completion: use __gitcomp_builtin for format-patch

This helps format-patch gain completion for a couple new options, notably --range-diff.

---
Of course it will be even better if I could complete the ref for --range-diff=, but maybe another day.

 contrib/completion/git-completion.bash | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
contrib/completion/git-completion.bash +3 -7
index c8fdcf8644..065b922777 100644
@@ -1533,12 +1533,8 @@ _git_fetch ()
 }
 
 __git_format_patch_options="
-	--stdout --attach --no-attach --thread --thread= --no-thread
-	--numbered --start-number --numbered-files --keep-subject --signoff
-	--signature --no-signature --in-reply-to= --cc= --full-index --binary
-	--not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
-	--inline --suffix= --ignore-if-in-upstream --subject-prefix=
-	--output-directory --reroll-count --to= --quiet --notes
+	--full-index --not --all --no-prefix --src-prefix=
+	--dst-prefix= --notes
 "
 
 _git_format_patch ()
@@ -1551,7 +1547,7 @@ _git_format_patch ()
 		return
 		;;
 	--*)
-		__gitcomp "$__git_format_patch_options"
+		__gitcomp_builtin format-patch "$__git_format_patch_options"
 		return
 		;;
 	esac
Signature · 1 line
2.19.1.647.g708186aaf9
#1 lore raw
Quoted 18 lines · Nguyễn Thái Ngọc Duy

This helps format-patch gain completion for a couple new options, notably --range-diff.

---
Of course it will be even better if I could complete the ref for --range-diff=, but maybe another day.

 contrib/completion/git-completion.bash | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
contrib/completion/git-completion.bash +0 -0
index c8fdcf8644..065b922777 100644
@@ -1533,12 +1533,8 @@ _git_fetch ()
 }
 

contrib/completion/git-completion.bash _git_fetch () · line 1538

Quoted 10 lines
contrib/completion/git-completion.bash +2 -6
 __git_format_patch_options="
-	--stdout --attach --no-attach --thread --thread= --no-thread
-	--numbered --start-number --numbered-files --keep-subject --signoff
-	--signature --no-signature --in-reply-to= --cc= --full-index --binary
-	--not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
-	--inline --suffix= --ignore-if-in-upstream --subject-prefix=
-	--output-directory --reroll-count --to= --quiet --notes
+	--full-index --not --all --no-prefix --src-prefix=
+	--dst-prefix= --notes
 "

$__git_format_patch_options is also used when completing 'git send-email's options, thus removing all these options will badly affect that, and in fact makes 't9902-completion.sh' fail with:

  expecting success:
          test_completion "git send-email --cov" "--cover-letter " &&
          test_completion "git send-email ma" "master "

--- expected 2018-10-22 09:03:42.255325418 +0000
+++ out_sorted 2018-10-22 09:03:42.255325418 +0000 @@ -1 +1 @@
---cover-letter
+
not ok 122 - send-email
#
# test_completion "git send-email --cov" "--cover-letter " &&
# test_completion "git send-email ma" "master "
#

contrib/completion/git-completion.bash _git_format_patch () · line 1550

Quoted 7 lines
contrib/completion/git-completion.bash +1 -1
 _git_format_patch ()
@@ -1551,7 +1547,7 @@ _git_format_patch ()
 		return
 		;;
 	--*)
-		__gitcomp "$__git_format_patch_options"
+		__gitcomp_builtin format-patch "$__git_format_patch_options"

You sent out a separate bugfix patch (i.e. not a patch series) "completion: fix __gitcomp_builtin no longer consider extra options" in:

https://public-inbox.org/git/[email protected]/

and this patch makes the completion of 'git format-patch' also use extra options... So, does this patch really work without that bugfix?

Quoted 6 lines
contrib/completion/git-completion.bash +0 -0
 		return
 		;;
 	esac
Signature · 1 line
2.19.1.647.g708186aaf9
#3 lore raw
In reply to Nguyễn Thái Ngọc Duy

Hi Duy,

Quoted 31 lines · Nguyễn Thái Ngọc Duy

This helps format-patch gain completion for a couple new options, notably --range-diff.

---
Of course it will be even better if I could complete the ref for --range-diff=, but maybe another day.

 contrib/completion/git-completion.bash | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
contrib/completion/git-completion.bash +2 -6
index c8fdcf8644..065b922777 100644
@@ -1533,12 +1533,8 @@ _git_fetch ()
 }
 
 __git_format_patch_options="
-	--stdout --attach --no-attach --thread --thread= --no-thread
-	--numbered --start-number --numbered-files --keep-subject --signoff
-	--signature --no-signature --in-reply-to= --cc= --full-index --binary
-	--not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
-	--inline --suffix= --ignore-if-in-upstream --subject-prefix=
-	--output-directory --reroll-count --to= --quiet --notes
+	--full-index --not --all --no-prefix --src-prefix=
+	--dst-prefix= --notes
 "
 
 _git_format_patch ()

contrib/completion/git-completion.bash _git_format_patch () · line 1550

Quoted 5 lines
contrib/completion/git-completion.bash +1 -1
@@ -1551,7 +1547,7 @@ _git_format_patch ()
 		return
 		;;
 	--*)
-		__gitcomp "$__git_format_patch_options"
+		__gitcomp_builtin format-patch "$__git_format_patch_options"

Is it just me, or does this fail t9902 for you, too, where it wants to complete the --cover-letter option for *send-email* (not for *format-patch*)?

See e.g.
https://git-for-windows.visualstudio.com/git/_build/results?buildId=22023&view=logs

Ciao,
Dscho

Quoted 8 lines
contrib/completion/git-completion.bash +0 -0
 		return
 		;;
 	esac
Signature · 1 line
2.19.1.647.g708186aaf9
author
#2 lore raw
In reply to SZEDER Gábor
Quoted 20 lines · SZEDER Gábor
Quoted 18 lines · Nguyễn Thái Ngọc Duy

This helps format-patch gain completion for a couple new options, notably --range-diff.

---
Of course it will be even better if I could complete the ref for --range-diff=, but maybe another day.

 contrib/completion/git-completion.bash | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
contrib/completion/git-completion.bash +0 -0
index c8fdcf8644..065b922777 100644
@@ -1533,12 +1533,8 @@ _git_fetch ()
 }
 
Quoted 14 lines

contrib/completion/git-completion.bash _git_fetch () · line 1538

Quoted 10 lines
contrib/completion/git-completion.bash +2 -6
 __git_format_patch_options="
-     --stdout --attach --no-attach --thread --thread= --no-thread
-     --numbered --start-number --numbered-files --keep-subject --signoff
-     --signature --no-signature --in-reply-to= --cc= --full-index --binary
-     --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
-     --inline --suffix= --ignore-if-in-upstream --subject-prefix=
-     --output-directory --reroll-count --to= --quiet --notes
+     --full-index --not --all --no-prefix --src-prefix=
+     --dst-prefix= --notes
 "

$__git_format_patch_options is also used when completing 'git send-email's options, thus removing all these options will badly affect that, and in fact makes 't9902-completion.sh' fail with:

Oops. I guess I was excited about the other fix and forgot to test this patch. Junio please kick it out of 'pu'.

I'll need to think if I could somehow make send-email work without hardcoding a bunch of options in it.,,

Signature · 1 line
Duy