From: Junio C Hamano Date: Wed, 30 Jul 2014 21:21:13 +0000 (-0700) Subject: Merge branch 'jk/more-push-completion' X-Git-Tag: v2.1.0-rc1~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0d9cb2d14e4f26c122ab2532b4ceb3e757fb87b7?hp=-c Merge branch 'jk/more-push-completion' * jk/more-push-completion: completion: complete `git push --force-with-lease=` completion: add some missing options to `git push` completion: complete "unstuck" `git push --recurse-submodules` --- 0d9cb2d14e4f26c122ab2532b4ceb3e757fb87b7 diff --combined contrib/completion/git-completion.bash index 7a6e1d797a,5ba24ee106..06bf262087 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@@ -21,12 -21,6 +21,12 @@@ # source ~/.git-completion.sh # 3) Consider changing your PS1 to also show the current branch, # see git-prompt.sh for details. +# +# If you use complex aliases of form '!f() { ... }; f', you can use the null +# command ':' as the first command in the function body to declare the desired +# completion style. For example '!f() { : git commit ; ... }; f' will +# tell the completion to use commit completion. This also works with aliases +# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". case "$COMP_WORDBREAKS" in *:*) : great ;; @@@ -787,10 -781,6 +787,10 @@@ __git_aliased_command ( -*) : option ;; *=*) : setting env ;; git) : git itself ;; + \(\)) : skip parens of shell function definition ;; + {) : skip start of shell helper function ;; + :) : skip null command ;; + \'*) : skip opening quote after sh -c ;; *) echo "$word" return @@@ -1621,12 -1611,33 +1621,33 @@@ _git_pull ( __git_push_recurse_submodules="check on-demand" + __git_complete_force_with_lease () + { + local cur_=$1 + + case "$cur_" in + --*=) + ;; + *:*) + __gitcomp_nl "$(__git_refs)" "" "${cur_#*:}" + ;; + *) + __gitcomp_nl "$(__git_refs)" "" "$cur_" + ;; + esac + } + _git_push () { case "$prev" in --repo) __gitcomp_nl "$(__git_remotes)" return + ;; + --recurse-submodules) + __gitcomp "$__git_push_recurse_submodules" + return + ;; esac case "$cur" in --repo=*) @@@ -1637,11 -1648,16 +1658,16 @@@ __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}" return ;; + --force-with-lease=*) + __git_complete_force_with_lease "${cur##--force-with-lease=}" + return + ;; --*) __gitcomp " --all --mirror --tags --dry-run --force --verbose + --quiet --prune --delete --follow-tags --receive-pack= --repo= --set-upstream - --recurse-submodules= + --force-with-lease --force-with-lease= --recurse-submodules= " return ;;