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

[PATCH 3/4] completion: fix branch.autosetup(merge|rebase)

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Dec 30, 2013, 14:52 UTC
Message-ID
<1388415138-11011-4-git-send-email-artagnon@gmail.com>
In-Reply-To
<1388415138-11011-1-git-send-email-artagnon@gmail.com>
When attempting to complete
  $ git config branch.auto<TAB>

'autosetupmerge' and 'autosetuprebase' don't come up. This is because "$cur" is matched with "branch.*" and a list of branches are completed. Add 'autosetup(merge|rebase)' to the list of branches using __gitcomp_2 ().

Also take care to not complete
  $ git config branch.autosetupmerge.<TAB>
  $ git config branch.autosetuprebase.<TAB>
with the usual branch.<name>. candidates.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 contrib/completion/git-completion.bash | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 64b20b8..0bda757 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1851,12 +1851,18 @@ _git_config ()
 		;;
 	branch.*.*)
 		local pfx="${cur%.*}." cur_="${cur##*.}"
+		if [ "$pfx" == "branch.autosetupmerge." ] ||
+			[ "$pfx" == "branch.autosetuprebase." ]; then
+			return
+		fi
 		__gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"
 		return
 		;;
 	branch.*)
 		local pfx="${cur%.*}." cur_="${cur#*.}"
-		__gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
+		__gitcomp_2 "$(__git_heads)" "
+			autosetupmerge autosetuprebase
+			" "$pfx" "$cur_" "."
 		return
 		;;
 	guitool.*.*)
-- 
1.8.5.2.227.g53f3478
Previous: Ramkumar RamachandraNext: Junio C Hamano
Message 8 of 14 in “Fix branch.autosetup(merge|rebase) completion”
  1. 0/4 Fix branch.autosetup(merge|rebase) completionRamkumar Ramachandra, Dec 30, 2013
  2. 1/4 completion: prioritize ./git-completion.bashRamkumar Ramachandra, Dec 30, 2013
  3. 2/4 completion: introduce __gitcomp_2 ()Ramkumar Ramachandra, Dec 30, 2013
  4. Junio C HamanoJan 2, 2014
  5. Ramkumar RamachandraJan 3, 2014
  6. Junio C HamanoJan 3, 2014
  7. Ramkumar RamachandraJan 3, 2014
  8. 3/4 completion: fix branch.autosetup(merge|rebase)Ramkumar Ramachandra, Dec 30, 2013
  9. Junio C HamanoJan 2, 2014
  10. Ramkumar RamachandraJan 3, 2014
  11. Junio C HamanoJan 3, 2014
  12. Ramkumar RamachandraJan 3, 2014
  13. Junio C HamanoJan 3, 2014
  14. 4/4 completion: fix remote.pushdefaultRamkumar Ramachandra, Dec 30, 2013

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.