Merge branch 'bb/update-unicode-table'
[gitweb.git] / contrib / completion / git-completion.bash
index 2ed230a861248f510e8e9d4597faef6f14ffd552..cd765795ae42edfdf21a054619b64d5c3800f4f6 100644 (file)
@@ -16,9 +16,9 @@
 #
 # To use these routines:
 #
-#    1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
+#    1) Copy this file to somewhere (e.g. ~/.git-completion.bash).
 #    2) Add the following line to your .bashrc/.zshrc:
-#        source ~/.git-completion.sh
+#        source ~/.git-completion.bash
 #    3) Consider changing your PS1 to also show the current branch,
 #       see git-prompt.sh for details.
 #
@@ -281,16 +281,12 @@ __gitcomp_file ()
 # argument, and using the options specified in the second argument.
 __git_ls_files_helper ()
 {
-       (
-               test -n "${CDPATH+set}" && unset CDPATH
-               cd "$1"
-               if [ "$2" == "--committable" ]; then
-                       git diff-index --name-only --relative HEAD
-               else
-                       # NOTE: $2 is not quoted in order to support multiple options
-                       git ls-files --exclude-standard $2
-               fi
-       ) 2>/dev/null
+       if [ "$2" == "--committable" ]; then
+               git -C "$1" diff-index --name-only --relative HEAD
+       else
+               # NOTE: $2 is not quoted in order to support multiple options
+               git -C "$1" ls-files --exclude-standard $2
+       fi 2>/dev/null
 }
 
 
@@ -388,7 +384,8 @@ __git_refs ()
                ;;
        *)
                echo "HEAD"
-               git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##"
+               git for-each-ref --format="%(refname:short)" -- \
+                       "refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##"
                ;;
        esac
 }
@@ -522,7 +519,7 @@ __git_complete_index_file ()
                ;;
        esac
 
-       __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
+       __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
 }
 
 __git_complete_file ()
@@ -1207,7 +1204,7 @@ _git_diff ()
 }
 
 __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
-                       tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare
+                       tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
 "
 
 _git_difftool ()
@@ -1878,6 +1875,10 @@ _git_config ()
                __gitcomp "$__git_send_email_suppresscc_options"
                return
                ;;
+       sendemail.transferencoding)
+               __gitcomp "7bit 8bit quoted-printable base64"
+               return
+               ;;
        --get|--get-all|--unset|--unset-all)
                __gitcomp_nl "$(__git_config_get_set_variables)"
                return
@@ -2551,6 +2552,16 @@ _git_tag ()
                __gitcomp_nl "$(__git_refs)"
                ;;
        esac
+
+       case "$cur" in
+       --*)
+               __gitcomp "
+                       --list --delete --verify --annotate --message --file
+                       --sign --cleanup --local-user --force --column --sort
+                       --contains --points-at
+                       "
+               ;;
+       esac
 }
 
 _git_whatchanged ()