git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Vincent Mailhol <mailhol@kernel.org>
Date
Aug 6, 2026, 20:27 UTC
Message-ID
<20260806-history_autocompletion-v2-3-7e60f52a1c20@kernel.org>
In-Reply-To
<20260806-history_autocompletion-v2-0-7e60f52a1c20@kernel.org>

The "--update-refs" option accepts either "branches" or "head". Complete these values.

Although the synopsis only documents the:
  --update-refs=<value>
form, parse-options also accepts the value as a separate argument:
  --update-refs <value>
Support both forms to follow the parser.
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
Changes in v2:
  - New patch.
---
 contrib/completion/git-completion.bash | 5 +++++
 t/t9902-completion.sh                  | 6 +++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index fe5223b8ec..6f1ba96763 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2181,6 +2181,11 @@ _git_history ()
 				;;
 			esac
 			;;
+		--update-refs,*|*,--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 52a036a1ad..ea86ecc08f 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -3129,7 +3129,11 @@ test_expect_success 'git history subcommand options' '
 	test_completion "git history reword main -- --d" "" &&
 	test_completion "git history fixup --empty=ke" "keep " &&
 	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=he" "head " &&
+	test_completion "git history split --update-refs he" "head " &&
+	test_completion "git history reword main -- --update-refs=he" "" &&
+	test_completion "git history reword main -- --update-refs he" ""
 '
 
 test_expect_success 'git history revisions' '
-- 
2.54.0
Previous: Vincent MailholNext: D. Ben Knoble
Message 14 of 17 in “completion: add support for 'git history'”
  1. 0/4 completion: add support for 'git history'Vincent Mailhol, Aug 6, 2026
  2. 1/4 completion: add 'git history' subcommandsVincent Mailhol, Aug 6, 2026
  3. Patrick SteinhardtAug 7, 2026
  4. Vincent MailholAug 7, 2026
  5. Patrick SteinhardtAug 7, 2026
  6. Vincent MailholAug 7, 2026
  7. D. Ben KnobleAug 10, 2026
  8. 2/4 completion: complete 'git history --empty' valuesVincent Mailhol, Aug 6, 2026
  9. D. Ben KnobleAug 10, 2026
  10. D. Ben KnobleAug 10, 2026
  11. Vincent MailholAug 13, 2026
  12. Ben KnobleAug 13, 2026
  13. Vincent MailholAug 13, 2026
  14. 3/4 completion: complete 'git history --update-refs' valuesVincent Mailhol, Aug 6, 2026
  15. D. Ben KnobleAug 10, 2026
  16. 4/4 completion: complete 'git history split' pathspecsVincent Mailhol, Aug 6, 2026
  17. D. Ben KnobleAug 10, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.