threads / patch / 54770

patchcompletion: bash: fix gitk alias regression

Subject: [PATCH] completion: bash: fix gitk alias regression

## tl;dr

3 messages between Dec 5, 2020 and Dec 7, 2020. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Felipe Contreras· Dec 5, 2020, 07:10 UTC · lore

Long time ago when the _git_complete helper was introduced, _gitk was replaced with __gitk_main, and a placeholder for backwards compatibility pointing to __git_wrap_main_gitk was left in place.

When "__git_complete gitk __gitk_main" was called, that created the __git_wrap__gitk_main helper, which is just basically "__git_func_wrap __gitk_main" plus `complete` options.

Unfortunately the commit b0a4b2d257 (completion: add support for backwards compatibility, 2012-05-19) missed a previous instance of a call to _gitk in _git_gitk

So, basically we had __git_wrap__git_main -> __git_func_wrap __git_main -> __git_complete_command gitk -> _git_gitk -> _gitk -> __git_wrap__gitk_main -> __git_func_wrap __gitk_main -> __gitk_main.

There was never any need to call __git_func_wrap twice. Since _git_gitk is always called inside the wrapper, it can call __gitk_main directly.

And then, in commit 441ecdab37 (completion: bash: remove old compat wrappers, 2020-10-27) _gitk was removed, which triggers the following error:

  _git_gitk:9: command not found: _gitk
Let's call the correct function: __gitk_main.
Cc: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to contrib/completion/git-completion.bash +1 −1
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 1ed03623cd..463a3124da 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1829,7 +1829,7 @@ _git_fsck ()
 
 _git_gitk ()
 {
-	_gitk
+	__gitk_main
 }
 
 # Lists matching symbol names from a tag (as in ctags) file.
-- 
2.29.2
Felipe Contreras· Dec 5, 2020, 07:12 UTC · re: Felipe Contreras · lore

Re: [PATCH] completion: bash: fix gitk alias regression

On Sat, Dec 5, 2020 at 1:10 AM Felipe Contreras <felipe.contreras@gmail.com> wrote:

Show 29 quoted lines
>
> Long time ago when the _git_complete helper was introduced, _gitk was
> replaced with __gitk_main, and a placeholder for backwards compatibility
> pointing to __git_wrap_main_gitk was left in place.
>
> When "__git_complete gitk __gitk_main" was called, that created the
> __git_wrap__gitk_main helper, which is just basically "__git_func_wrap
> __gitk_main" plus `complete` options.
>
> Unfortunately the commit b0a4b2d257 (completion: add support for
> backwards compatibility, 2012-05-19) missed a previous instance of a
> call to _gitk in _git_gitk
>
> So, basically we had __git_wrap__git_main -> __git_func_wrap __git_main ->
> __git_complete_command gitk -> _git_gitk -> _gitk ->
> __git_wrap__gitk_main -> __git_func_wrap __gitk_main -> __gitk_main.
>
> There was never any need to call __git_func_wrap twice. Since _git_gitk
> is always called inside the wrapper, it can call __gitk_main directly.
>
> And then, in commit 441ecdab37 (completion: bash: remove old compat
> wrappers, 2020-10-27) _gitk was removed, which triggers the following
> error:
>
>   _git_gitk:9: command not found: _gitk
>
> Let's call the correct function: __gitk_main.
>
> Cc: SZEDER Gábor <szeder@ira.uka.de>
Hmmm. SZEDER Gábor <szeder.dev@gmail.com>
-- 
Felipe Contreras
Junio C Hamano· Dec 7, 2020, 21:44 UTC · re: Felipe Contreras · lore

Re: [PATCH] completion: bash: fix gitk alias regression

Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 33 quoted lines
> On Sat, Dec 5, 2020 at 1:10 AM Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
>>
>> Long time ago when the _git_complete helper was introduced, _gitk was
>> replaced with __gitk_main, and a placeholder for backwards compatibility
>> pointing to __git_wrap_main_gitk was left in place.
>>
>> When "__git_complete gitk __gitk_main" was called, that created the
>> __git_wrap__gitk_main helper, which is just basically "__git_func_wrap
>> __gitk_main" plus `complete` options.
>>
>> Unfortunately the commit b0a4b2d257 (completion: add support for
>> backwards compatibility, 2012-05-19) missed a previous instance of a
>> call to _gitk in _git_gitk
>>
>> So, basically we had __git_wrap__git_main -> __git_func_wrap __git_main ->
>> __git_complete_command gitk -> _git_gitk -> _gitk ->
>> __git_wrap__gitk_main -> __git_func_wrap __gitk_main -> __gitk_main.
>>
>> There was never any need to call __git_func_wrap twice. Since _git_gitk
>> is always called inside the wrapper, it can call __gitk_main directly.
>>
>> And then, in commit 441ecdab37 (completion: bash: remove old compat
>> wrappers, 2020-10-27) _gitk was removed, which triggers the following
>> error:
>>
>>   _git_gitk:9: command not found: _gitk
>>
>> Let's call the correct function: __gitk_main.
>>
>> Cc: SZEDER Gábor <szeder@ira.uka.de>
>
> Hmmm. SZEDER Gábor <szeder.dev@gmail.com>
Thanks.

We've seen two hotfixes including this one on the fc/zsh-completion topic since it has been pushed down to 'master' for a month or so. Can somebody give the entire topic a quick eyeballing again (the range is 1d1c4a8759..af806a2c24) just to be sure?

← back to recent threads