1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-10 02:56:17 +02:00

completion: bash: check for alias loop

We don't want to be stuck in an endless cycle.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Felipe Contreras 2020-11-09 20:03:43 -06:00 committed by Junio C Hamano
parent 9414938c34
commit c2822a842d

View File

@ -1120,11 +1120,16 @@ __git_pretty_aliases ()
# __git_aliased_command requires 1 argument
__git_aliased_command ()
{
local cur=$1 last word cmdline
local cur=$1 list word cmdline
while [[ -n "$cur" ]]; do
if [[ "$list" == *"$cur "* ]]; then
# loop detected
return
fi
cmdline=$(__git config --get "alias.$cur")
last=$cur
list="$cur $list"
cur=
for word in $cmdline; do
@ -1148,7 +1153,7 @@ __git_aliased_command ()
done
done
cur=$last
cur="${list%% *}"
if [[ "$cur" != "$1" ]]; then
echo "$cur"
fi