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

[PATCH 1/3] completion: fix alias listings with newlines

From
Stephen Boyd <bebarino@gmail.com>
Date
Oct 7, 2009, 08:48 UTC
Message-ID
<1254905331-29516-1-git-send-email-bebarino@gmail.com>

Since commit 518ef8f (completion: Replace config --list with --get-regexp, 2009-09-11) an alias config value containing a newline would break the completion of aliases. Instead of setting the IFS to the newline, use git-config's null termination to separate aliases with the null character.

An example .gitconfig causing the breakage.
[alias]
	whowhat = "log -1 --pretty='format:%an <%ae>\n%s'"
	wont-complete = ...
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

This is the best I can come up with. I'm not sure about using the d option of read though.

 contrib/completion/git-completion.bash |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 2c2a0d4..332be99 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -600,10 +600,10 @@ __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
 
 __git_aliases ()
 {
-	local i IFS=$'\n'
-	for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
-		i="${i#alias.}"
-		echo "${i/ */}"
+	local i
+	git --git-dir="$(__gitdir)" config -z --get-regexp "alias\..*" 2>/dev/null |
+	while IFS= read -rd '' i; do
+		echo ${i#alias.} | cut -d' ' -f1
 	done
 }
 
-- 
1.6.5.rc2.17.gdbc1b
Next: Stephen Boyd
Message 1 of 15 in “completion: fix alias listings with newlines”
  1. 1/3 completion: fix alias listings with newlinesStephen Boyd, Oct 7, 2009
  2. 2/3 completion: update am, commit, and logStephen Boyd, Oct 7, 2009
  3. 3/3 completion: add dirstat and friends to diff optionsStephen Boyd, Oct 7, 2009
  4. Junio C HamanoOct 7, 2009
  5. Junio C HamanoOct 7, 2009
  6. Johannes SixtOct 7, 2009
  7. Stephen BoydOct 7, 2009
  8. Shawn O. PearceOct 8, 2009
  9. Stephen BoydOct 8, 2009
  10. Johannes SixtOct 8, 2009
  11. Stephen BoydOct 8, 2009
  12. Johannes SixtOct 8, 2009
  13. Junio C HamanoOct 7, 2009
  14. Shawn O. PearceOct 8, 2009
  15. Stephen BoydOct 8, 2009

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.