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. Also add entries for this new command in: - the build files (Makefile and meson.build) - builtin.h - git.c - .gitignore Mentored-by: Karthik Nayak <karthik.188@xxxxxxxxx> Mentored-by Patrick Steinhardt <ps@xxxxxx> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@xxxxxxxxx> --- .gitignore | 1 + Makefile | 1 + builtin.h | 1 + builtin/repo-info.c | 22 ++++++++++++++++++++++ git.c | 1 + meson.build | 1 + 6 files changed, 27 insertions(+) create mode 100644 builtin/repo-info.c diff --git a/.gitignore b/.gitignore index 04c444404e..b2f3fb0047 100644 --- a/.gitignore +++ b/.gitignore @@ -139,6 +139,7 @@ /git-repack /git-replace /git-replay +/git-repo-info /git-request-pull /git-rerere /git-reset diff --git a/Makefile b/Makefile index 70d1543b6b..50e3a3cbcc 100644 --- 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-info.o BUILTIN_OBJS += builtin/rerere.o BUILTIN_OBJS += builtin/reset.o BUILTIN_OBJS += builtin/rev-list.o diff --git a/builtin.h b/builtin.h index bff13e3069..cc6bc95962 100644 --- 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_info(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-info.c b/builtin/repo-info.c new file mode 100644 index 0000000000..4615b988d8 --- /dev/null +++ b/builtin/repo-info.c @@ -0,0 +1,22 @@ +#include "builtin.h" +#include "parse-options.h" + +int cmd_repo_info( + int argc, + const char **argv, + const char *prefix, + struct repository *repo UNUSED + ) +{ + const char *const repo_info_usage[] = { + "git repo-info", + NULL + }; + struct option options[] = { + OPT_END() + }; + + argc = parse_options(argc, argv, prefix, options, repo_info_usage, 0); + + return 0; +} diff --git a/git.c b/git.c index 7c37872a88..d1774de82f 100644 --- 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-info", cmd_repo_info, RUN_SETUP }, { "rerere", cmd_rerere, RUN_SETUP }, { "reset", cmd_reset, RUN_SETUP }, { "restore", cmd_restore, RUN_SETUP | NEED_WORK_TREE }, diff --git a/meson.build b/meson.build index 7fea4a34d6..06f2f647ba 100644 --- a/meson.build +++ b/meson.build @@ -645,6 +645,7 @@ builtin_sources = [ 'builtin/repack.c', 'builtin/replace.c', 'builtin/replay.c', + 'builtin/repo-info.c', 'builtin/rerere.c', 'builtin/reset.c', 'builtin/rev-list.c', -- 2.39.5 (Apple Git-154)