[PATCH] completion: improve doc for complex aliases

Subsystems: the rest

STALE1111d

6 messages, 4 authors, 2023-09-14 · open the first message on its own page

[PATCH] completion: improve doc for complex aliases

From: Philippe Blain via GitGitGadget <hidden>
Date: 2023-09-09 16:25:38

From: Philippe Blain <redacted>

The completion code can be told to use a particular completion for
aliases that shell out by using ': git <cmd> ;' as the first command of
the alias. This only works if <cmd> and the semicolon are separated by a
space. The examples have that space but it's not clear if it's just for
style or if it's mandatory.

Explicitely mention it.

Signed-off-by: Philippe Blain <redacted>
---
    completion: improve doc for complex aliases
    
    The completion code can be told to use a particular completion for
    aliases that shell out by using ': git ;' as the first command of the
    alias. This only works if and the semicolon are separated by a space.
    The examples have that space but it's not clear if it's just for style
    or if it's mandatory.
    
    Explicitely mention it.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1585%2Fphil-blain%2Fcompletion-shell-aliases-doc-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1585/phil-blain/completion-shell-aliases-doc-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1585

 contrib/completion/git-completion.bash | 1 +
 1 file changed, 1 insertion(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index dc95c34cc85..659df570496 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -28,6 +28,7 @@
 # completion style.  For example '!f() { : git commit ; ... }; f' will
 # tell the completion to use commit completion.  This also works with aliases
 # of form "!sh -c '...'".  For example, "!sh -c ': git commit ; ... '".
+# Be sure to add a space between the command name and the ';'.
 #
 # If you have a command that is not part of git, but you would still
 # like completion, you can use __git_complete:
base-commit: 23c56f7bd5f1667f8b793d796bf30e39545920f6
-- 
gitgitgadget

Re: [PATCH] completion: improve doc for complex aliases

From: Eric Sunshine <hidden>
Date: 2023-09-10 02:02:37

On Sat, Sep 9, 2023 at 12:25 PM Philippe Blain via GitGitGadget
[off-list ref] wrote:
The completion code can be told to use a particular completion for
aliases that shell out by using ': git <cmd> ;' as the first command of
the alias. This only works if <cmd> and the semicolon are separated by a
space. The examples have that space but it's not clear if it's just for
style or if it's mandatory.

Explicitely mention it.
s/Explicitely/Explicitly/
Signed-off-by: Philippe Blain <redacted>

Re: [PATCH] completion: improve doc for complex aliases

From: Linus Arver <hidden>
Date: 2023-09-12 01:13:59

Hi Philippe,

"Philippe Blain via GitGitGadget" [off-list ref] writes:
From: Philippe Blain <redacted>

The completion code can be told to use a particular completion for
aliases that shell out by using ': git <cmd> ;' as the first command of
the alias. This only works if <cmd> and the semicolon are separated by a
space. The examples have that space but it's not clear if it's just for
style or if it's mandatory.

Explicitely mention it.
It would be even more helpful if you explain _why_ it is mandatory in
the commit message. Is there some Bash-specific behavior or something
else going on here?

If you are unable to explain why, then as an alternative you could
explain the error or buggy behavior (any error messages encountered, for
example) you observe on your system when you do not use the space (which
is corrected by applying the suggestion you are adding in this patch).

Thanks!

Re: [PATCH] completion: improve doc for complex aliases

From: Philippe Blain <hidden>
Date: 2023-09-12 12:13:16

Hi Linus,

Le 2023-09-11 à 21:04, Linus Arver a écrit :
Hi Philippe,

"Philippe Blain via GitGitGadget" [off-list ref] writes:
quoted
From: Philippe Blain <redacted>

The completion code can be told to use a particular completion for
aliases that shell out by using ': git <cmd> ;' as the first command of
the alias. This only works if <cmd> and the semicolon are separated by a
space. The examples have that space but it's not clear if it's just for
style or if it's mandatory.

Explicitely mention it.
It would be even more helpful if you explain _why_ it is mandatory in
the commit message. Is there some Bash-specific behavior or something
else going on here?

If you are unable to explain why, then as an alternative you could
explain the error or buggy behavior (any error messages encountered, for
example) you observe on your system when you do not use the space (which
is corrected by applying the suggestion you are adding in this patch).
Yeah, I guess I did not investigate why it did not work without the space,
it would be more complete if I did.

There's no error message though, it just does not work without the space 
(as I wrote in the commit message) in the sense that it won't suggest completion
for the git command '<cmd>'.

I'll investigate and update the commit message.

Thanks,
Philippe.

[PATCH v2] completion: improve doc for complex aliases

From: Philippe Blain via GitGitGadget <hidden>
Date: 2023-09-12 17:02:29

From: Philippe Blain <redacted>

The completion code can be told to use a particular completion for
aliases that shell out by using ': git <cmd> ;' as the first command of
the alias. This only works if <cmd> and the semicolon are separated by a
space, since if the space is missing __git_aliased_command returns (for
example) 'checkout;' instead of just 'checkout', and then
__git_complete_command fails to find a completion for 'checkout;'.

The examples have that space but it's not clear if it's just for
style or if it's mandatory. Explicitly mention it.

Signed-off-by: Philippe Blain <redacted>
---
    completion: improve doc for complex aliases
    
    Changes since v1:
    
     * fixed the typo pointed out by Eric
     * added an explanation of why the space is mandatory, as suggested by
       Linus

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1585%2Fphil-blain%2Fcompletion-shell-aliases-doc-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1585/phil-blain/completion-shell-aliases-doc-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1585

Range-diff vs v1:

 1:  b3621ed25f0 ! 1:  96a0867c5ad completion: improve doc for complex aliases
     @@ Commit message
          The completion code can be told to use a particular completion for
          aliases that shell out by using ': git <cmd> ;' as the first command of
          the alias. This only works if <cmd> and the semicolon are separated by a
     -    space. The examples have that space but it's not clear if it's just for
     -    style or if it's mandatory.
     +    space, since if the space is missing __git_aliased_command returns (for
     +    example) 'checkout;' instead of just 'checkout', and then
     +    __git_complete_command fails to find a completion for 'checkout;'.
      
     -    Explicitely mention it.
     +    The examples have that space but it's not clear if it's just for
     +    style or if it's mandatory. Explicitly mention it.
      
          Signed-off-by: Philippe Blain [off-list ref]
      


 contrib/completion/git-completion.bash | 1 +
 1 file changed, 1 insertion(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index dc95c34cc85..659df570496 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -28,6 +28,7 @@
 # completion style.  For example '!f() { : git commit ; ... }; f' will
 # tell the completion to use commit completion.  This also works with aliases
 # of form "!sh -c '...'".  For example, "!sh -c ': git commit ; ... '".
+# Be sure to add a space between the command name and the ';'.
 #
 # If you have a command that is not part of git, but you would still
 # like completion, you can use __git_complete:
base-commit: 23c56f7bd5f1667f8b793d796bf30e39545920f6
-- 
gitgitgadget

Re: [PATCH v2] completion: improve doc for complex aliases

From: Linus Arver <hidden>
Date: 2023-09-14 22:33:30

"Philippe Blain via GitGitGadget" [off-list ref] writes:
From: Philippe Blain <redacted>

The completion code can be told to use a particular completion for
aliases that shell out by using ': git <cmd> ;' as the first command of
the alias. This only works if <cmd> and the semicolon are separated by a
space, since if the space is missing __git_aliased_command returns (for
example) 'checkout;' instead of just 'checkout', and then
__git_complete_command fails to find a completion for 'checkout;'.

The examples have that space but it's not clear if it's just for
style or if it's mandatory. Explicitly mention it.

Signed-off-by: Philippe Blain <redacted>
---
    completion: improve doc for complex aliases
    
    Changes since v1:
    
     * fixed the typo pointed out by Eric
     * added an explanation of why the space is mandatory, as suggested by
       Linus
Thanks for the investigation. The commit message reads much better now.

This LGTM, but I think Junio's review comments [1] are worth
considering. I'll respond there also.

[1] https://lore.kernel.org/git/xmqqo7i6khxv.fsf@gitster.g/#t 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help