Skip to content

Commit 62be64a

Browse files
committed
Merge branch 'mk/repo-help-strings' into jch
"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
2 parents b057f98 + abd728c commit 62be64a

3 files changed

Lines changed: 34 additions & 6 deletions

File tree

builtin/repo.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,27 @@
2020
#include "tree-walk.h"
2121
#include "utf8.h"
2222

23+
#define REPO_INFO_USAGE \
24+
"git repo info [--format=(lines|nul) | -z] [--all | <key>...]", \
25+
"git repo info --keys [--format=(lines|nul) | -z]"
26+
27+
#define REPO_STRUCTURE_USAGE \
28+
"git repo structure [--format=(table|lines|nul) | -z]"
29+
2330
static const char *const repo_usage[] = {
24-
"git repo info [--format=(lines|nul) | -z] [--all | <key>...]",
25-
"git repo info --keys [--format=(lines|nul) | -z]",
26-
"git repo structure [--format=(table|lines|nul) | -z]",
27-
NULL
31+
REPO_INFO_USAGE,
32+
REPO_STRUCTURE_USAGE,
33+
NULL,
34+
};
35+
36+
static const char *const repo_info_usage[] = {
37+
REPO_INFO_USAGE,
38+
NULL,
39+
};
40+
41+
static const char *const repo_structure_usage[] = {
42+
REPO_STRUCTURE_USAGE,
43+
NULL,
2844
};
2945

3046
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,
214230
OPT_END()
215231
};
216232

217-
argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
233+
argc = parse_options(argc, argv, prefix, options, repo_info_usage, 0);
218234

219235
if (show_keys && (all_keys || argc))
220236
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,
879895
OPT_END()
880896
};
881897

882-
argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
898+
argc = parse_options(argc, argv, prefix, options, repo_structure_usage, 0);
883899
if (argc)
884900
usage(_("too many arguments"));
885901

t/t1900-repo-info.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,10 @@ test_expect_success 'git repo info --keys uses lines as its default output forma
149149
test_cmp expect actual
150150
'
151151

152+
test_expect_success 'git repo info -h shows only repo info usage' '
153+
test_must_fail git repo info -h >actual &&
154+
test_grep "git repo info" actual &&
155+
test_grep ! "git repo structure" actual
156+
'
157+
152158
test_done

t/t1901-repo-structure.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,10 @@ test_expect_success 'progress meter option' '
224224
)
225225
'
226226

227+
test_expect_success 'git repo structure -h shows only repo structure usage' '
228+
test_must_fail git repo structure -h >actual &&
229+
test_grep "git repo structure" actual &&
230+
test_grep ! "git repo info" actual
231+
'
232+
227233
test_done

0 commit comments

Comments
 (0)