repo: declare the repo command

Currently, `git rev-parse` covers a wide range of functionality not directly related to parsing revisions, as its name suggests. Over time, many features like parsing datestrings, options, paths, and others were added to it because there wasn't a more appropriate command to place them. Create a new Git command called `repo`. `git repo` will be the main command for obtaining the information about a repository (such as metadata and metrics). Also declare a subcommand for `repo` called `info`. `git repo info` will bring the functionality of retrieving repository-related information currently returned by `rev-parse`. Add the required documentation and build changes to enable usage of this subcommand. 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>

Lucas Seiki Oshiro committed Aug 16, 2025 at 19:45 UTC ab94bb80002a85b31124f9ece8ba3843f93f063c
9 files changed +66
.gitignore
+1
@@ -139,6 +139,7 @@
139 /git-repack
140 /git-replace
141 /git-replay
142 +/git-repo
143 /git-request-pull
144 /git-rerere
145 /git-reset
Documentation/git-repo.adoc new
+32
@@ -0,0 +1,32 @@
1 +git-repo(1)
2 +===========
3 +
4 +NAME
5 +----
6 +git-repo - Retrieve information about the repository
7 +
8 +SYNOPSIS
9 +--------
10 +[synopsis]
11 +git repo info [<key>...]
12 +
13 +DESCRIPTION
14 +-----------
15 +Retrieve information about the repository.
16 +
17 +THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
18 +
19 +COMMANDS
20 +--------
21 +`info [<key>...]`::
22 + Retrieve metadata-related information about the current repository. Only
23 + the requested data will be returned based on their keys (see "INFO KEYS"
24 + section below).
25 +
26 +SEE ALSO
27 +--------
28 +linkgit:git-rev-parse[1]
29 +
30 +GIT
31 +---
32 +Part of the linkgit:git[1] suite
Documentation/meson.build
+1
@@ -116,6 +116,7 @@ manpages = {
116 'git-repack.adoc' : 1,
117 'git-replace.adoc' : 1,
118 'git-replay.adoc' : 1,
119 + 'git-repo.adoc' : 1,
120 'git-request-pull.adoc' : 1,
121 'git-rerere.adoc' : 1,
122 'git-reset.adoc' : 1,
Makefile
+1
@@ -1308,6 +1308,7 @@ BUILTIN_OBJS += builtin/remote.o
1308 BUILTIN_OBJS += builtin/repack.o
1309 BUILTIN_OBJS += builtin/replace.o
1310 BUILTIN_OBJS += builtin/replay.o
1311 +BUILTIN_OBJS += builtin/repo.o
1312 BUILTIN_OBJS += builtin/rerere.o
1313 BUILTIN_OBJS += builtin/reset.o
1314 BUILTIN_OBJS += builtin/rev-list.o
builtin.h
+1
@@ -216,6 +216,7 @@ int cmd_remote_ext(int argc, const char **argv, const char *prefix, struct repos
216 int cmd_remote_fd(int argc, const char **argv, const char *prefix, struct repository *repo);
217 int cmd_repack(int argc, const char **argv, const char *prefix, struct repository *repo);
218 int cmd_replay(int argc, const char **argv, const char *prefix, struct repository *repo);
219 +int cmd_repo(int argc, const char **argv, const char *prefix, struct repository *repo);
220 int cmd_rerere(int argc, const char **argv, const char *prefix, struct repository *repo);
221 int cmd_reset(int argc, const char **argv, const char *prefix, struct repository *repo);
222 int cmd_restore(int argc, const char **argv, const char *prefix, struct repository *repo);
builtin/repo.c new
+27
@@ -0,0 +1,27 @@
1 +#include "builtin.h"
2 +#include "parse-options.h"
3 +
4 +static const char *const repo_usage[] = {
5 + "git repo info [<key>...]",
6 + NULL
7 +};
8 +
9 +static int repo_info(int argc UNUSED, const char **argv UNUSED,
10 + const char *prefix UNUSED, struct repository *repo UNUSED)
11 +{
12 + return 0;
13 +}
14 +
15 +int cmd_repo(int argc, const char **argv, const char *prefix,
16 + struct repository *repo)
17 +{
18 + parse_opt_subcommand_fn *fn = NULL;
19 + struct option options[] = {
20 + OPT_SUBCOMMAND("info", &fn, repo_info),
21 + OPT_END()
22 + };
23 +
24 + argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
25 +
26 + return fn(argc, argv, prefix, repo);
27 +}
command-list.txt
+1
@@ -164,6 +164,7 @@ git-remote ancillarymanipulators complete
164 git-repack ancillarymanipulators complete
165 git-replace ancillarymanipulators complete
166 git-replay plumbingmanipulators
167 +git-repo plumbinginterrogators
168 git-request-pull foreignscminterface complete
169 git-rerere ancillaryinterrogators
170 git-reset mainporcelain history
git.c
+1
@@ -611,6 +611,7 @@ static struct cmd_struct commands[] = {
611 { "repack", cmd_repack, RUN_SETUP },
612 { "replace", cmd_replace, RUN_SETUP },
613 { "replay", cmd_replay, RUN_SETUP },
614 + { "repo", cmd_repo, RUN_SETUP },
615 { "rerere", cmd_rerere, RUN_SETUP },
616 { "reset", cmd_reset, RUN_SETUP },
617 { "restore", cmd_restore, RUN_SETUP | NEED_WORK_TREE },
meson.build
+1
@@ -645,6 +645,7 @@ builtin_sources = [
645 'builtin/repack.c',
646 'builtin/replace.c',
647 'builtin/replay.c',
648 + 'builtin/repo.c',
649 'builtin/rerere.c',
650 'builtin/reset.c',
651 'builtin/rev-list.c',