public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Derrick Stolee <stolee@gmail.com>,
	Derrick Stolee <stolee@gmail.com>
Subject: [PATCH 01/11] config-batch: basic boilerplate of new builtin
Date: Wed, 04 Feb 2026 14:19:53 +0000	[thread overview]
Message-ID: <c4dab0609613bc5d43bce705dca2f057674a5d5b.1770214803.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2033.git.1770214803.gitgitgadget@gmail.com>

From: Derrick Stolee <stolee@gmail.com>

Later changes will document, implement, and test this new builtin. For now,
this serves as the latest example of the minimum boilerplate to introduce a
new builtin.

Recently, we updated the comment in builtin.h about how to create a new
builtin, but failed to mention the required change to meson.build files for
some CI builds to pass. Fix that oversight.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
---
 .gitignore                          |  1 +
 Documentation/git-config-batch.adoc | 24 +++++++++++++++++++++++
 Documentation/meson.build           |  1 +
 Makefile                            |  1 +
 builtin.h                           |  7 +++++++
 builtin/config-batch.c              | 30 +++++++++++++++++++++++++++++
 command-list.txt                    |  1 +
 git.c                               |  1 +
 meson.build                         |  1 +
 t/meson.build                       |  1 +
 t/t1312-config-batch.sh             | 12 ++++++++++++
 11 files changed, 80 insertions(+)
 create mode 100644 Documentation/git-config-batch.adoc
 create mode 100644 builtin/config-batch.c
 create mode 100755 t/t1312-config-batch.sh

diff --git a/.gitignore b/.gitignore
index 78a45cb5be..42640b5e24 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,6 +44,7 @@
 /git-commit-graph
 /git-commit-tree
 /git-config
+/git-config-batch
 /git-count-objects
 /git-credential
 /git-credential-cache
diff --git a/Documentation/git-config-batch.adoc b/Documentation/git-config-batch.adoc
new file mode 100644
index 0000000000..dfa0bd83e2
--- /dev/null
+++ b/Documentation/git-config-batch.adoc
@@ -0,0 +1,24 @@
+git-config-batch(1)
+===================
+
+NAME
+----
+git-config-batch - Get and set options using machine-parseable interface
+
+
+SYNOPSIS
+--------
+[verse]
+'git config-batch' <options>
+
+DESCRIPTION
+-----------
+TODO
+
+SEE ALSO
+--------
+linkgit:git-config[1]
+
+GIT
+---
+Part of the linkgit:git[1] suite
diff --git a/Documentation/meson.build b/Documentation/meson.build
index f02dbc20cb..f5ad117921 100644
--- a/Documentation/meson.build
+++ b/Documentation/meson.build
@@ -29,6 +29,7 @@ manpages = {
   'git-commit-tree.adoc' : 1,
   'git-commit.adoc' : 1,
   'git-config.adoc' : 1,
+  'git-config-batch.adoc' : 1,
   'git-count-objects.adoc' : 1,
   'git-credential-cache--daemon.adoc' : 1,
   'git-credential-cache.adoc' : 1,
diff --git a/Makefile b/Makefile
index 8aa489f3b6..aa3868e513 100644
--- a/Makefile
+++ b/Makefile
@@ -1390,6 +1390,7 @@ BUILTIN_OBJS += builtin/commit-graph.o
 BUILTIN_OBJS += builtin/commit-tree.o
 BUILTIN_OBJS += builtin/commit.o
 BUILTIN_OBJS += builtin/config.o
+BUILTIN_OBJS += builtin/config-batch.o
 BUILTIN_OBJS += builtin/count-objects.o
 BUILTIN_OBJS += builtin/credential-cache--daemon.o
 BUILTIN_OBJS += builtin/credential-cache.o
diff --git a/builtin.h b/builtin.h
index e5e16ecaa6..5f5a19635e 100644
--- a/builtin.h
+++ b/builtin.h
@@ -68,12 +68,18 @@
  *
  * . Add `builtin/foo.o` to `BUILTIN_OBJS` in `Makefile`.
  *
+ * . Add 'builtin/foo.c' to the 'builtin_sources' array in 'meson.build'.
+ *
  * Additionally, if `foo` is a new command, there are 4 more things to do:
  *
  * . Add tests to `t/` directory.
  *
+ * . Add the test script to 'integration_tests' in  't/meson.build'.
+ *
  * . Write documentation in `Documentation/git-foo.adoc`.
  *
+ * . Add 'git-foo.adoc' to the manpages list in 'Documentation/meson.build'.
+ *
  * . Add an entry for `git-foo` to `command-list.txt`.
  *
  * . Add an entry for `/git-foo` to `.gitignore`.
@@ -167,6 +173,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix, struct repositor
 int cmd_commit_graph(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_commit_tree(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_config(int argc, const char **argv, const char *prefix, struct repository *repo);
+int cmd_config_batch(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_count_objects(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_credential(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_credential_cache(int argc, const char **argv, const char *prefix, struct repository *repo);
diff --git a/builtin/config-batch.c b/builtin/config-batch.c
new file mode 100644
index 0000000000..ea4f408ecb
--- /dev/null
+++ b/builtin/config-batch.c
@@ -0,0 +1,30 @@
+#define USE_THE_REPOSITORY_VARIABLE
+#include "builtin.h"
+#include "config.h"
+#include "environment.h"
+#include "parse-options.h"
+
+static const char *const builtin_config_batch_usage[] = {
+	N_("git config-batch <options>"),
+	NULL
+};
+
+int cmd_config_batch(int argc,
+		     const char **argv,
+		     const char *prefix,
+		     struct repository *repo)
+{
+	struct option options[] = {
+		OPT_END(),
+	};
+
+	show_usage_with_options_if_asked(argc, argv,
+					 builtin_config_batch_usage, options);
+
+	argc = parse_options(argc, argv, prefix, options, builtin_config_batch_usage,
+			     0);
+
+	repo_config(repo, git_default_config, NULL);
+
+	return 0;
+}
diff --git a/command-list.txt b/command-list.txt
index accd3d0c4b..57c7c7458d 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -83,6 +83,7 @@ git-commit                              mainporcelain           history
 git-commit-graph                        plumbingmanipulators
 git-commit-tree                         plumbingmanipulators
 git-config                              ancillarymanipulators           complete
+git-config-batch                        plumbinginterrogators
 git-count-objects                       ancillaryinterrogators
 git-credential                          purehelpers
 git-credential-cache                    purehelpers
diff --git a/git.c b/git.c
index c5fad56813..6b55a867dd 100644
--- a/git.c
+++ b/git.c
@@ -557,6 +557,7 @@ static struct cmd_struct commands[] = {
 	{ "commit-graph", cmd_commit_graph, RUN_SETUP },
 	{ "commit-tree", cmd_commit_tree, RUN_SETUP },
 	{ "config", cmd_config, RUN_SETUP_GENTLY | DELAY_PAGER_CONFIG },
+	{ "config-batch", cmd_config_batch, RUN_SETUP_GENTLY },
 	{ "count-objects", cmd_count_objects, RUN_SETUP },
 	{ "credential", cmd_credential, RUN_SETUP_GENTLY | NO_PARSEOPT },
 	{ "credential-cache", cmd_credential_cache },
diff --git a/meson.build b/meson.build
index dd52efd1c8..040bc32c2d 100644
--- a/meson.build
+++ b/meson.build
@@ -582,6 +582,7 @@ builtin_sources = [
   'builtin/commit-tree.c',
   'builtin/commit.c',
   'builtin/config.c',
+  'builtin/config-batch.c',
   'builtin/count-objects.c',
   'builtin/credential-cache--daemon.c',
   'builtin/credential-cache.c',
diff --git a/t/meson.build b/t/meson.build
index 459c52a489..0e9f1826f8 100644
--- a/t/meson.build
+++ b/t/meson.build
@@ -186,6 +186,7 @@ integration_tests = [
   't1309-early-config.sh',
   't1310-config-default.sh',
   't1311-config-optional.sh',
+  't1312-config-batch.sh',
   't1350-config-hooks-path.sh',
   't1400-update-ref.sh',
   't1401-symbolic-ref.sh',
diff --git a/t/t1312-config-batch.sh b/t/t1312-config-batch.sh
new file mode 100755
index 0000000000..f59ba4a0f3
--- /dev/null
+++ b/t/t1312-config-batch.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+test_description='Test git config-batch'
+
+. ./test-lib.sh
+
+test_expect_success 'help text' '
+	test_must_fail git config-batch -h >out &&
+	grep usage out
+'
+
+test_done
-- 
gitgitgadget


  reply	other threads:[~2026-02-04 14:20 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 ` Derrick Stolee via GitGitGadget [this message]
2026-02-04 23:23   ` [PATCH 01/11] config-batch: basic boilerplate of new builtin 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
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=c4dab0609613bc5d43bce705dca2f057674a5d5b.1770214803.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=stolee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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