Merge branch 'tr/test-commit-only-on-orphan'
[gitweb.git] / contrib / completion / git-completion.bash
index f9e8e7dae52068f82edeced360198279c09a86a6..91234d47ad7f6e3ee0f45d53f67426eeba6bfaf2 100644 (file)
@@ -255,27 +255,10 @@ __gitcomp_file ()
        __gitcompadd "$1" "${2-}" "${3-$cur}" ""
 
        # use a hack to enable file mode in bash < 4
-       compopt -o filenames 2>/dev/null ||
+       compopt -o filenames +o nospace 2>/dev/null ||
        compgen -f /non-existing-dir/ > /dev/null
 }
 
-# Process path list returned by "ls-files" and "diff-index --name-only"
-# commands, in order to list only file names relative to a specified
-# directory, and append a slash to directory names.
-__git_index_file_list_filter ()
-{
-       local path
-
-       while read -r path; do
-               case "$path" in
-               ?*/*)
-                       echo "${path%%/*}" ;;
-               *)
-                       echo "$path" ;;
-               esac
-       done
-}
-
 # Execute 'git ls-files', unless the --committable option is specified, in
 # which case it runs 'git diff-index' to find out the files that can be
 # committed.  It return paths relative to the directory specified in the first
@@ -303,11 +286,16 @@ __git_ls_files_helper ()
 #    slash.
 __git_index_files ()
 {
-       local dir="$(__gitdir)" root="${2-.}"
+       local dir="$(__gitdir)" root="${2-.}" file
 
        if [ -d "$dir" ]; then
-               __git_ls_files_helper "$root" "$1" | __git_index_file_list_filter |
-                       sort | uniq
+               __git_ls_files_helper "$root" "$1" |
+               while read -r file; do
+                       case "$file" in
+                       ?*/*) echo "${file%%/*}" ;;
+                       *) echo "$file" ;;
+                       esac
+               done | sort | uniq
        fi
 }
 
@@ -1249,11 +1237,12 @@ _git_fetch ()
 }
 
 __git_format_patch_options="
-       --stdout --attach --no-attach --thread --thread= --output-directory
+       --stdout --attach --no-attach --thread --thread= --no-thread
        --numbered --start-number --numbered-files --keep-subject --signoff
        --signature --no-signature --in-reply-to= --cc= --full-index --binary
        --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
        --inline --suffix= --ignore-if-in-upstream --subject-prefix=
+       --output-directory --reroll-count --to= --quiet --notes
 "
 
 _git_format_patch ()
@@ -1745,7 +1734,7 @@ __git_config_get_set_variables ()
 _git_config ()
 {
        case "$prev" in
-       branch.*.remote)
+       branch.*.remote|branch.*.pushremote)
                __gitcomp_nl "$(__git_remotes)"
                return
                ;;
@@ -1753,11 +1742,19 @@ _git_config ()
                __gitcomp_nl "$(__git_refs)"
                return
                ;;
+       branch.*.rebase)
+               __gitcomp "false true"
+               return
+               ;;
+       remote.pushdefault)
+               __gitcomp_nl "$(__git_remotes)"
+               return
+               ;;
        remote.*.fetch)
                local remote="${prev#remote.}"
                remote="${remote%.fetch}"
                if [ -z "$cur" ]; then
-                       __gitcompadd "refs/heads/" "" "" ""
+                       __gitcomp_nl "refs/heads/" "" "" ""
                        return
                fi
                __gitcomp_nl "$(__git_refs_remotes "$remote")"
@@ -1792,6 +1789,10 @@ _git_config ()
                        "
                return
                ;;
+       diff.submodule)
+               __gitcomp "log short"
+               return
+               ;;
        help.format)
                __gitcomp "man info web html"
                return
@@ -1833,7 +1834,7 @@ _git_config ()
                ;;
        branch.*.*)
                local pfx="${cur%.*}." cur_="${cur##*.}"
-               __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_"
+               __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"
                return
                ;;
        branch.*)
@@ -1986,13 +1987,14 @@ _git_config ()
                core.whitespace
                core.worktree
                diff.autorefreshindex
-               diff.statGraphWidth
                diff.external
                diff.ignoreSubmodules
                diff.mnemonicprefix
                diff.noprefix
                diff.renameLimit
                diff.renames
+               diff.statGraphWidth
+               diff.submodule
                diff.suppressBlankEmpty
                diff.tool
                diff.wordRegex
@@ -2127,6 +2129,7 @@ _git_config ()
                receive.fsckObjects
                receive.unpackLimit
                receive.updateserverinfo
+               remote.pushdefault
                remotes.
                repack.usedeltabaseoffset
                rerere.autoupdate
@@ -2371,7 +2374,7 @@ _git_svn ()
                        --no-metadata --use-svm-props --use-svnsync-props
                        --log-window-size= --no-checkout --quiet
                        --repack-flags --use-log-author --localtime
-                       --ignore-paths= $remote_opts
+                       --ignore-paths= --include-paths= $remote_opts
                        "
                local init_opts="
                        --template= --shared= --trunk= --tags=
@@ -2583,7 +2586,7 @@ if [[ -n ${ZSH_VERSION-} ]]; then
                                --*=*|*.) ;;
                                *) c="$c " ;;
                                esac
-                               array[$#array+1]="$c"
+                               array+=("$c")
                        done
                        compset -P '*[=:]'
                        compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
@@ -2609,22 +2612,14 @@ if [[ -n ${ZSH_VERSION-} ]]; then
                compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
        }
 
-       __git_zsh_helper ()
-       {
-               emulate -L ksh
-               local cur cword prev
-               cur=${words[CURRENT-1]}
-               prev=${words[CURRENT-2]}
-               let cword=CURRENT-1
-               __${service}_main
-       }
-
        _git ()
        {
-               emulate -L zsh
-               local _ret=1
-               __git_zsh_helper
-               let _ret && _default -S '' && _ret=0
+               local _ret=1 cur cword prev
+               cur=${words[CURRENT]}
+               prev=${words[CURRENT-1]}
+               let cword=CURRENT-1
+               emulate ksh -c __${service}_main
+               let _ret && _default && _ret=0
                return _ret
        }