Skip to content

Commit

Permalink
completion: __git_config_get_set_variables() handle values with spaces
Browse files Browse the repository at this point in the history
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 <gitster@pobox.com>

 $ git config --unset <TAB>
   format.cc
   <gitster@pobox.com>

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 <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
bebarino authored and gitster committed Jul 6, 2009
1 parent dd787c1 commit f581de1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -1357,11 +1357,12 @@ __git_config_get_set_variables ()
c=$((--c))
done

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/=*/}"
;;
esac
done
Expand Down

0 comments on commit f581de1

Please sign in to comment.