Skip to content

Commit 518ef8f

Browse files
tmzullingergitster
authored andcommitted
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 <[email protected]> Trivially-acked-by: Shawn O. Pearce <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 05d3951 commit 518ef8f

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

contrib/completion/git-completion.bash

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,9 @@ __git_remotes ()
318318
echo ${i#$d/remotes/}
319319
done
320320
[ "$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*/}"
328324
done
329325
}
330326

@@ -605,13 +601,9 @@ __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
605601
__git_aliases ()
606602
{
607603
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/ */}"
615607
done
616608
}
617609

@@ -1769,13 +1761,9 @@ _git_remote ()
17691761
;;
17701762
update)
17711763
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/ */}"
17791767
done
17801768
__gitcomp "$c"
17811769
;;

0 commit comments

Comments
 (0)