]> git.ipfire.org Git - thirdparty/git.git/blobdiff - contrib/completion/git-completion.bash
Merge branch 'ma/doc-pack-format-varint-for-sizes' into maint
[thirdparty/git.git] / contrib / completion / git-completion.bash
index 7c81e4ba497fb6ab1b9b32a40336f5995b0b5b55..463a3124da0a98715e074bf057dac1b67f79b3be 100644 (file)
@@ -1120,26 +1120,44 @@ __git_pretty_aliases ()
 # __git_aliased_command requires 1 argument
 __git_aliased_command ()
 {
-       local word cmdline=$(__git config --get "alias.$1")
-       for word in $cmdline; do
-               case "$word" in
-               \!gitk|gitk)
-                       echo "gitk"
-                       return
-                       ;;
-               \!*)    : shell command alias ;;
-               -*)     : option ;;
-               *=*)    : setting env ;;
-               git)    : git itself ;;
-               \(\))   : skip parens of shell function definition ;;
-               {)      : skip start of shell helper function ;;
-               :)      : skip null command ;;
-               \'*)    : skip opening quote after sh -c ;;
-               *)
-                       echo "$word"
+       local cur=$1 last list word cmdline
+
+       while [[ -n "$cur" ]]; do
+               if [[ "$list" == *" $cur "* ]]; then
+                       # loop detected
                        return
-               esac
+               fi
+
+               cmdline=$(__git config --get "alias.$cur")
+               list=" $cur $list"
+               last=$cur
+               cur=
+
+               for word in $cmdline; do
+                       case "$word" in
+                       \!gitk|gitk)
+                               cur="gitk"
+                               break
+                               ;;
+                       \!*)    : shell command alias ;;
+                       -*)     : option ;;
+                       *=*)    : setting env ;;
+                       git)    : git itself ;;
+                       \(\))   : skip parens of shell function definition ;;
+                       {)      : skip start of shell helper function ;;
+                       :)      : skip null command ;;
+                       \'*)    : skip opening quote after sh -c ;;
+                       *)
+                               cur="$word"
+                               break
+                       esac
+               done
        done
+
+       cur=$last
+       if [[ "$cur" != "$1" ]]; then
+               echo "$cur"
+       fi
 }
 
 # Check whether one of the given words is present on the command line,
@@ -1811,7 +1829,7 @@ _git_fsck ()
 
 _git_gitk ()
 {
-       _gitk
+       __gitk_main
 }
 
 # Lists matching symbol names from a tag (as in ctags) file.