]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: fix __gitcomp_builtin no longer consider extra options
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 21 Oct 2018 08:37:31 +0000 (10:37 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Oct 2018 03:52:29 +0000 (12:52 +0900)
__gitcomp_builtin() has the main completion list provided by

    git xxx --git-completion-helper

but the caller can also add extra options that is not provided by
--git-completion-helper. The only call site that does this is "git
difftool" completion.

This support is broken by b221b5ab9b (completion: collapse extra
--no-.. options - 2018-06-06), which adds a special value "--" to mark
that the rest of the options can be hidden by default. The commit
forgets the fact that extra options are appended after
"$(git xxx --git-completion-helper)", i.e. after this "--", and will
be incorrectly hidden as well.

Prepend the extra options before "$(git xxx --git-completion-helper)"
to avoid this.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash

index 425d06256f8da9e59952253ea7f48cd6efddddca..74aae853e42673de418dda8027d3f90b885bf7fe 100644 (file)
@@ -336,7 +336,7 @@ __gitcomp_builtin ()
        if [ -z "$options" ]; then
                # leading and trailing spaces are significant to make
                # option removal work correctly.
-               options=" $(__git ${cmd/_/ } --git-completion-helper) $incl "
+               options=" $incl $(__git ${cmd/_/ } --git-completion-helper) "
                for i in $excl; do
                        options="${options/ $i / }"
                done