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

[PATCH v2 4/4] completion: use __git when calling --list-cmds

From
Todd Zullinger <tmz@pobox.com>
Date
Mar 17, 2019, 18:16 UTC
Message-ID
<20190317181620.26727-5-tmz@pobox.com>
In-Reply-To
<CACsJy8BuR=syjT1gjTxXXKKaevzpbdRGp+je+rsX6jV96F3sbA@mail.gmail.com>

Since e51bdea6d3 ("git: read local config in --list-cmds", 2019-03-01), the completion.commands variable respects repo-level configuration. Use __git which ensures that the proper repo config is consulted if the command line contains 'git -C /some/other/repo'.

Suggested-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Todd Zullinger <tmz@pobox.com>
---

Junio, I referenc the commit id for "git: read local config in --list-cmds" which is earlier in this series, so the id will, of course, differ when you apply it. Let me know if you'd prefer this commit to be dropped and resent once the others in the series are applied or if it's easy for you to adjust when it's queued.

Also, as I wrote in an earlier reply, at the moment, I think using __git only matters for calls where config is in the --list-cmds list. But since Jeff's fix affects all --list-cmds calls, it seems prudent to adjust the 3 other uses of --list-cmds in the completion script.

 contrib/completion/git-completion.bash | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 499e56f83d..e505f04ff7 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1010,7 +1010,7 @@ __git_all_commands=
 __git_compute_all_commands ()
 {
 	test -n "$__git_all_commands" ||
-	__git_all_commands=$(git --list-cmds=main,others,alias,nohelpers)
+	__git_all_commands=$(__git --list-cmds=main,others,alias,nohelpers)
 }
 
 # Lists all set config variables starting with the given section prefix,
@@ -1620,9 +1620,9 @@ _git_help ()
 	esac
 	if test -n "$GIT_TESTING_ALL_COMMAND_LIST"
 	then
-		__gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(git --list-cmds=alias,list-guide) gitk"
+		__gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk"
 	else
-		__gitcomp "$(git --list-cmds=main,nohelpers,alias,list-guide) gitk"
+		__gitcomp "$(__git --list-cmds=main,nohelpers,alias,list-guide) gitk"
 	fi
 }
 
@@ -2888,7 +2888,7 @@ __git_main ()
 			then
 				__gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
 			else
-				__gitcomp "$(git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
+				__gitcomp "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
 			fi
 			;;
 		esac
Previous: Todd ZullingerNext: Todd Zullinger
Message 28 of 35 in “[BUG] completion.commands does not remove multiple commands”
  1. Todd ZullingerFeb 28, 2019
  2. Jeff KingFeb 28, 2019
  3. Todd ZullingerMar 1, 2019
  4. Jeff KingMar 1, 2019
  5. Todd ZullingerMar 1, 2019
  6. Jeff KingMar 1, 2019
  7. Duy NguyenMar 2, 2019
  8. Junio C HamanoMar 2, 2019
  9. Todd ZullingerMar 2, 2019
  10. SZEDER GáborMar 2, 2019
  11. Todd ZullingerMar 3, 2019
  12. Jeff KingMar 3, 2019
  13. 1/3 doc: note config file restrictions for completion.commandsTodd Zullinger, Mar 1, 2019
  14. Duy NguyenMar 17, 2019
  15. 1/4 git: read local config in --list-cmdsTodd Zullinger, Mar 17, 2019
  16. Duy NguyenMar 18, 2019
  17. 0/4 completion.commands: fix multiple command removalsTodd Zullinger, Mar 20, 2019
  18. Junio C HamanoMar 21, 2019
  19. Todd ZullingerMar 21, 2019
  20. Duy NguyenMar 21, 2019
  21. 1/4 git: read local config in --list-cmdsTodd Zullinger, Mar 20, 2019
  22. 2/4 t9902: test multiple removals via completion.commandsTodd Zullinger, Mar 20, 2019
  23. 3/4 completion: fix multiple command removalsTodd Zullinger, Mar 20, 2019
  24. 4/4 completion: use __git when calling --list-cmdsTodd Zullinger, Mar 20, 2019
  25. 0/4 completion.commands: fix multiple command removalsTodd Zullinger, Mar 17, 2019
  26. 2/4 t9902: test multiple removals via completion.commandsTodd Zullinger, Mar 17, 2019
  27. 3/4 completion: fix multiple command removalsTodd Zullinger, Mar 17, 2019
  28. 4/4 completion: use __git when calling --list-cmdsTodd Zullinger, Mar 17, 2019
  29. 2/3 t9902: test multiple removals via completion.commandsTodd Zullinger, Mar 1, 2019
  30. Eric SunshineMar 1, 2019
  31. SZEDER GáborMar 1, 2019
  32. Todd ZullingerMar 1, 2019
  33. 3/3 completion: fix multiple command removalsTodd Zullinger, Mar 1, 2019
  34. Jeff KingMar 1, 2019
  35. SZEDER GáborFeb 28, 2019

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.