Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
/git-commit-graph
/git-commit-tree
/git-config
/git-config-batch
/git-count-objects
/git-credential
/git-credential-cache
Expand Down
109 changes: 109 additions & 0 deletions Documentation/git-config-batch.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
git-config-batch(1)
===================

NAME
----
git-config-batch - Get and set options using machine-parseable interface


SYNOPSIS
--------
[verse]
'git config-batch' <options>

DESCRIPTION
-----------
Tools frequently need to change their behavior based on values stored in
Git's configuration files. These files may have complicated conditions
for including extra files, so it is difficult to produce an independent
parser. To avoid executing multiple processes to discover or modify
multiple configuration values, the `git config-batch` command allows a
single process to handle multiple requests using a machine-parseable
interface across `stdin` and `stdout`.

PROTOCOL
--------
By default, the protocol uses line feeds (`LF`) to signal the end of a
command over `stdin` or a response over `stdout`.

The protocol will be extended in the future, and consumers should be
resilient to older Git versions not understanding the latest command
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
------------

These are the commands that are currently understood:

`help` version 1::
The `help` command lists the currently-available commands in
this version of Git. The output is multi-line, but the first
line provides the count of possible commands via `help count <N>`.
The next `<N>` lines are of the form `help <command> <version>`
to state that this Git version supports that `<command>` at
version `<version>`. Note that the same command may have multiple
available versions.
+
Here is the currentl output of the help text at the latest version:
+
------------
help count 2
help help 1
help get 1
------------

`get` version 1::
The `get` command searches the config key-value pairs within a
given `<scope>` for values that match the fixed `<key>` and
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> regex <value-pattern>
get 1 <scope> <key> fixed-value <value>
------------
+
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 `regex` is specified, then `<value-pattern>`
is interpreted as a regular expression for matching against stored
values, similar to specifying a value to `get config --get <key> <value>`.
If `fixed-value` is specified, then `<value>` is checked for an exact
match against the key-value pairs, simmilar to `git config --get <key>
--fixed-value <value>`.
+
At mmost one key-value pair is returned, that being the last key-value
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 found <key> <scope> <value>
------------
+
If no matching key-value pair is found, then the following output is
given:
+
------------
get missing <key> [<value-pattern>|<value>]
------------
+
where `<value-pattern>` or `<value>` is only supplied if provided in
the command.

SEE ALSO
--------
linkgit:git-config[1]

GIT
---
Part of the linkgit:git[1] suite
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@
*
* . 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 an entry for `git-foo` to `command-list.txt`.
Expand Down Expand Up @@ -167,6 +171,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);
Expand Down
Loading
Loading