Re: [PATCH 03/11] config-batch: implement get v1
From: Jean-Noël Avila <hidden>
Date: 2026-02-06 04:41:57
Le 04/02/2026 à 15:19, Derrick Stolee via GitGitGadget a écrit :
quoted hunk ↗ jump to hunk
From: Derrick Stolee <redacted> 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 <redacted> --- 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?
quoted hunk ↗ jump to hunk
+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>_,…
quoted hunk ↗ jump to hunk
+ 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> ------------
quoted hunk ↗ jump to hunk
+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
quoted hunk ↗ jump to hunk
+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.
quoted hunk ↗ jump to hunk
+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 (local)