Skip to content

Commit f581de1

Browse files
bebarinogitster
authored andcommitted
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 format.cc = Junio C Hamano <[email protected]> $ git config --unset <TAB> format.cc <[email protected]> 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 'config.variable=value'. Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dd787c1 commit f581de1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

contrib/completion/git-completion.bash

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,11 +1357,12 @@ __git_config_get_set_variables ()
13571357
c=$((--c))
13581358
done
13591359

1360-
for i in $(git --git-dir="$(__gitdir)" config $config_file --list \
1361-
2>/dev/null); do
1362-
case "$i" in
1363-
*.*)
1364-
echo "${i/=*/}"
1360+
git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
1361+
while read line
1362+
do
1363+
case "$line" in
1364+
*.*=*)
1365+
echo "${line/=*/}"
13651366
;;
13661367
esac
13671368
done

0 commit comments

Comments
 (0)