public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail•com>
To: "Jean-Noël Avila" <gitgitgadget@gmail•com>, git@vger•kernel.org
Cc: "Junio C Hamano" <gitster@pobox•com>,
	"Derrick Stolee" <stolee@gmail•com>
Subject: Re: [PATCH 11/11] config-batch: add unset v1 command
Date: Thu, 05 Feb 2026 18:36:33 +0100	[thread overview]
Message-ID: <bd2dbd12-e12f-467c-983b-f7e9a31e1d92@app.fastmail.com> (raw)
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 <stolee@gmail•com>
>
> 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 <stolee@gmail•com>
> ---
>  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 <scope> <key> <value>
>  set 1 failed <scope> <key> <value>
>  ------------
>
> +`unset` version 1::
> +	The `unset` command removes a single value from a config file.
> +	It specifies which file by a `<scope>` parameter from among
> +	`system`, `global`, `local`, and `worktree`. The `<key>` 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 <scope> <key>
> +unset 1 <scope> <key> arg:regex <value-pattern>
> +unset 1 <scope> <key> arg:fixed-value <value>
> +------------
> ++
> +These uses will match the behavior of `git config --unset --<scope> <key>`

Same as above.

> +with the additional arguments of `<value-pattern>` if `arg:regex` is
> +given or `--fixed-value <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 <scope> <key>
> +unset 1 failed <scope> <key>
> +------------
> +
>  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]

  reply	other threads:[~2026-02-05 17:36 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-04 14:19 [PATCH 00/11] [RFC] config-batch: a new builtin for tools querying config Derrick Stolee via GitGitGadget
2026-02-04 14:19 ` [PATCH 01/11] config-batch: basic boilerplate of new builtin Derrick Stolee via GitGitGadget
2026-02-04 23:23   ` Junio C Hamano
2026-02-05 14:17     ` Derrick Stolee
2026-02-05 17:26       ` Kristoffer Haugsbakk
2026-02-05 17:29   ` Kristoffer Haugsbakk
2026-02-06  4:11   ` Jean-Noël Avila
2026-02-04 14:19 ` [PATCH 02/11] config-batch: create parse loop and unknown command Derrick Stolee via GitGitGadget
2026-02-04 23:26   ` Junio C Hamano
2026-02-05 17:30   ` Kristoffer Haugsbakk
2026-02-06  4:15   ` Jean-Noël Avila
2026-02-04 14:19 ` [PATCH 03/11] config-batch: implement get v1 Derrick Stolee via GitGitGadget
2026-02-06  4:41   ` Jean-Noël Avila
2026-02-04 14:19 ` [PATCH 04/11] config-batch: create 'help' command Derrick Stolee via GitGitGadget
2026-02-06  4:49   ` Jean-Noël Avila
2026-02-10  4:20     ` Derrick Stolee
2026-02-04 14:19 ` [PATCH 05/11] config-batch: add NUL-terminated I/O format Derrick Stolee via GitGitGadget
2026-02-05 17:44   ` Kristoffer Haugsbakk
2026-02-06  4:58   ` Jean-Noël Avila
2026-02-04 14:19 ` [PATCH 06/11] docs: add design doc for config-batch Derrick Stolee via GitGitGadget
2026-02-05 17:38   ` Kristoffer Haugsbakk
2026-02-10  4:22     ` Derrick Stolee
2026-02-04 14:19 ` [PATCH 07/11] config: extract location structs from builtin Derrick Stolee via GitGitGadget
2026-02-04 14:20 ` [PATCH 08/11] config-batch: pass prefix through commands Derrick Stolee via GitGitGadget
2026-02-04 14:20 ` [PATCH 09/11] config-batch: add 'set' v1 command Derrick Stolee via GitGitGadget
2026-02-05 17:21   ` Kristoffer Haugsbakk
2026-02-05 18:58     ` Kristoffer Haugsbakk
2026-02-05 19:01   ` Kristoffer Haugsbakk
2026-02-10  4:25     ` Derrick Stolee
2026-02-06  5:04   ` Jean-Noël Avila
2026-02-04 14:20 ` [PATCH 10/11] t1312: create read/write test Derrick Stolee via GitGitGadget
2026-02-04 14:20 ` [PATCH 11/11] config-batch: add unset v1 command Derrick Stolee via GitGitGadget
2026-02-05 17:36   ` Kristoffer Haugsbakk [this message]
2026-02-04 23:04 ` [PATCH 00/11] [RFC] config-batch: a new builtin for tools querying config Junio C Hamano
2026-02-05 14:10   ` Derrick Stolee
2026-02-05  0:04 ` brian m. carlson
2026-02-05 13:52   ` Derrick Stolee
2026-02-10  4:49     ` Derrick Stolee
2026-02-05 14:45 ` Phillip Wood
2026-02-05 17:20 ` Kristoffer Haugsbakk

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=bd2dbd12-e12f-467c-983b-f7e9a31e1d92@app.fastmail.com \
    --to=kristofferhaugsbakk@fastmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitgitgadget@gmail$(echo .)com \
    --cc=gitster@pobox$(echo .)com \
    --cc=stolee@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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