git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] completion: take into account the formatting backticks for options

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 17, 2025, 20:52 UTC
Message-ID
<xmqqplif8jnm.fsf@gitster.g>
In-Reply-To
<f8883d83f3096ce16e5dfc9647a41970396693f4.1742056310.git.gitgitgadget@gmail.com>
"Jean-Noël Avila via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 22 quoted lines
> From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>
>
> With the modern formatting of the manpages, the options and commands are now
> backticked in their definition lists. This patch updates the generation of
> the completion list to take into account this new format.
>
> Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
> ---
>  generate-configlist.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/generate-configlist.sh b/generate-configlist.sh
> index dffdaada8b5..802178daad4 100755
> --- a/generate-configlist.sh
> +++ b/generate-configlist.sh
> @@ -13,8 +13,8 @@ print_config_list () {
>  	cat <<EOF
>  static const char *config_name_list[] = {
>  EOF
> -	grep -h '^[a-zA-Z].*\..*::$' "$SOURCE_DIR"/Documentation/*config.adoc "$SOURCE_DIR"/Documentation/config/*.adoc |
> -	sed '/deprecated/d; s/::$//; s/,  */\n/g' |
> +	grep -h '^`\?[a-zA-Z].*\..*`\?::$' "$SOURCE_DIR"/Documentation/*config.adoc "$SOURCE_DIR"/Documentation/config/*.adoc |

Using \? in BRE as a short-hand for \{0,1\} (or trying to use any single regexp magic in BRE by adding a backslash when that magic is only available in ERE) is a GNUism, isn't it?

We probably should rewrite the thing as ERE, perhaps like
	grep -E -h '^`?[a-zA-Z].*\..*`?::$' ...

Also, if we can avoid piping grep into sed or awk, we should do so, when it does not lose readability. Perhaps we can do something like

	sed -E -n -e '/... that pattern .../{
		/deprecated/d;
		s/::$//;
		...
	}' "$SOURCE_DIR"/Documentation/*config.adoc ... |
        sort |
	...
in this case?
> +	sed '/deprecated/d; s/::$//; s/`//g; s/,  */\n/g' |
>  	sort |
>  	sed 's/^.*$/	"&",/'
>  	cat <<EOF
Previous: Jean-Noël Avila via GitGitGadgetNext: Jean-Noël AVILA
Message 3 of 11 in “doc: apply new format to git-branch man page”
  1. 0/2 doc: apply new format to git-branch man pageJean-Noël Avila via GitGitGadget, Mar 15, 2025
  2. 1/2 completion: take into account the formatting backticks for optionsJean-Noël Avila via GitGitGadget, Mar 15, 2025
  3. Junio C HamanoMar 17, 2025
  4. Jean-Noël AVILAMar 18, 2025
  5. Junio C HamanoMar 18, 2025
  6. Jean-Noël AVILAMar 18, 2025
  7. 2/2 doc: apply new format to git-branch man pageJean-Noël Avila via GitGitGadget, Mar 15, 2025
  8. Junio C HamanoMar 17, 2025
  9. 0/2 doc: apply new format to git-branch man pageJean-Noël Avila via GitGitGadget, Mar 19, 2025
  10. 1/2 completion: take into account the formatting backticks for optionsJean-Noël Avila via GitGitGadget, Mar 19, 2025
  11. 2/2 doc: apply new format to git-branch man pageJean-Noël Avila via GitGitGadget, Mar 19, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.