[GSoC RFC PATCH v3 0/5] repo-info: add new command for retrieving repository info
- From
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
- Date
- Jul 6, 2025, 23:19 UTC
- Message-ID
- <20250706231938.16113-1-lucasseikioshiro@gmail.com>
- In-Reply-To
- <20250610152117.14826-1-lucasseikioshiro@gmail.com>
Hi!
This is the third version of the patchset introducing the new Git command called `repo-info`, which will return repository information currently stored under git-rev-parse using machine-readable formats.
The main changes since v2 are:
- Documentation for git-repo-info has been added. - The `--allow-empty` flag was removed. In this version, repo-info no longer returns a default set of data when called without parameters. However, an `--all` flag is planned for a future version. - The `plaintext` format was replaced by a null-terminated format, following the syntax of `git config --list -z`.
Here is the rangediff from v2 to v3:
1: 102b5ce90a ! 1: 3f9ef00413 repo-info: declare the repo-info command
@@ Metadata
## Commit message ##
repo-info: declare the repo-info command - Create a new Git subcommand called repo-info. `git repo-info` will query
- metadata from the current repository and outputs it as JSON or plaintext.
+ Currently, `git rev-parse` covers a wide range of functionality not
+ directly related to parsing revisions, as its name says. Over time,
+ many features like parsing datestrings, options, paths, and others
+ were added to it because there wasn't a more appropriated command
+ to place them.
+
+ Create a new Git subcommand called `repo-info`. `git repo-info` will
+ bring the functionality of retrieving repository-related information
+ currently returned by `rev-parse`, displaying them in
+ machine-readable formats (JSON or a null-terminated format).Also add entries for this new command in:
- - the build files (Makefile and meson.build)
+ - the build files (Makefile, meson.build, Documentation/meson.build)
- builtin.h
- git.c
- .gitignore
+ - command-list.txt
+ - Documentation - In option parsing, use PARSE_OPT_KEEP_UNKNOWN_OPT to allow the users
- specify after the flags the information that they want to retrieve.
-
+ Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
+ Helped-by: Junio C Hamano <gitster@pobox.com>
Mentored-by: Karthik Nayak <karthik.188@gmail.com>
- Mentored-by Patrick Steinhardt <ps@pks.im>
+ Mentored-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> ## .gitignore ##
@@ .gitignore
/git-rerere
/git-reset + ## Documentation/git-repo-info.adoc (new) ##
+@@
++git-repo-info(1)
++================
++
++NAME
++----
++git-repo-info - Retrieve information about a repository
++
++SYNOPSIS
++--------
++[synopsis]
++git repo-info
++
++DESCRIPTION
++-----------
++Retrieve information about the current repository in a machine-readable format.
++
++`git repo-info` will be the primary tool to query repository-specific
++information, which currently can also be done by calling `git rev-parse` (see
++linkgit:git-rev-parse[1]). `git repo-info` doesn't query information unrelated
++to the current repository or that is already retrieved by a specialized command,
++for example, `git config` (see linkgit:git-config[1]) or `git var` (see
++linkgit:git-var[1]).
++
++THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
++
++OPTIONS
++-------
++
++`<key>`::
++Key of the value that will be retrieved. It should be in the format
++`<category>.<field>`. See the "CATEGORIES AND FIELDS" section below.
++
++CATEGORIES AND FIELDS
++---------------------
++
++The set of data that `git repo-info` can return is divided into
++categories. Each category is composed by one or more fields.
++
++SEE ALSO
++--------
++linkgit:git-rev-parse[1]
++
++GIT
++---
++Part of the linkgit:git[1] suite
+
+ ## Documentation/meson.build ##
+@@ Documentation/meson.build: manpages = {
+ 'git-repack.adoc' : 1,
+ 'git-replace.adoc' : 1,
+ 'git-replay.adoc' : 1,
++ 'git-repo-info.adoc' : 1,
+ 'git-request-pull.adoc' : 1,
+ 'git-rerere.adoc' : 1,
+ 'git-reset.adoc' : 1,
+
## Makefile ##
@@ Makefile: BUILTIN_OBJS += builtin/remote.o
BUILTIN_OBJS += builtin/repack.o
@@ builtin/repo-info.c (new)
+ };
+
+ argc = parse_options(argc, argv, prefix, options, repo_info_usage,
-+ PARSE_OPT_KEEP_UNKNOWN_OPT);
++ 0);
+
+ return 0;
+} + ## command-list.txt ##
+@@ command-list.txt: git-remote ancillarymanipulators complete
+ git-repack ancillarymanipulators complete
+ git-replace ancillarymanipulators complete
+ git-replay plumbingmanipulators
++git-repo-info plumbinginterrogators
+ git-request-pull foreignscminterface complete
+ git-rerere ancillaryinterrogators
+ git-reset mainporcelain history
+
## git.c ##
@@ git.c: static struct cmd_struct commands[] = {
{ "repack", cmd_repack, RUN_SETUP },
2: 1cc1184663 < -: ---------- repo-info: add the --format flag
3: a329825387 < -: ---------- repo-info: add plaintext as an output format
4: 3b6c27b68d < -: ---------- repo-info: add the --allow-empty flag
5: 4b1e99cac4 < -: ---------- repo-info: add the field references.format
6: 0cd72e5ebf < -: ---------- repo-info: add field layout.bare
7: 274dfbde86 < -: ---------- repo-info: add field layout.shallow
-: ---------- > 2: 33c3d5e665 repo-info: add the --format flag
-: ---------- > 3: e6331b18d4 repo-info: add the field references.format
-: ---------- > 4: 6a6825c4df repo-info: add field layout.bare
-: ---------- > 5: 938be682d2 repo-info: add field layout.shallowLucas Seiki Oshiro (5): repo-info: declare the repo-info command repo-info: add the --format flag repo-info: add the field references.format repo-info: add field layout.bare repo-info: add field layout.shallow
.gitignore | 1 + Documentation/git-repo-info.adoc | 84 ++++++++++++ Documentation/meson.build | 1 + Makefile | 1 + builtin.h | 1 + builtin/repo-info.c | 229 +++++++++++++++++++++++++++++++ command-list.txt | 1 + git.c | 1 + meson.build | 1 + t/meson.build | 1 + t/t1900-repo-info.sh | 84 ++++++++++++ 11 files changed, 405 insertions(+) create mode 100644 Documentation/git-repo-info.adoc create mode 100644 builtin/repo-info.c create mode 100755 t/t1900-repo-info.sh
-- 2.39.5 (Apple Git-154)