completion: fix __gitcomp_builtin no longer consider extra options
PATCH 1/1 completion: fix __gitcomp_builtin no longer consider extra options
__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.
--- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/completion/git-completion.bash +1 -1
@@ -400,7 +400,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
Signature · 1 line
2.19.1.647.g708186aaf9
Quoted 15 lines · Nguyễn Thái Ngọc Duy
__gitcomp_builtin()has the main completion list provided bygit xxx --git-completion-helperbut 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.
Quoted 2 lines
Prepend the extra options before "$(git xxx --git-completion-helper)" to avoid this.
Thanks for a clear analysis. How did you find it? Got annoyed that completion of difftool got broken, or discovered while trying to apply the same trick as difftool completion uses to another one and seeing that the technique does not work?
Will queue. Thanks.
Quoted 19 lines
Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>--- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)contrib/completion/git-completion.bash +1
-1@@ -400,7 +400,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
Quoted 18 lines · Junio C Hamano
Quoted 15 lines · Nguyễn Thái Ngọc Duy
__gitcomp_builtin()has the main completion list provided bygit xxx --git-completion-helperbut 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.
Quoted 7 lines
Quoted 2 lines
Prepend the extra options before "$(git xxx --git-completion-helper)" to avoid this.
Thanks for a clear analysis. How did you find it? Got annoyed that completion of difftool got broken, or discovered while trying to apply the same trick as difftool completion uses to another one and seeing that the technique does not work?
I was fixing format-patch completion and was surprised it did not work as expected. Never really used difftool myself :P I only found out about it when I asked myself "why wasn't this breakage found earlier?"
Signature · 1 line
Duy
Quoted 22 lines · Duy Nguyen
Quoted 21 lines · Junio C Hamano
Quoted 17 lines · Nguyễn Thái Ngọc Duy
__gitcomp_builtin()has the main completion list provided bygit xxx --git-completion-helperbut 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.
Quoted 8 lines
Quoted 4 lines
Thanks for a clear analysis. How did you find it? Got annoyed that completion of difftool got broken, or discovered while trying to apply the same trick as difftool completion uses to another one and seeing that the technique does not work?
I was fixing format-patch completion and was surprised it did not work as expected. Never really used difftool myself :P I only found out about it when I asked myself "why wasn't this breakage found earlier?"
Erm... maybe because there are no tests covering the combination of extra options and '--no-..' options in 't9902-completion.sh'?
(Hint, hint... :)