Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Roland Hieber <rhi@pengutronix.de>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Felipe Contreras <felipe.contreras@gmail.com>
Subject: Re: [PATCH 2/2] completion: add docs on how to add subcommand completions
Date: Wed, 24 Apr 2024 23:17:09 +0200	[thread overview]
Message-ID: <20240424211709.ppljgyxzu2rmkamw@pengutronix.de> (raw)
In-Reply-To: <20240424210549.256256-2-rhi@pengutronix.de>

On Wed, Apr 24, 2024 at 11:05:48PM +0200, Roland Hieber wrote:
> It took me more than a few tries and a good lecture of __git_main to
> understand that the two paragraphs above really only refer to adding
> completion functions for executables that are not called through git's
> subcommand magic. Add a few sentences for that case.
> 
> Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> ---
>  contrib/completion/git-completion.bash | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index ffcc55484bcd..f0c8353c1cdb 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -40,6 +40,13 @@
>  #
>  #   __git_complete gk gitk
>  #
> +# To add completion for git subcommands that live in external scripts,
> +# define a function of the form '_git_${subcommand}' while replacing all dashes
> +# with underscores, and the main git completion will make use of it.
> +# For example, to add completeion after 'git do-my-stuff' (which could e.g. live

Ah, of course its s/completeion/completion/ …

 - Roland

> +# in /usr/bin/git-do-stuff), name the completion function '_git_do_stuff'.
> +# See _git_show, _git_bisect etc. below for more examples.
> +#
>  # Compatible with bash 3.2.57.
>  #
>  # You can set the following environment variables to influence the behavior of
> -- 
> 2.39.2
> 
> 

-- 
Roland Hieber, Pengutronix e.K.          | r.hieber@pengutronix.de     |
Steuerwalder Str. 21                     | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686         | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2024-04-24 21:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-24 21:05 [PATCH 1/2] completion: add 'symbolic-ref' Roland Hieber
2024-04-24 21:05 ` [PATCH 2/2] completion: add docs on how to add subcommand completions Roland Hieber
2024-04-24 21:17   ` Roland Hieber [this message]
2024-04-24 21:36   ` Junio C Hamano
2024-04-24 21:41     ` Roland Hieber
2024-04-24 22:22   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240424211709.ppljgyxzu2rmkamw@pengutronix.de \
    --to=rhi@pengutronix.de \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).