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

Re: [PATCH 03/11] config-batch: implement get v1

From
Jean-Noël Avila <jn.avila@free.fr>
Date
Feb 6, 2026, 04:41 UTC
Message-ID
<61926b22-dca1-4e5d-a911-6fc47dee68d6@free.fr>
In-Reply-To
<3de1bba3b10668f0200e27def9128571f51c1f68.1770214803.git.gitgitgadget@gmail.com>
Le 04/02/2026 à 15:19, Derrick Stolee via GitGitGadget a écrit :
Show 42 quoted lines
> From: Derrick Stolee <stolee@gmail.com>
> 
> The 'get' command for the 'git config-batch' builtin is the first command
> and is currently at version 1. It returns at most one value, the same as
> 'git config --get <key>' with optional value-based filtering.
> 
> The documentation and tests detail the specifics of how to format requests
> of this format and how to parse the results.
> 
> Future versions could consider multi-valued responses or regex-based key
> matching.
> 
> For the sake of incremental exploration of the potential in the 'git
> config-batch' command, this is the only implementation being presented in
> the first patch series.
> 
> Future extensions could include a '-z' parameter that uses NUL bytes in the
> command and output format to allow for spaces or newlines in the input or
> newlines in the output.
> 
> Signed-off-by: Derrick Stolee <stolee@gmail.com>
> ---
>  Documentation/git-config-batch.adoc |  53 +++++-
>  builtin/config-batch.c              | 251 +++++++++++++++++++++++++++-
>  config.h                            |   3 +
>  t/t1312-config-batch.sh             | 101 +++++++++++
>  4 files changed, 405 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/git-config-batch.adoc b/Documentation/git-config-batch.adoc
> index 9ca04b0c1e..31dd42f481 100644
> --- a/Documentation/git-config-batch.adoc
> +++ b/Documentation/git-config-batch.adoc
> @@ -32,9 +32,58 @@ set. Thus, if the Git version includes the `git config-batch` builtin
>  but doesn't understand an input command, it will return a single line
>  response:
>  
> -```
> +------------
>  unknown_command LF
> -```
> +------------
> +

OK, the change to Asciidoc code block is done here. Would it be possible to push it up at the introduction of these lines?

Show 5 quoted lines
> +These are the commands that are currently understood:
> +
> +`get` version 1::
> +	The `get` command searches the config key-value pairs within a
> +	given `<scope>` for values that match the fixed `<key>` and

The rendering of these is correct due to the synopsis formatter, but we usually prefer to use the direct formatting for placeholders: _<scope>_, _<key>_,…

Show 10 quoted lines
> +	filters the resulting value based on an optional `<value-filter>`.
> +	This can either be a regex or a fixed value. The command format
> +	is one of the following formats:
> ++
> +------------
> +get 1 <scope> <key>
> +get 1 <scope> <key> arg:regex <value-pattern>
> +get 1 <scope> <key> arg:fixed-value <value>
> +------------
> ++

If you are using synopsis style in the block, with the upcoming change of synopsis style block[1], you can format it:

[synopsis] ------------ get 1 <scope> <key> get 1 <scope> <key> arg:regex <value-pattern> get 1 <scope> <key> arg:fixed-value <value> ------------

Show 13 quoted lines
> +The `<scope>` value can be one of `inherited`, `system`, `global`,
> +`local`, `worktree`, `submodule`, or `command`. If `inherited`, then all
> +config key-value pairs will be considered regardless of scope. Otherwise,
> +only the given scope will be considered.
> ++
> +If no optional arguments are given, then the value will not be filtered
> +by any pattern matching. If `arg:regex` is specified, then the rest of
> +the line is considered a single string, `<value-pattern>`, and is
> +interpreted as a regular expression for matching against stored values,
> +similar to specifying a value to `get config --get <key> "<value-pattern>"`.
> +If `arg:fixed-value` is specified, then the rest of the line is
> +considered a single string, `<value>`, and is checked for an exact
> +match against the key-value pairs, simmilar to `git config --get <key>
similar
> +--fixed-value "<value>"`.
> ++

Here I would use a sub definition list for each matching type, instead of long running description paragraph.

optional arguments can be specified:

no optional arguments;; the value will not be filteredby any pattern matching. `arg:regex <value-pattern>`;; `<value-pattern>` is interpreted as a regular expression for matching against stored values, similar to specifying a value to `get config --get <key> "<value-pattern>"`. `arg:fixed-value <value>`;; `<value>` is checked for an exact match against the key-value pairs, similar to `git config --get <key>`.

> +At mmost one key-value pair is returned, that being the last key-value
At most
Show 15 quoted lines
> +pair in the standard config order by scope and sequence within each scope.
> ++
> +If a key-value pair is found, then the following output is given:
> ++
> +------------
> +get 1 found <key> <scope> <value>
> +------------
> ++
> +If no matching key-value pair is found, then the following output is
> +given:
> ++
> +------------
> +get 1 missing <key> [<value-pattern>|<value>]
> +------------
> ++
Please also apply synopsis block style.
Show 5 quoted lines
> +where `<value-pattern>` or `<value>` is only supplied if provided in
> +the command.
>  
>  SEE ALSO
>  --------

[1]: https://lore.kernel.org/git/6a2b94e720862fa07fe9463ebf7f7beaa9a1ccd4.1770351146.git.gitgitgadget@gmail.com/T/#u

Previous: Derrick Stolee via GitGitGadgetNext: Derrick Stolee via GitGitGadget
Message 13 of 40 in “[RFC] config-batch: a new builtin for tools querying config”
  1. 00/11 [RFC] config-batch: a new builtin for tools querying configDerrick Stolee via GitGitGadget, Feb 4, 2026
  2. 01/11 config-batch: basic boilerplate of new builtinDerrick Stolee via GitGitGadget, Feb 4, 2026
  3. Junio C HamanoFeb 4, 2026
  4. Derrick StoleeFeb 5, 2026
  5. Kristoffer HaugsbakkFeb 5, 2026
  6. Kristoffer HaugsbakkFeb 5, 2026
  7. Jean-Noël AvilaFeb 6, 2026
  8. 02/11 config-batch: create parse loop and unknown commandDerrick Stolee via GitGitGadget, Feb 4, 2026
  9. Junio C HamanoFeb 4, 2026
  10. Kristoffer HaugsbakkFeb 5, 2026
  11. Jean-Noël AvilaFeb 6, 2026
  12. 03/11 config-batch: implement get v1Derrick Stolee via GitGitGadget, Feb 4, 2026
  13. Jean-Noël AvilaFeb 6, 2026
  14. 04/11 config-batch: create 'help' commandDerrick Stolee via GitGitGadget, Feb 4, 2026
  15. Jean-Noël AvilaFeb 6, 2026
  16. Derrick StoleeFeb 10, 2026
  17. 05/11 config-batch: add NUL-terminated I/O formatDerrick Stolee via GitGitGadget, Feb 4, 2026
  18. Kristoffer HaugsbakkFeb 5, 2026
  19. Jean-Noël AvilaFeb 6, 2026
  20. 06/11 docs: add design doc for config-batchDerrick Stolee via GitGitGadget, Feb 4, 2026
  21. Kristoffer HaugsbakkFeb 5, 2026
  22. Derrick StoleeFeb 10, 2026
  23. 07/11 config: extract location structs from builtinDerrick Stolee via GitGitGadget, Feb 4, 2026
  24. 08/11 config-batch: pass prefix through commandsDerrick Stolee via GitGitGadget, Feb 4, 2026
  25. 09/11 config-batch: add 'set' v1 commandDerrick Stolee via GitGitGadget, Feb 4, 2026
  26. Kristoffer HaugsbakkFeb 5, 2026
  27. Kristoffer HaugsbakkFeb 5, 2026
  28. Kristoffer HaugsbakkFeb 5, 2026
  29. Derrick StoleeFeb 10, 2026
  30. Jean-Noël AvilaFeb 6, 2026
  31. 10/11 t1312: create read/write testDerrick Stolee via GitGitGadget, Feb 4, 2026
  32. 11/11 config-batch: add unset v1 commandDerrick Stolee via GitGitGadget, Feb 4, 2026
  33. Kristoffer HaugsbakkFeb 5, 2026
  34. Junio C HamanoFeb 4, 2026
  35. Derrick StoleeFeb 5, 2026
  36. brian m. carlsonFeb 5, 2026
  37. Derrick StoleeFeb 5, 2026
  38. Derrick StoleeFeb 10, 2026
  39. Phillip WoodFeb 5, 2026
  40. Kristoffer HaugsbakkFeb 5, 2026

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.