From: Junio C Hamano Date: Mon, 29 Apr 2013 16:57:38 +0000 (-0700) Subject: Merge branch 'maint' X-Git-Tag: v1.8.3-rc1~11 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/01449e314f383861f053786129120abdbeac3198?ds=inline;hp=-c Merge branch 'maint' * maint: complete: zsh: use zsh completion for the main cmd complete: zsh: trivial simplification git-completion.bash: complete branch.*.rebase as boolean git-completion.bash: add diff.submodule to config list git-completion.bash: lexical sorting for diff.statGraphWidth --- 01449e314f383861f053786129120abdbeac3198 diff --combined contrib/completion/git-completion.bash index 3b20108cba,e769800393..5dc54a340f --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@@ -53,6 -53,19 +53,6 @@@ __gitdir ( fi } -__gitcomp_1 () -{ - local c IFS=$' \t\n' - for c in $1; do - c="$c$2" - case $c in - --*=*|*.) ;; - *) c="$c " ;; - esac - printf '%s\n' "$c" - done -} - # The following function is based on code from: # # bash_completion - programmable completion functions for bash 3.2+ @@@ -182,18 -195,8 +182,18 @@@ _get_comp_words_by_ref ( } fi -# Generates completion reply with compgen, appending a space to possible -# completion words, if necessary. +__gitcompadd () +{ + local i=0 + for x in $1; do + if [[ "$x" == "$3"* ]]; then + COMPREPLY[i++]="$2$x$4" + fi + done +} + +# Generates completion reply, appending a space to possible completion words, +# if necessary. # It accepts 1 to 4 arguments: # 1: List of possible completion words. # 2: A prefix to be added to each possible completion word (optional). @@@ -205,25 -208,19 +205,25 @@@ __gitcomp ( case "$cur_" in --*=) - COMPREPLY=() ;; *) - local IFS=$'\n' - COMPREPLY=($(compgen -P "${2-}" \ - -W "$(__gitcomp_1 "${1-}" "${4-}")" \ - -- "$cur_")) + local c i=0 IFS=$' \t\n' + for c in $1; do + c="$c${4-}" + if [[ $c == "$cur_"* ]]; then + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + COMPREPLY[i++]="${2-}$c" + fi + done ;; esac } -# Generates completion reply with compgen from newline-separated possible -# completion words by appending a space to all of them. +# Generates completion reply from newline-separated possible completion words +# by appending a space to all of them. # It accepts 1 to 4 arguments: # 1: List of possible completion words, separated by a single newline. # 2: A prefix to be added to each possible completion word (optional). @@@ -234,7 -231,7 +234,7 @@@ __gitcomp_nl () { local IFS=$'\n' - COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}")) + __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }" } # Generates completion reply with compgen from newline-separated possible @@@ -617,6 -614,7 +617,6 @@@ __git_complete_remote_or_refspec ( case "$cmd" in push) no_complete_refspec=1 ;; fetch) - COMPREPLY=() return ;; *) ;; @@@ -632,6 -630,7 +632,6 @@@ return fi if [ $no_complete_refspec = 1 ]; then - COMPREPLY=() return fi [ "$remote" = "." ] && remote= @@@ -952,6 -951,7 +952,6 @@@ _git_am ( " return esac - COMPREPLY=() } _git_apply () @@@ -971,6 -971,7 +971,6 @@@ " return esac - COMPREPLY=() } _git_add () @@@ -1030,6 -1031,7 +1030,6 @@@ _git_bisect ( __gitcomp_nl "$(__git_refs)" ;; *) - COMPREPLY=() ;; esac } @@@ -1122,14 -1124,9 +1122,14 @@@ _git_cherry ( _git_cherry_pick () { + local dir="$(__gitdir)" + if [ -f "$dir"/CHERRY_PICK_HEAD ]; then + __gitcomp "--continue --quit --abort" + return + fi case "$cur" in --*) - __gitcomp "--edit --no-commit" + __gitcomp "--edit --no-commit --signoff --strategy= --mainline" ;; *) __gitcomp_nl "$(__git_refs)" @@@ -1173,6 -1170,7 +1173,6 @@@ _git_clone ( return ;; esac - COMPREPLY=() } _git_commit () @@@ -1314,12 -1312,11 +1314,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 () @@@ -1350,6 -1347,7 +1350,6 @@@ _git_fsck ( return ;; esac - COMPREPLY=() } _git_gc () @@@ -1360,6 -1358,7 +1360,6 @@@ return ;; esac - COMPREPLY=() } _git_gitk () @@@ -1436,6 -1435,7 +1436,6 @@@ _git_init ( return ;; esac - COMPREPLY=() } _git_ls_files () @@@ -1571,6 -1571,7 +1571,6 @@@ _git_mergetool ( return ;; esac - COMPREPLY=() } _git_merge_base () @@@ -1819,11 -1820,15 +1819,15 @@@ _git_config ( __gitcomp_nl "$(__git_refs)" return ;; + branch.*.rebase) + __gitcomp "false true" + return + ;; remote.*.fetch) local remote="${prev#remote.}" remote="${remote%.fetch}" if [ -z "$cur" ]; then - COMPREPLY=("refs/heads/") + __gitcompadd "refs/heads/" "" "" "" return fi __gitcomp_nl "$(__git_refs_remotes "$remote")" @@@ -1858,6 -1863,10 +1862,10 @@@ " return ;; + diff.submodule) + __gitcomp "log short" + return + ;; help.format) __gitcomp "man info web html" return @@@ -1883,6 -1892,7 +1891,6 @@@ return ;; *.*) - COMPREPLY=() return ;; esac @@@ -2052,13 -2062,14 +2060,14 @@@ 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 @@@ -2263,6 -2274,7 +2272,6 @@@ _git_remote ( __gitcomp "$c" ;; *) - COMPREPLY=() ;; esac } @@@ -2378,6 -2390,8 +2387,6 @@@ _git_stash ( *) if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then __gitcomp "$subcommands" - else - COMPREPLY=() fi ;; esac @@@ -2390,12 -2404,14 +2399,12 @@@ __gitcomp "--index --quiet" ;; show,--*|drop,--*|branch,--*) - COMPREPLY=() ;; show,*|apply,*|drop,*|pop,*|branch,*) __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ | sed -n -e 's/:.*//p')" ;; *) - COMPREPLY=() ;; esac fi @@@ -2405,7 -2421,7 +2414,7 @@@ _git_submodule ( { __git_has_doubledash && return - local subcommands="add status init update summary foreach sync" + local subcommands="add status init deinit update summary foreach sync" if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then case "$cur" in --*) @@@ -2512,6 -2528,7 +2521,6 @@@ _git_svn ( __gitcomp "--revision= --parent" ;; *) - COMPREPLY=() ;; esac fi @@@ -2536,10 -2553,13 +2545,10 @@@ _git_tag ( case "$prev" in -m|-F) - COMPREPLY=() ;; -*|tag) if [ $f = 1 ]; then __gitcomp_nl "$(__git_tags)" - else - COMPREPLY=() fi ;; *)