[PATCH v3 3/4] completion: complete 'git history --update-refs' values

Vincent Mailhol <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
The "--update-refs" option accepts either "branches" or "head".
Complete these values for the documented

  --update-refs=<value>

form.

While parse-options also accepts the split

  --update-refs <value>

form, it is not documented. Omit it from completion as a trade-off for
code simplicity.

Signed-off-by: Vincent Mailhol <[email protected]>
---
Changes in v3:

  - Complete only the documented stuck form.

Changes in v2:

  - New patch.
---
 contrib/completion/git-completion.bash | 5 +++++
 t/t9902-completion.sh                  | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 7f3cabd595..19600940dc 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2178,6 +2178,11 @@ _git_history ()
 			esac
 			return
 			;;
+		--update-refs=*)
+			__gitcomp "branches head" "" \
+				"${cur##--update-refs=}"
+			return
+			;;
 		--*)
 			__gitcomp_builtin "history_$subcommand"
 			return
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 851be383e1..b225dd3800 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -3131,7 +3131,10 @@ test_expect_success 'git history subcommand options' '
 	test_completion "git history fixup --empty=ke" "keep " &&
 	test_completion "git history fixup --empty=drop" "drop " &&
 	test_completion "git history drop --empty=ab" "abort " &&
-	test_completion "git history reword --empty=ke" ""
+	test_completion "git history reword --empty=ke" "" &&
+	test_completion "git history fixup --update-refs=branch" "branches " &&
+	test_completion "git history split --update-refs=he" "head " &&
+	test_completion "git history reword main -- --update-refs=he" ""
 '
 
 test_expect_success 'git history revisions' '

-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.