]> Pileus Git - ~andy/git/blobdiff - contrib/completion/git-completion.bash
Merge branch 'maint'
[~andy/git] / contrib / completion / git-completion.bash
index 554a03ff4fbc61e8b02b6010c9ffb9fad632f195..c79c98ffec58f81b7592ba3fc359fc0d1c8d1d22 100755 (executable)
@@ -154,11 +154,8 @@ __git_heads ()
 {
        local cmd i is_hash=y dir="$(__gitdir "$1")"
        if [ -d "$dir" ]; then
-               for i in $(git --git-dir="$dir" \
-                       for-each-ref --format='%(refname)' \
-                       refs/heads ); do
-                       echo "${i#refs/heads/}"
-               done
+               git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
+                       refs/heads
                return
        fi
        for i in $(git ls-remote "$1" 2>/dev/null); do
@@ -175,11 +172,8 @@ __git_tags ()
 {
        local cmd i is_hash=y dir="$(__gitdir "$1")"
        if [ -d "$dir" ]; then
-               for i in $(git --git-dir="$dir" \
-                       for-each-ref --format='%(refname)' \
-                       refs/tags ); do
-                       echo "${i#refs/tags/}"
-               done
+               git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
+                       refs/tags
                return
        fi
        for i in $(git ls-remote "$1" 2>/dev/null); do
@@ -194,19 +188,22 @@ __git_tags ()
 
 __git_refs ()
 {
-       local cmd i is_hash=y dir="$(__gitdir "$1")"
+       local i is_hash=y dir="$(__gitdir "$1")"
+       local cur="${COMP_WORDS[COMP_CWORD]}" format refs
        if [ -d "$dir" ]; then
-               if [ -e "$dir/HEAD" ]; then echo HEAD; fi
-               for i in $(git --git-dir="$dir" \
-                       for-each-ref --format='%(refname)' \
-                       refs/tags refs/heads refs/remotes); do
-                       case "$i" in
-                               refs/tags/*)    echo "${i#refs/tags/}" ;;
-                               refs/heads/*)   echo "${i#refs/heads/}" ;;
-                               refs/remotes/*) echo "${i#refs/remotes/}" ;;
-                               *)              echo "$i" ;;
-                       esac
-               done
+               case "$cur" in
+               refs|refs/*)
+                       format="refname"
+                       refs="${cur%/*}"
+                       ;;
+               *)
+                       if [ -e "$dir/HEAD" ]; then echo HEAD; fi
+                       format="refname:short"
+                       refs="refs/tags refs/heads refs/remotes"
+                       ;;
+               esac
+               git --git-dir="$dir" for-each-ref --format="%($format)" \
+                       $refs
                return
        fi
        for i in $(git ls-remote "$dir" 2>/dev/null); do
@@ -881,6 +878,7 @@ _git_help ()
                attributes cli core-tutorial cvs-migration
                diffcore gitk glossary hooks ignore modules
                repository-layout tutorial tutorial-2
+               workflows
                "
 }
 
@@ -1112,7 +1110,8 @@ _git_send_email ()
                        --no-suppress-from --no-thread --quiet
                        --signed-off-by-cc --smtp-pass --smtp-server
                        --smtp-server-port --smtp-ssl --smtp-user --subject
-                       --suppress-cc --suppress-from --thread --to"
+                       --suppress-cc --suppress-from --thread --to
+                       --validate --no-validate"
                return
                ;;
        esac
@@ -1452,7 +1451,7 @@ _git_submodule ()
 {
        __git_has_doubledash && return
 
-       local subcommands="add status init update"
+       local subcommands="add status init update summary foreach sync"
        if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
                local cur="${COMP_WORDS[COMP_CWORD]}"
                case "$cur" in