diff options
| author | Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> | 2025-08-16 19:46:03 -0300 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-08-17 09:13:41 -0700 |
| commit | a81224d12818e94a2e3c257ee2e5b0f3169da12b (patch) | |
| tree | 29a6a23f4ab3c71fe94d8daaf37cc504b5b795ba /Documentation/git-repo.adoc | |
| parent | repo: add the field layout.shallow (diff) | |
| download | git-a81224d12818e94a2e3c257ee2e5b0f3169da12b.tar.gz git-a81224d12818e94a2e3c257ee2e5b0f3169da12b.zip | |
repo: add the --format flag
Add the --format flag to git-repo-info. By using this flag, the users
can choose the format for obtaining the data they requested.
Given that this command can be used for generating input for other
applications and for being read by end users, it requires at least two
formats: one for being read by humans and other for being read by
machines. Some other Git commands also have two output formats, notably
git-config which was the inspiration for the two formats that were
chosen here:
- keyvalue, where the retrieved data is printed one per line, using =
for delimiting the key and the value. This is the default format,
targeted for end users.
- nul, where the retrieved data is separated by NUL characters, using
the newline character for delimiting the key and the value. This
format is targeted for being read by machines.
Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Justin Tobler <jltobler@gmail.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Mentored-by: Karthik Nayak <karthik.188@gmail.com>
Mentored-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/git-repo.adoc')
| -rw-r--r-- | Documentation/git-repo.adoc | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc index 01b7f9c95e..2870828d93 100644 --- a/Documentation/git-repo.adoc +++ b/Documentation/git-repo.adoc @@ -8,7 +8,7 @@ git-repo - Retrieve information about the repository SYNOPSIS -------- [synopsis] -git repo info [<key>...] +git repo info [--format=(keyvalue|nul)] [<key>...] DESCRIPTION ----------- @@ -18,7 +18,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE. COMMANDS -------- -`info [<key>...]`:: +`info [--format=(keyvalue|nul)] [<key>...]`:: Retrieve metadata-related information about the current repository. Only the requested data will be returned based on their keys (see "INFO KEYS" section below). @@ -26,14 +26,23 @@ COMMANDS The values are returned in the same order in which their respective keys were requested. + -The output format consists of key-value pairs one per line using the `=` -character as the delimiter between the key and the value. Values containing -"unusual" characters are quoted as explained for the configuration variable -`core.quotePath` (see linkgit:git-config[1]). +The output format can be chosen through the flag `--format`. Two formats are +supported: ++ +`keyvalue`::: + output key-value pairs one per line using the `=` character as + the delimiter between the key and the value. Values containing "unusual" + characters are quoted as explained for the configuration variable + `core.quotePath` (see linkgit:git-config[1]). This is the default. + +`nul`::: + similar to `keyvalue`, but using a newline character as the delimiter + between the key and the value and using a NUL character after each value. + This format is better suited for being parsed by another applications than + `keyvalue`. Unlike in the `keyvalue` format, the values are never quoted. INFO KEYS --------- - In order to obtain a set of values from `git repo info`, you should provide the keys that identify them. Here's a list of the available keys and the values that they return: @@ -49,6 +58,23 @@ values that they return: + include::ref-storage-format.adoc[] +EXAMPLES +-------- + +* Retrieves the reference format of the current repository: ++ +------------ +git repo info references.format +------------ ++ + +* Retrieves whether the current repository is bare and whether it is shallow +using the `nul` format: ++ +------------ +git repo info --format=nul layout.bare layout.shallow +------------ + SEE ALSO -------- linkgit:git-rev-parse[1] |
