Do not name "repo" struct "remote" in push_http.c
[gitweb.git] / contrib / completion / git-completion.bash
index e8c4be2e818ca30a87e7c11f10442c4c7862346f..271b911f7a1300057c0b100c1bdfe5d68a0e3248 100755 (executable)
@@ -391,10 +391,11 @@ __git_complete_remote_or_refspec ()
 {
        local cmd="${COMP_WORDS[1]}"
        local cur="${COMP_WORDS[COMP_CWORD]}"
-       local i c=2 remote="" pfx="" lhs=1
+       local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
        while [ $c -lt $COMP_CWORD ]; do
                i="${COMP_WORDS[c]}"
                case "$i" in
+               --all|--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
                -*) ;;
                *) remote="$i"; break ;;
                esac
@@ -404,6 +405,10 @@ __git_complete_remote_or_refspec ()
                __gitcomp "$(__git_remotes)"
                return
        fi
+       if [ $no_complete_refspec = 1 ]; then
+               COMPREPLY=()
+               return
+       fi
        [ "$remote" = "." ] && remote=
        case "$cur" in
        *:*)
@@ -444,6 +449,23 @@ __git_complete_remote_or_refspec ()
        esac
 }
 
+__git_complete_strategy ()
+{
+       case "${COMP_WORDS[COMP_CWORD-1]}" in
+       -s|--strategy)
+               __gitcomp "$(__git_merge_strategies)"
+               return 0
+       esac
+       local cur="${COMP_WORDS[COMP_CWORD]}"
+       case "$cur" in
+       --strategy=*)
+               __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
+               return 0
+               ;;
+       esac
+       return 1
+}
+
 __git_all_commands ()
 {
        if [ -n "${__git_all_commandlist-}" ]; then
@@ -887,8 +909,20 @@ _git_diff ()
        __git_complete_file
 }
 
+__git_fetch_options="
+       --quiet --verbose --append --upload-pack --force --keep --depth=
+       --tags --no-tags
+"
+
 _git_fetch ()
 {
+       local cur="${COMP_WORDS[COMP_CWORD]}"
+       case "$cur" in
+       --*)
+               __gitcomp "$__git_fetch_options"
+               return
+               ;;
+       esac
        __git_complete_remote_or_refspec
 }
 
@@ -1093,24 +1127,19 @@ _git_log ()
        __git_complete_revlist
 }
 
+__git_merge_options="
+       --no-commit --no-stat --log --no-log --squash --strategy
+       --commit --stat --no-squash --ff --no-ff
+"
+
 _git_merge ()
 {
+       __git_complete_strategy && return
+
        local cur="${COMP_WORDS[COMP_CWORD]}"
-       case "${COMP_WORDS[COMP_CWORD-1]}" in
-       -s|--strategy)
-               __gitcomp "$(__git_merge_strategies)"
-               return
-       esac
        case "$cur" in
-       --strategy=*)
-               __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
-               return
-               ;;
        --*)
-               __gitcomp "
-                       --no-commit --no-stat --log --no-log --squash --strategy
-                       --commit --stat --no-squash --ff --no-ff
-                       "
+               __gitcomp "$__git_merge_options"
                return
        esac
        __gitcomp "$(__git_refs)"
@@ -1159,11 +1188,43 @@ _git_name_rev ()
 
 _git_pull ()
 {
+       __git_complete_strategy && return
+
+       local cur="${COMP_WORDS[COMP_CWORD]}"
+       case "$cur" in
+       --*)
+               __gitcomp "
+                       --rebase --no-rebase
+                       $__git_merge_options
+                       $__git_fetch_options
+               "
+               return
+               ;;
+       esac
        __git_complete_remote_or_refspec
 }
 
 _git_push ()
 {
+       local cur="${COMP_WORDS[COMP_CWORD]}"
+       case "${COMP_WORDS[COMP_CWORD-1]}" in
+       --repo)
+               __gitcomp "$(__git_remotes)"
+               return
+       esac
+       case "$cur" in
+       --repo=*)
+               __gitcomp "$(__git_remotes)" "" "${cur##--repo=}"
+               return
+               ;;
+       --*)
+               __gitcomp "
+                       --all --mirror --tags --dry-run --force --verbose
+                       --receive-pack= --repo=
+               "
+               return
+               ;;
+       esac
        __git_complete_remote_or_refspec
 }
 
@@ -1174,16 +1235,8 @@ _git_rebase ()
                __gitcomp "--continue --skip --abort"
                return
        fi
-       case "${COMP_WORDS[COMP_CWORD-1]}" in
-       -s|--strategy)
-               __gitcomp "$(__git_merge_strategies)"
-               return
-       esac
+       __git_complete_strategy && return
        case "$cur" in
-       --strategy=*)
-               __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
-               return
-               ;;
        --*)
                __gitcomp "--onto --merge --strategy --interactive"
                return