diff options
| author | Junio C Hamano <gitster@pobox.com> | 2026-04-01 10:28:19 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-04-01 10:28:19 -0700 |
| commit | 9d498801a7a6ed219481361115d385698c66cec9 (patch) | |
| tree | 77f711942d1fc8eb32a3d6edd617604f4de4d97f | |
| parent | 0f85c4c100fb9c72a638c2b2f360e5f9819831a1 (diff) | |
| parent | abd728cdf6ea0164cfd7ede2223f669037ff531d (diff) | |
| download | git-9d498801a7a6ed219481361115d385698c66cec9.tar.xz | |
Merge branch 'mk/repo-help-strings'
"git repo info -h" and "git repo structure -h" limit their help output
to the part that is specific to the subcommand.
* mk/repo-help-strings:
repo: show subcommand-specific help text
repo: factor repo usage strings into shared macros
| -rw-r--r-- | builtin/repo.c | 28 | ||||
| -rwxr-xr-x | t/t1900-repo-info.sh | 6 | ||||
| -rwxr-xr-x | t/t1901-repo-structure.sh | 6 |
3 files changed, 34 insertions, 6 deletions
diff --git a/builtin/repo.c b/builtin/repo.c index 55f9b9095c..71a5c1c29c 100644 --- a/builtin/repo.c +++ b/builtin/repo.c @@ -20,11 +20,27 @@ #include "tree-walk.h" #include "utf8.h" +#define REPO_INFO_USAGE \ + "git repo info [--format=(lines|nul) | -z] [--all | <key>...]", \ + "git repo info --keys [--format=(lines|nul) | -z]" + +#define REPO_STRUCTURE_USAGE \ + "git repo structure [--format=(table|lines|nul) | -z]" + static const char *const repo_usage[] = { - "git repo info [--format=(lines|nul) | -z] [--all | <key>...]", - "git repo info --keys [--format=(lines|nul) | -z]", - "git repo structure [--format=(table|lines|nul) | -z]", - NULL + REPO_INFO_USAGE, + REPO_STRUCTURE_USAGE, + NULL, +}; + +static const char *const repo_info_usage[] = { + REPO_INFO_USAGE, + NULL, +}; + +static const char *const repo_structure_usage[] = { + REPO_STRUCTURE_USAGE, + NULL, }; typedef int get_value_fn(struct repository *repo, struct strbuf *buf); @@ -214,7 +230,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix, OPT_END() }; - argc = parse_options(argc, argv, prefix, options, repo_usage, 0); + argc = parse_options(argc, argv, prefix, options, repo_info_usage, 0); if (show_keys && (all_keys || argc)) die(_("--keys cannot be used with a <key> or --all")); @@ -879,7 +895,7 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix, OPT_END() }; - argc = parse_options(argc, argv, prefix, options, repo_usage, 0); + argc = parse_options(argc, argv, prefix, options, repo_structure_usage, 0); if (argc) usage(_("too many arguments")); diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh index a9eb07abe8..39bb77dda0 100755 --- a/t/t1900-repo-info.sh +++ b/t/t1900-repo-info.sh @@ -149,4 +149,10 @@ test_expect_success 'git repo info --keys uses lines as its default output forma test_cmp expect actual ' +test_expect_success 'git repo info -h shows only repo info usage' ' + test_must_fail git repo info -h >actual && + test_grep "git repo info" actual && + test_grep ! "git repo structure" actual +' + test_done diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh index 98921ce1cb..10050abd70 100755 --- a/t/t1901-repo-structure.sh +++ b/t/t1901-repo-structure.sh @@ -224,4 +224,10 @@ test_expect_success 'progress meter option' ' ) ' +test_expect_success 'git repo structure -h shows only repo structure usage' ' + test_must_fail git repo structure -h >actual && + test_grep "git repo structure" actual && + test_grep ! "git repo info" actual +' + test_done |
