Stephen Boyd  committed f581de1

completion: __git_config_get_set_variables() handle values with spaces

Commit 0065236 (bash completion: complete variable names for "git
config" with options 2009-05-08) implemented its config variable search
wrong. When a config contains a value with a space and a period (.) in
it, completion erroneously thinks that line in the configuration is
multiple config variables.

For example

$ cat .git/config = Junio C Hamano <>

$ git config --unset <TAB>

Instead of using a for loop splitting across spaces, pipe each line to a
while read loop and beef up the case statement to match only

Signed-off-by: Stephen Boyd <>
Signed-off-by: Junio C Hamano <>

  • Participants
  • Parent commits dd787c1

Comments (0)

Files changed (1)

File contrib/completion/git-completion.bash

-	for i in $(git --git-dir="$(__gitdir)" config $config_file --list \
-			2>/dev/null); do
-		case "$i" in
-		*.*)
-			echo "${i/=*/}"
+	git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
+	while read line
+	do
+		case "$line" in
+		*.*=*)
+			echo "${line/=*/}"