From: Kristoffer Haugsbakk Date: Thu, 05 Feb 2026 17:36:33 GMT Subject: Re: [PATCH 11/11] config-batch: add unset v1 command Message-ID: In-Reply-To: <59d19fee5f5bd34c5864bebb8243afdc6bc9ea7a.1770214803.git.gitgitgadget@gmail.com> On Wed, Feb 4, 2026, at 15:20, Derrick Stolee via GitGitGadget wrote: > From: Derrick Stolee > > Add a new 'unset' command with version 1 that mimics 'git config > --unset' with optional regex pattern or '--fixed-value' arguments. `git config --unset` is deprecated in favor of `git config unset`. > > Signed-off-by: Derrick Stolee > --- > Documentation/git-config-batch.adoc | 28 ++++++++ > builtin/config-batch.c | 99 +++++++++++++++++++++++++++++ > t/t1312-config-batch.sh | 61 ++++++++++++++++-- > 3 files changed, 181 insertions(+), 7 deletions(-) > > diff --git a/Documentation/git-config-batch.adoc > b/Documentation/git-config-batch.adoc > index feec85c4ef..bdfd872d65 100644 > --- a/Documentation/git-config-batch.adoc > +++ b/Documentation/git-config-batch.adoc > @@ -135,6 +135,34 @@ set 1 success > set 1 failed > ------------ > > +`unset` version 1:: > + The `unset` command removes a single value from a config file. > + It specifies which file by a `` parameter from among > + `system`, `global`, `local`, and `worktree`. The `` is the > + next positional argument. There could be two additional > + arguments used to match specific config values, where the first > + is either `arg:regex` or `arg:fixed-value` to specify the type > + of match. > ++ > +------------ > +unset 1 > +unset 1 arg:regex > +unset 1 arg:fixed-value > +------------ > ++ > +These uses will match the behavior of `git config --unset -- ` Same as above. > +with the additional arguments of `` if `arg:regex` is > +given or `--fixed-value ` if `arg:fixed-value` is given. > ++ > +The response of these commands will include a `success` message > +if matched values are found and removed as expected or `failed` if an > +unexpected failure occurs: > ++ > +------------ > +unset 1 success > +unset 1 failed > +------------ > + > NUL-Terminated Format > ~~~~~~~~~~~~~~~~~~~~~ > > diff --git a/builtin/config-batch.c b/builtin/config-batch.c > index 373b0cad47..25a942ba61 100644 > --- a/builtin/config-batch.c > +++ b/builtin/config-batch.c > @@ -17,6 +17,7 @@ static int zformat = 0; > #define HELP_COMMAND "help" > #define GET_COMMAND "get" > #define SET_COMMAND "set" > +#define UNSET_COMMAND "unset" > #define COMMAND_PARSE_ERROR "command_parse_error" > > static void print_word(const char *word, int start) > @@ -445,6 +446,99 @@ cleanup: > return res; > } > > +/** > + * 'unset' command, version 1. > + * > + * Positional arguments should be of the form: > + * > + * [0] scope ("system", "global", "local", or "worktree") > + * [1] config key > + * [2] config value > + * [3*] match ("regex", "fixed-value") > + * [4*] value regex OR value string > + * > + * [N*] indicates optional parameters that are not needed. > + */ > +static int unset_command_1(struct repository *repo, > + const char *prefix, > + char *data, > + size_t data_len) > +{ > + int res = 0, err = 0, flags = 0; > + enum config_scope scope = CONFIG_SCOPE_UNKNOWN; > + char *token = NULL, *key = NULL, *value_pattern = NULL; > + size_t token_len; > + struct config_location_options locopts = CONFIG_LOCATION_OPTIONS_INIT; > + > + if (!parse_token(&data, &data_len, &token, &err) || err) > + goto parse_error; > + > + if (parse_scope(token, &scope) || > + scope == CONFIG_SCOPE_UNKNOWN || > + scope == CONFIG_SCOPE_SUBMODULE || > + scope == CONFIG_SCOPE_COMMAND) > + goto parse_error; I think this should get braces since it has many lines? Or maybe multi-line conditionals are excempt. > + > + if (!parse_token(&data, &data_len, &key, &err) || err) > + goto parse_error; >[snip]