diff options
author | Felipe Contreras <felipe.contreras@gmail.com> | 2020-11-09 20:03:43 -0600 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-11-09 18:09:21 -0800 |
commit | c2822a842dc993722a9d6f8226189312b95d8801 (patch) | |
tree | 7a2e0b04c18f2e10de09ebd680c841ecef6b7306 /contrib | |
parent | completion: bash: support recursive aliases (diff) | |
download | tgif-c2822a842dc993722a9d6f8226189312b95d8801.tar.xz |
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>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/completion/git-completion.bash | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 97eccffa4a..8fcf464bc3 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -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 |