diff options
Diffstat (limited to 'contrib/completion')
-rw-r--r-- | contrib/completion/git-completion.bash | 50 | ||||
-rw-r--r-- | contrib/completion/git-completion.zsh | 3 |
2 files changed, 30 insertions, 23 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 0a96ad87e7..36f5a91c7a 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1467,14 +1467,15 @@ _git_bundle () # Helper function to decide whether or not we should enable DWIM logic for # git-switch and git-checkout. # -# To decide between the following rules in priority order -# 1) the last provided of "--guess" or "--no-guess" explicitly enable or -# disable completion of DWIM logic respectively. -# 2) If the --no-track option is provided, take this as a hint to disable the -# DWIM completion logic -# 3) If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion -# logic, as requested by the user. -# 4) Enable DWIM logic otherwise. +# To decide between the following rules in decreasing priority order: +# - the last provided of "--guess" or "--no-guess" explicitly enable or +# disable completion of DWIM logic respectively. +# - If checkout.guess is false, disable completion of DWIM logic. +# - If the --no-track option is provided, take this as a hint to disable the +# DWIM completion logic +# - If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion +# logic, as requested by the user. +# - Enable DWIM logic otherwise. # __git_checkout_default_dwim_mode () { @@ -1485,11 +1486,17 @@ __git_checkout_default_dwim_mode () fi # --no-track disables DWIM, but with lower priority than - # --guess/--no-guess + # --guess/--no-guess/checkout.guess if [ -n "$(__git_find_on_cmdline "--no-track")" ]; then dwim_opt="" fi + # checkout.guess = false disables DWIM, but with lower priority than + # --guess/--no-guess + if [ "$(__git config --type=bool checkout.guess)" = "false" ]; then + dwim_opt="" + fi + # Find the last provided --guess or --no-guess last_option="$(__git_find_last_on_cmdline "--guess --no-guess")" case "$last_option" in @@ -1688,8 +1695,13 @@ __git_diff_common_options="--stat --numstat --shortstat --summary --submodule --submodule= --ignore-submodules --indent-heuristic --no-indent-heuristic --textconv --no-textconv + --patch --no-patch " +__git_diff_difftool_options="--cached --staged --pickaxe-all --pickaxe-regex + --base --ours --theirs --no-index --relative --merge-base + $__git_diff_common_options" + _git_diff () { __git_has_doubledash && return @@ -1712,10 +1724,7 @@ _git_diff () return ;; --*) - __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex - --base --ours --theirs --no-index - $__git_diff_common_options - " + __gitcomp "$__git_diff_difftool_options" return ;; esac @@ -1737,11 +1746,7 @@ _git_difftool () return ;; --*) - __gitcomp_builtin difftool "$__git_diff_common_options - --base --cached --ours --theirs - --pickaxe-all --pickaxe-regex - --relative --staged - " + __gitcomp_builtin difftool "$__git_diff_difftool_options" return ;; esac @@ -2031,11 +2036,9 @@ _git_log () --no-walk --no-walk= --do-walk --parents --children --expand-tabs --expand-tabs= --no-expand-tabs - --patch $merge $__git_diff_common_options --pickaxe-all --pickaxe-regex - --patch --no-patch " return ;; @@ -2938,7 +2941,7 @@ _git_show () ;; --*) __gitcomp "--pretty= --format= --abbrev-commit --no-abbrev-commit - --oneline --show-signature --patch + --oneline --show-signature --expand-tabs --expand-tabs= --no-expand-tabs $__git_diff_common_options " @@ -3021,7 +3024,10 @@ _git_stash () list,--*) __gitcomp "--name-status --oneline --patch-with-stat" ;; - show,--*|branch,--*) + show,--*) + __gitcomp "$__git_diff_common_options" + ;; + branch,--*) ;; branch,*) if [ $cword -eq 3 ]; then diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index ce47e86b60..107869036d 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -9,13 +9,14 @@ # # If your script is somewhere else, you can configure it on your ~/.zshrc: # -# zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh +# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash # # The recommended way to install this script is to make a copy of it in # ~/.zsh/ directory as ~/.zsh/git-completion.zsh and then add the following # to your ~/.zshrc file: # # fpath=(~/.zsh $fpath) +# autoload -Uz compinit && compinit complete () { |