It is possible for the name of an alias to end with the name of another
alias, in which case the code will incorrectly detect a loop.
We can fix that by adding an extra space between words.
Suggested-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
# __git_aliased_command requires 1 argument
__git_aliased_command ()
{
- local cur=$1 list word cmdline
+ local cur=$1 last list word cmdline
while [[ -n "$cur" ]]; do
- if [[ "$list" == *"$cur "* ]]; then
+ if [[ "$list" == *" $cur "* ]]; then
# loop detected
return
fi
cmdline=$(__git config --get "alias.$cur")
- list="$cur $list"
+ list=" $cur $list"
+ last=$cur
cur=
for word in $cmdline; do
done
done
- cur="${list%% *}"
+ cur=$last
if [[ "$cur" != "$1" ]]; then
echo "$cur"
fi