Re: [PATCH v2 18/18] completion: support branch-diff
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- May 6, 2018, 08:24 UTC
- Message-ID
- <20180506082440.GA26958@duynguyen.home>
- In-Reply-To
- <71698f11835311c103aae565a2a761d10f4676b9.1525448066.git.johannes.schindelin@gmx.de>
On Fri, May 04, 2018 at 05:35:11PM +0200, Johannes Schindelin wrote:
Show 35 quoted lines
> Tab completion of `branch-diff` is very convenient, especially given
> that the revision arguments that need to be passed to `git branch-diff`
> are typically more complex than, say, your grandfather's `git log`
> arguments.
>
> Without this patch, we would only complete the `branch-diff` part but
> not the options and other arguments.
>
> This of itself may already be slightly disruptive for well-trained
> fingers that assume that `git bra<TAB>ori<TAB>mas<TAB>` would expand to
> `git branch origin/master`, as we now no longer automatically append a
> space after completing `git branch`: this is now ambiguous.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> contrib/completion/git-completion.bash | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 01dd9ff07a2..45addd525ac 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1496,6 +1496,24 @@ _git_format_patch ()
> __git_complete_revlist
> }
>
> +__git_branch_diff_options="
> + --no-patches --creation-weight= --dual-color
> +"
> +
> +_git_branch_diff ()
> +{
> + case "$cur" in
> + --*)
> + __gitcomp "You should use __gitcomp_builtin so you don't have to maintain $__git_branch_diff_options here. Something like this
-- 8< --
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 45addd525a..4745631daf 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1496,18 +1496,11 @@ _git_format_patch () __git_complete_revlist } -__git_branch_diff_options=" - --no-patches --creation-weight= --dual-color -" - _git_branch_diff () { case "$cur" in --*) - __gitcomp " - $__git_branch_diff_options - $__git_diff_common_options - " + __gitcomp_builtin branch-diff "$__git_diff_common_options" return ;; esac -- 8< -- > + $__git_branch_diff_options > + $__git_diff_common_options > + " > + return > + ;; > + esac > + __git_complete_revlist > +} > + > _git_fsck () > { > case "$cur" in > -- > 2.17.0.409.g71698f11835