@matheusbsbs / matheus-bagliano / commits / 518ef8f07f
Fork 0

completion: Replace config --list with --get-regexp

James Bardin noted that the completion spewed warnings when no git config file is present. This is likely a bug to be fixed in git config, but it's also good to simplify the completion code by using the --get-regexp option as Jeff King pointed out. Signed-off-by: Todd Zullinger <tmz@pobox.com> Trivially-acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Todd Zullinger committed Sep 11, 2009 at 19:23 UTC 518ef8f07f72271dff4040c1e7452ab6de73d199
1 file changed +9 -21
contrib/completion/git-completion.bash
+9 -21
@@ -318,13 +318,9 @@ __git_remotes ()
318 echo ${i#$d/remotes/}
319 done
320 [ "$ngoff" ] && shopt -u nullglob
321 - for i in $(git --git-dir="$d" config --list); do
322 - case "$i" in
323 - remote.*.url=*)
324 - i="${i#remote.}"
325 - echo "${i/.url=*/}"
326 - ;;
327 - esac
321 + for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
322 + i="${i#remote.}"
323 + echo "${i/.url*/}"
324 done
325 }
326
@@ -605,13 +601,9 @@ __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
601 __git_aliases ()
602 {
603 local i IFS=$'\n'
608 - for i in $(git --git-dir="$(__gitdir)" config --list); do
609 - case "$i" in
610 - alias.*)
611 - i="${i#alias.}"
612 - echo "${i/=*/}"
613 - ;;
614 - esac
604 + for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
605 + i="${i#alias.}"
606 + echo "${i/ */}"
607 done
608 }
609
@@ -1769,13 +1761,9 @@ _git_remote ()
1761 ;;
1762 update)
1763 local i c='' IFS=$'\n'
1772 - for i in $(git --git-dir="$(__gitdir)" config --list); do
1773 - case "$i" in
1774 - remotes.*)
1775 - i="${i#remotes.}"
1776 - c="$c ${i/=*/}"
1777 - ;;
1778 - esac
1764 + for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
1765 + i="${i#remotes.}"
1766 + c="$c ${i/ */}"
1767 done
1768 __gitcomp "$c"
1769 ;;