completion: ensure that the repository path given on the command line exists
[gitweb.git] / contrib / completion / git-completion.bash
index 21016bf8dfe87572fb53a05488ba05bb3c08ed97..92801329268232a2ae048b0dea615f67069607e9 100644 (file)
@@ -40,6 +40,7 @@ __gitdir ()
 {
        if [ -z "${1-}" ]; then
                if [ -n "${__git_dir-}" ]; then
+                       test -d "$__git_dir" || return 1
                        echo "$__git_dir"
                elif [ -n "${GIT_DIR-}" ]; then
                        test -d "${GIT_DIR-}" || return 1
@@ -332,9 +333,11 @@ __git_tags ()
        fi
 }
 
-# __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
-# presence of 2nd argument means use the guess heuristic employed
-# by checkout for tracking branches
+# Lists refs from the local (by default) or from a remote repository.
+# It accepts 0, 1 or 2 arguments:
+# 1: The remote to list refs from (optional; ignored, if set but empty).
+# 2: In addition to local refs, list unique branches from refs/remotes/ for
+#    'git checkout's tracking DWIMery (optional; ignored, if set but empty).
 __git_refs ()
 {
        local i hash dir="$(__gitdir "${1-}")" track="${2-}"
@@ -1206,7 +1209,7 @@ _git_describe ()
 
 __git_diff_algorithms="myers minimal patience histogram"
 
-__git_diff_submodule_formats="log short"
+__git_diff_submodule_formats="diff log short"
 
 __git_diff_common_options="--stat --numstat --shortstat --summary
                        --patch-with-stat --name-only --name-status --color
@@ -1552,7 +1555,7 @@ _git_merge ()
        case "$cur" in
        --*)
                __gitcomp "$__git_merge_options
-                       --rerere-autoupdate --no-rerere-autoupdate --abort"
+                       --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
                return
        esac
        __gitcomp_nl "$(__git_refs)"
@@ -1734,10 +1737,10 @@ _git_rebase ()
 {
        local dir="$(__gitdir)"
        if [ -f "$dir"/rebase-merge/interactive ]; then
-               __gitcomp "--continue --skip --abort --edit-todo"
+               __gitcomp "--continue --skip --abort --quit --edit-todo"
                return
        elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
-               __gitcomp "--continue --skip --abort"
+               __gitcomp "--continue --skip --abort --quit"
                return
        fi
        __git_complete_strategy && return