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

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

From
Vincent Mailhol <mailhol@kernel.org>
Date
Aug 13, 2026, 19:05 UTC
Message-ID
<20260813-history_autocompletion-v3-3-69eed1cea93a@kernel.org>
In-Reply-To
<20260813-history_autocompletion-v3-0-69eed1cea93a@kernel.org>

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 <mailhol@kernel.org>
---
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
Previous: Patrick SteinhardtNext: Vincent Mailhol
Message 12 of 18 in “completion: add 'git history' subcommands”
  1. completion: add 'git history' subcommandsVincent Mailhol, Aug 4, 2026
  2. Patrick SteinhardtAug 5, 2026
  3. D. Ben KnobleAug 5, 2026
  4. Junio C HamanoAug 5, 2026
  5. Vincent MailholAug 5, 2026
  6. Patrick SteinhardtAug 6, 2026
  7. 0/4 completion: add support for 'git history'Vincent Mailhol, Aug 13, 2026
  8. 1/4 completion: add 'git history' subcommandsVincent Mailhol, Aug 13, 2026
  9. Patrick SteinhardtAug 19, 2026
  10. 2/4 completion: complete 'git history --empty' valuesVincent Mailhol, Aug 13, 2026
  11. Patrick SteinhardtAug 19, 2026
  12. 3/4 completion: complete 'git history --update-refs' valuesVincent Mailhol, Aug 13, 2026
  13. 4/4 completion: complete 'git history split' pathspecsVincent Mailhol, Aug 13, 2026
  14. Kristoffer HaugsbakkAug 13, 2026
  15. Vincent MailholAug 14, 2026
  16. Kristoffer HaugsbakkAug 14, 2026
  17. Patrick SteinhardtAug 19, 2026
  18. Junio C HamanoAug 19, 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.