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

[PATCH] completion: loosen and document the requirement around completing alias

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 20, 2023, 18:28 UTC
Message-ID
<xmqqy1h08zsp.fsf_-_@gitster.g>
In-Reply-To
<pull.1585.v2.git.1694538135853.gitgitgadget@gmail.com>

Recently we started to tell users to spell ": git foo ;" with space(s) around 'foo' for an alias to be completed similarly to the 'git foo' command. It however is easy to also allow users to spell it in a more natural way with the semicolon attached to 'foo', i.e. ": git foo;". Also, add a comment to note that 'git' is optional and writing ": foo;" would complete the alias just fine.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * We've discussed this when we reviewed the topic that just hit
   'master'.  Before we forget...
 contrib/completion/git-completion.bash | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git c/contrib/completion/git-completion.bash w/contrib/completion/git-completion.bash
index 47fd664ea5..477ef8157a 100644
--- c/contrib/completion/git-completion.bash
+++ w/contrib/completion/git-completion.bash
@@ -28,7 +28,8 @@
 # completion style.  For example '!f() { : git commit ; ... }; f' will
 # tell the completion to use commit completion.  This also works with aliases
 # of form "!sh -c '...'".  For example, "!sh -c ': git commit ; ... '".
-# Be sure to add a space between the command name and the ';'.
+# Note that "git" is optional --- '!f() { : commit; ...}; f' would complete
+# just like the 'git commit' command.
 #
 # If you have a command that is not part of git, but you would still
 # like completion, you can use __git_complete:
@@ -1183,7 +1184,7 @@ __git_aliased_command ()
 			:)	: skip null command ;;
 			\'*)	: skip opening quote after sh -c ;;
 			*)
-				cur="$word"
+				cur="${word%;}"
 				break
 			esac
 		done
Previous: Linus ArverNext: Junio C Hamano
Message 9 of 12 in “completion: improve doc for complex aliases”
  1. completion: improve doc for complex aliasesPhilippe Blain via GitGitGadget, Sep 9, 2023
  2. Eric SunshineSep 10, 2023
  3. Linus ArverSep 12, 2023
  4. Philippe BlainSep 12, 2023
  5. completion: improve doc for complex aliasesPhilippe Blain via GitGitGadget, Sep 12, 2023
  6. Junio C HamanoSep 13, 2023
  7. Linus ArverSep 14, 2023
  8. Linus ArverSep 14, 2023
  9. completion: loosen and document the requirement around completing aliasJunio C Hamano, Sep 20, 2023
  10. Junio C HamanoSep 20, 2023
  11. Linus ArverSep 22, 2023
  12. Junio C HamanoSep 22, 2023

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.