Code

Merge branch 'maint'
[git.git] / contrib / completion / git-completion.bash
index 7a7bc99955e9182be1fcd088932d49681a00dc35..4f64f8ab7d5860391ddbf0909edcfcfe9073a282 100755 (executable)
@@ -271,15 +271,17 @@ __git_merge_strategies ()
                echo "$__git_merge_strategylist"
                return
        fi
-       sed -n "/^all_strategies='/{
-               s/^all_strategies='//
-               s/'//
+       git merge -s help 2>&1 |
+       sed -n -e '/[Aa]vailable strategies are: /,/^$/{
+               s/\.$//
+               s/.*://
+               s/^[    ]*//
+               s/[     ]*$//
                p
-               q
-               }" "$(git --exec-path)/git-merge"
+       }'
 }
 __git_merge_strategylist=
-__git_merge_strategylist="$(__git_merge_strategies 2>/dev/null)"
+__git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
 
 __git_complete_file ()
 {
@@ -501,7 +503,7 @@ __git_has_doubledash ()
        return 1
 }
 
-__git_whitespacelist="nowarn warn error error-all strip"
+__git_whitespacelist="nowarn warn error error-all fix"
 
 _git_am ()
 {
@@ -769,7 +771,7 @@ _git_diff ()
                __gitcomp "--cached --stat --numstat --shortstat --summary
                        --patch-with-stat --name-only --name-status --color
                        --no-color --color-words --no-renames --check
-                       --full-index --binary --abbrev --diff-filter
+                       --full-index --binary --abbrev --diff-filter=
                        --find-copies-harder --pickaxe-all --pickaxe-regex
                        --text --ignore-space-at-eol --ignore-space-change
                        --ignore-all-space --exit-code --quiet --ext-diff
@@ -885,7 +887,11 @@ _git_help ()
                return
                ;;
        esac
-       __gitcomp "$(__git_all_commands)"
+       __gitcomp "$(__git_all_commands)
+               attributes cli core-tutorial cvs-migration
+               diffcore gitk glossary hooks ignore modules
+               repository-layout tutorial tutorial-2
+               "
 }
 
 _git_init ()
@@ -972,6 +978,7 @@ _git_log ()
                        --decorate --diff-filter=
                        --color-words --walk-reflogs
                        --parents --children --full-history
+                       --merge
                        "
                return
                ;;
@@ -1001,11 +1008,42 @@ _git_merge ()
        __gitcomp "$(__git_refs)"
 }
 
+_git_mergetool ()
+{
+       local cur="${COMP_WORDS[COMP_CWORD]}"
+       case "$cur" in
+       --tool=*)
+               __gitcomp "
+                       kdiff3 tkdiff meld xxdiff emerge
+                       vimdiff gvimdiff ecmerge opendiff
+                       " "" "${cur##--tool=}"
+               return
+               ;;
+       --*)
+               __gitcomp "--tool="
+               return
+               ;;
+       esac
+       COMPREPLY=()
+}
+
 _git_merge_base ()
 {
        __gitcomp "$(__git_refs)"
 }
 
+_git_mv ()
+{
+       local cur="${COMP_WORDS[COMP_CWORD]}"
+       case "$cur" in
+       --*)
+               __gitcomp "--dry-run"
+               return
+               ;;
+       esac
+       COMPREPLY=()
+}
+
 _git_name_rev ()
 {
        __gitcomp "--tags --all --stdin"
@@ -1427,7 +1465,7 @@ _git_stash ()
                apply,--*)
                        __gitcomp "--index"
                        ;;
-               show,--*|apply,--*|drop,--*|pop,--*|branch,--*)
+               show,--*|drop,--*|pop,--*|branch,--*)
                        COMPREPLY=()
                        ;;
                show,*|apply,*|drop,*|pop,*|branch,*)
@@ -1445,7 +1483,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
@@ -1638,7 +1676,9 @@ _git ()
        ls-remote)   _git_ls_remote ;;
        ls-tree)     _git_ls_tree ;;
        merge)       _git_merge;;
+       mergetool)   _git_mergetool;;
        merge-base)  _git_merge_base ;;
+       mv)          _git_mv ;;
        name-rev)    _git_name_rev ;;
        pull)        _git_pull ;;
        push)        _git_push ;;