Skip to content

Commit 3166c58

Browse files
lucasoshirogitster
authored andcommitted
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 <[email protected]> Helped-by: Junio C Hamano <[email protected]> Helped-by: Justin Tobler <[email protected]> Helped-by: Eric Sunshine <[email protected]> Mentored-by: Karthik Nayak <[email protected]> Mentored-by: Patrick Steinhardt <[email protected]> Signed-off-by: Lucas Seiki Oshiro <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 16bd9f2 commit 3166c58

File tree

9 files changed

+66
-0
lines changed

9 files changed

+66
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
/git-repack
140140
/git-replace
141141
/git-replay
142+
/git-repo
142143
/git-request-pull
143144
/git-rerere
144145
/git-reset

Documentation/git-repo.adoc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ manpages = {
116116
'git-repack.adoc' : 1,
117117
'git-replace.adoc' : 1,
118118
'git-replay.adoc' : 1,
119+
'git-repo.adoc' : 1,
119120
'git-request-pull.adoc' : 1,
120121
'git-rerere.adoc' : 1,
121122
'git-reset.adoc' : 1,

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,7 @@ BUILTIN_OBJS += builtin/remote.o
13081308
BUILTIN_OBJS += builtin/repack.o
13091309
BUILTIN_OBJS += builtin/replace.o
13101310
BUILTIN_OBJS += builtin/replay.o
1311+
BUILTIN_OBJS += builtin/repo.o
13111312
BUILTIN_OBJS += builtin/rerere.o
13121313
BUILTIN_OBJS += builtin/reset.o
13131314
BUILTIN_OBJS += builtin/rev-list.o

builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ int cmd_remote_ext(int argc, const char **argv, const char *prefix, struct repos
216216
int cmd_remote_fd(int argc, const char **argv, const char *prefix, struct repository *repo);
217217
int cmd_repack(int argc, const char **argv, const char *prefix, struct repository *repo);
218218
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);
219220
int cmd_rerere(int argc, const char **argv, const char *prefix, struct repository *repo);
220221
int cmd_reset(int argc, const char **argv, const char *prefix, struct repository *repo);
221222
int cmd_restore(int argc, const char **argv, const char *prefix, struct repository *repo);

builtin/repo.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ git-remote ancillarymanipulators complete
164164
git-repack ancillarymanipulators complete
165165
git-replace ancillarymanipulators complete
166166
git-replay plumbingmanipulators
167+
git-repo plumbinginterrogators
167168
git-request-pull foreignscminterface complete
168169
git-rerere ancillaryinterrogators
169170
git-reset mainporcelain history

git.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ static struct cmd_struct commands[] = {
611611
{ "repack", cmd_repack, RUN_SETUP },
612612
{ "replace", cmd_replace, RUN_SETUP },
613613
{ "replay", cmd_replay, RUN_SETUP },
614+
{ "repo", cmd_repo, RUN_SETUP },
614615
{ "rerere", cmd_rerere, RUN_SETUP },
615616
{ "reset", cmd_reset, RUN_SETUP },
616617
{ "restore", cmd_restore, RUN_SETUP | NEED_WORK_TREE },

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ builtin_sources = [
645645
'builtin/repack.c',
646646
'builtin/replace.c',
647647
'builtin/replay.c',
648+
'builtin/repo.c',
648649
'builtin/rerere.c',
649650
'builtin/reset.c',
650651
'builtin/rev-list.c',

0 commit comments

Comments
 (0)