]> git.ipfire.org Git - thirdparty/git.git/commitdiff
repo: declare the repo command
authorLucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Sat, 16 Aug 2025 22:45:59 +0000 (19:45 -0300)
committerJunio C Hamano <gitster@pobox.com>
Sun, 17 Aug 2025 16:13:39 +0000 (09:13 -0700)
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>
.gitignore
Documentation/git-repo.adoc [new file with mode: 0644]
Documentation/meson.build
Makefile
builtin.h
builtin/repo.c [new file with mode: 0644]
command-list.txt
git.c
meson.build

index 04c444404e4ba835659089c0fdafc68bb9fccc93..1803023427af81f31c17f83231078e3ddcf6fe0a 100644 (file)
 /git-repack
 /git-replace
 /git-replay
+/git-repo
 /git-request-pull
 /git-rerere
 /git-reset
diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
new file mode 100644 (file)
index 0000000..68c706f
--- /dev/null
@@ -0,0 +1,32 @@
+git-repo(1)
+===========
+
+NAME
+----
+git-repo - Retrieve information about the repository
+
+SYNOPSIS
+--------
+[synopsis]
+git repo info [<key>...]
+
+DESCRIPTION
+-----------
+Retrieve information about the repository.
+
+THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
+
+COMMANDS
+--------
+`info [<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).
+
+SEE ALSO
+--------
+linkgit:git-rev-parse[1]
+
+GIT
+---
+Part of the linkgit:git[1] suite
index 1433acfd310e7b1567bd3d9180467bc5fee58511..30e858db3fd09e83b5c8560caf735fd81cc28c38 100644 (file)
@@ -116,6 +116,7 @@ manpages = {
   'git-repack.adoc' : 1,
   'git-replace.adoc' : 1,
   'git-replay.adoc' : 1,
+  'git-repo.adoc' : 1,
   'git-request-pull.adoc' : 1,
   'git-rerere.adoc' : 1,
   'git-reset.adoc' : 1,
index 70d1543b6b8688bf348f03f5e9cc1690fe547249..4c3fa064854c3afb823af0df3c48b65f1f4e1605 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1308,6 +1308,7 @@ BUILTIN_OBJS += builtin/remote.o
 BUILTIN_OBJS += builtin/repack.o
 BUILTIN_OBJS += builtin/replace.o
 BUILTIN_OBJS += builtin/replay.o
+BUILTIN_OBJS += builtin/repo.o
 BUILTIN_OBJS += builtin/rerere.o
 BUILTIN_OBJS += builtin/reset.o
 BUILTIN_OBJS += builtin/rev-list.o
index bff13e3069b4affc66f669d2d2c35c124fd86919..e6458e6fb9a21a5d7f5232a3b833563da02712cd 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -216,6 +216,7 @@ int cmd_remote_ext(int argc, const char **argv, const char *prefix, struct repos
 int cmd_remote_fd(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_repack(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_replay(int argc, const char **argv, const char *prefix, struct repository *repo);
+int cmd_repo(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_rerere(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_reset(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_restore(int argc, const char **argv, const char *prefix, struct repository *repo);
diff --git a/builtin/repo.c b/builtin/repo.c
new file mode 100644 (file)
index 0000000..fd2a9b4
--- /dev/null
@@ -0,0 +1,27 @@
+#include "builtin.h"
+#include "parse-options.h"
+
+static const char *const repo_usage[] = {
+       "git repo info [<key>...]",
+       NULL
+};
+
+static int repo_info(int argc UNUSED, const char **argv UNUSED,
+                    const char *prefix UNUSED, struct repository *repo UNUSED)
+{
+       return 0;
+}
+
+int cmd_repo(int argc, const char **argv, const char *prefix,
+            struct repository *repo)
+{
+       parse_opt_subcommand_fn *fn = NULL;
+       struct option options[] = {
+               OPT_SUBCOMMAND("info", &fn, repo_info),
+               OPT_END()
+       };
+
+       argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
+
+       return fn(argc, argv, prefix, repo);
+}
index b7ade3ab9f3319264bf08af2aa2ce073c1b337c7..1b0bdee00dd4f111959727c8698060406cb6f14e 100644 (file)
@@ -164,6 +164,7 @@ git-remote                              ancillarymanipulators           complete
 git-repack                              ancillarymanipulators           complete
 git-replace                             ancillarymanipulators           complete
 git-replay                              plumbingmanipulators
+git-repo                                plumbinginterrogators
 git-request-pull                        foreignscminterface             complete
 git-rerere                              ancillaryinterrogators
 git-reset                               mainporcelain           history
diff --git a/git.c b/git.c
index 77c435952232f60435bfd96697e304ee1761f565..63dfb65103aad0b7eee63da95388aaa0c4ac784a 100644 (file)
--- a/git.c
+++ b/git.c
@@ -611,6 +611,7 @@ static struct cmd_struct commands[] = {
        { "repack", cmd_repack, RUN_SETUP },
        { "replace", cmd_replace, RUN_SETUP },
        { "replay", cmd_replay, RUN_SETUP },
+       { "repo", cmd_repo, RUN_SETUP },
        { "rerere", cmd_rerere, RUN_SETUP },
        { "reset", cmd_reset, RUN_SETUP },
        { "restore", cmd_restore, RUN_SETUP | NEED_WORK_TREE },
index 596f5ac7110ebf608ced79dc335226d10a09b4a8..2758670d36298034c9481f9cdc00fcfccdd514a7 100644 (file)
@@ -645,6 +645,7 @@ builtin_sources = [
   'builtin/repack.c',
   'builtin/replace.c',
   'builtin/replay.c',
+  'builtin/repo.c',
   'builtin/rerere.c',
   'builtin/reset.c',
   'builtin/rev-list.c',