Merge branch 'sg/config-name-only'
authorJunio C Hamano <gitster@pobox.com>
Mon, 31 Aug 2015 22:38:50 +0000 (15:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 31 Aug 2015 22:38:50 +0000 (15:38 -0700)
"git config --list" output was hard to parse when values consist of
multiple lines. "--name-only" option is added to help this.

* sg/config-name-only:
get_urlmatch: avoid useless strbuf write
format_config: simplify buffer handling
format_config: don't init strbuf
config: restructure format_config() for better control flow
completion: list variable names reliably with 'git config --name-only'
config: add '--name-only' option to list only variable names

1  2 
contrib/completion/git-completion.bash
index 3da7dc209d4dc79c078027cc0c17dc5df6911901,0ec56942f60751a75c02c07ca2d8c7b7785e5201..482ca84b451ba7049b702cac7f737ecf4a65fa05
@@@ -744,9 -744,8 +744,8 @@@ __git_compute_porcelain_commands (
  __git_get_config_variables ()
  {
        local section="$1" i IFS=$'\n'
-       for i in $(git --git-dir="$(__gitdir)" config --get-regexp "^$section\..*" 2>/dev/null); do
-               i="${i#$section.}"
-               echo "${i/ */}"
+       for i in $(git --git-dir="$(__gitdir)" config --name-only --get-regexp "^$section\..*" 2>/dev/null); do
+               echo "${i#$section.}"
        done
  }
  
@@@ -1108,7 -1107,7 +1107,7 @@@ _git_commit (
  
        case "$cur" in
        --cleanup=*)
 -              __gitcomp "default strip verbatim whitespace
 +              __gitcomp "default scissors strip verbatim whitespace
                        " "" "${cur##--cleanup=}"
                return
                ;;
@@@ -1667,10 -1666,7 +1666,10 @@@ _git_push (
  _git_rebase ()
  {
        local dir="$(__gitdir)"
 -      if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
 +      if [ -f "$dir"/rebase-merge/interactive ]; then
 +              __gitcomp "--continue --skip --abort --edit-todo"
 +              return
 +      elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
                __gitcomp "--continue --skip --abort"
                return
        fi
@@@ -1777,15 -1773,7 +1776,7 @@@ __git_config_get_set_variables (
                c=$((--c))
        done
  
-       git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
-       while read -r line
-       do
-               case "$line" in
-               *.*=*)
-                       echo "${line/=*/}"
-                       ;;
-               esac
-       done
+       git --git-dir="$(__gitdir)" config $config_file --name-only --list 2>/dev/null
  }
  
  _git_config ()
                        --get --get-all --get-regexp
                        --add --unset --unset-all
                        --remove-section --rename-section
+                       --name-only
                        "
                return
                ;;
                http.postBuffer
                http.proxy
                http.sslCipherList
 +              http.sslVersion
                http.sslCAInfo
                http.sslCAPath
                http.sslCert
@@@ -2286,11 -2274,6 +2278,11 @@@ _git_reset (
  
  _git_revert ()
  {
 +      local dir="$(__gitdir)"
 +      if [ -f "$dir"/REVERT_HEAD ]; then
 +              __gitcomp "--continue --quit --abort"
 +              return
 +      fi
        case "$cur" in
        --*)
                __gitcomp "--edit --mainline --no-edit --no-commit --signoff"