Skip to content

Commit

Permalink
completion: Replace config --list with --get-regexp
Browse files Browse the repository at this point in the history
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 <[email protected]>
Trivially-acked-by: Shawn O. Pearce <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
tmzullinger authored and gitster committed Sep 13, 2009
1 parent 05d3951 commit 518ef8f
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,9 @@ __git_remotes ()
echo ${i#$d/remotes/}
done
[ "$ngoff" ] && shopt -u nullglob
for i in $(git --git-dir="$d" config --list); do
case "$i" in
remote.*.url=*)
i="${i#remote.}"
echo "${i/.url=*/}"
;;
esac
for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
i="${i#remote.}"
echo "${i/.url*/}"
done
}

Expand Down Expand Up @@ -605,13 +601,9 @@ __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
__git_aliases ()
{
local i IFS=$'\n'
for i in $(git --git-dir="$(__gitdir)" config --list); do
case "$i" in
alias.*)
i="${i#alias.}"
echo "${i/=*/}"
;;
esac
for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
i="${i#alias.}"
echo "${i/ */}"
done
}

Expand Down Expand Up @@ -1769,13 +1761,9 @@ _git_remote ()
;;
update)
local i c='' IFS=$'\n'
for i in $(git --git-dir="$(__gitdir)" config --list); do
case "$i" in
remotes.*)
i="${i#remotes.}"
c="$c ${i/=*/}"
;;
esac
for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
i="${i#remotes.}"
c="$c ${i/ */}"
done
__gitcomp "$c"
;;
Expand Down

0 comments on commit 518ef8f

Please sign in to comment.