Skip to content

Commit 84a1d00

Browse files
pks-tgitster
authored andcommitted
builtin/cat-file: rename variable that tracks usage
The usage strings for git-cat-file(1) that we pass to `parse_options()` and `usage_msg_optf()` are stored in a variable called `usage`. This variable shadows the declaration of `usage()`, which we'll want to use in a subsequent commit. Rename the variable to `builtin_catfile_usage`, which is in line with how the variable is typically called in other builtins. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cd8d2c4 commit 84a1d00

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

builtin/cat-file.c

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ int cmd_cat_file(int argc,
941941
int input_nul_terminated = 0;
942942
int nul_terminated = 0;
943943

944-
const char * const usage[] = {
944+
const char * const builtin_catfile_usage[] = {
945945
N_("git cat-file <type> <object>"),
946946
N_("git cat-file (-e | -p) <object>"),
947947
N_("git cat-file (-t | -s) [--allow-unknown-type] <object>"),
@@ -1007,7 +1007,7 @@ int cmd_cat_file(int argc,
10071007

10081008
batch.buffer_output = -1;
10091009

1010-
argc = parse_options(argc, argv, prefix, options, usage, 0);
1010+
argc = parse_options(argc, argv, prefix, options, builtin_catfile_usage, 0);
10111011
opt_cw = (opt == 'c' || opt == 'w');
10121012
opt_epts = (opt == 'e' || opt == 'p' || opt == 't' || opt == 's');
10131013

@@ -1021,28 +1021,28 @@ int cmd_cat_file(int argc,
10211021
/* Option compatibility */
10221022
if (force_path && !opt_cw)
10231023
usage_msg_optf(_("'%s=<%s>' needs '%s' or '%s'"),
1024-
usage, options,
1024+
builtin_catfile_usage, options,
10251025
"--path", _("path|tree-ish"), "--filters",
10261026
"--textconv");
10271027

10281028
/* Option compatibility with batch mode */
10291029
if (batch.enabled)
10301030
;
10311031
else if (batch.follow_symlinks)
1032-
usage_msg_optf(_("'%s' requires a batch mode"), usage, options,
1033-
"--follow-symlinks");
1032+
usage_msg_optf(_("'%s' requires a batch mode"), builtin_catfile_usage,
1033+
options, "--follow-symlinks");
10341034
else if (batch.buffer_output >= 0)
1035-
usage_msg_optf(_("'%s' requires a batch mode"), usage, options,
1036-
"--buffer");
1035+
usage_msg_optf(_("'%s' requires a batch mode"), builtin_catfile_usage,
1036+
options, "--buffer");
10371037
else if (batch.all_objects)
1038-
usage_msg_optf(_("'%s' requires a batch mode"), usage, options,
1039-
"--batch-all-objects");
1038+
usage_msg_optf(_("'%s' requires a batch mode"), builtin_catfile_usage,
1039+
options, "--batch-all-objects");
10401040
else if (input_nul_terminated)
1041-
usage_msg_optf(_("'%s' requires a batch mode"), usage, options,
1042-
"-z");
1041+
usage_msg_optf(_("'%s' requires a batch mode"), builtin_catfile_usage,
1042+
options, "-z");
10431043
else if (nul_terminated)
1044-
usage_msg_optf(_("'%s' requires a batch mode"), usage, options,
1045-
"-Z");
1044+
usage_msg_optf(_("'%s' requires a batch mode"), builtin_catfile_usage,
1045+
options, "-Z");
10461046

10471047
batch.input_delim = batch.output_delim = '\n';
10481048
if (input_nul_terminated)
@@ -1063,33 +1063,36 @@ int cmd_cat_file(int argc,
10631063
batch.transform_mode = opt;
10641064
else if (opt && opt != 'b')
10651065
usage_msg_optf(_("'-%c' is incompatible with batch mode"),
1066-
usage, options, opt);
1066+
builtin_catfile_usage, options, opt);
10671067
else if (argc)
1068-
usage_msg_opt(_("batch modes take no arguments"), usage,
1069-
options);
1068+
usage_msg_opt(_("batch modes take no arguments"),
1069+
builtin_catfile_usage, options);
10701070

10711071
return batch_objects(&batch);
10721072
}
10731073

10741074
if (opt) {
10751075
if (!argc && opt == 'c')
10761076
usage_msg_optf(_("<rev> required with '%s'"),
1077-
usage, options, "--textconv");
1077+
builtin_catfile_usage, options,
1078+
"--textconv");
10781079
else if (!argc && opt == 'w')
10791080
usage_msg_optf(_("<rev> required with '%s'"),
1080-
usage, options, "--filters");
1081+
builtin_catfile_usage, options,
1082+
"--filters");
10811083
else if (!argc && opt_epts)
10821084
usage_msg_optf(_("<object> required with '-%c'"),
1083-
usage, options, opt);
1085+
builtin_catfile_usage, options, opt);
10841086
else if (argc == 1)
10851087
obj_name = argv[0];
10861088
else
1087-
usage_msg_opt(_("too many arguments"), usage, options);
1089+
usage_msg_opt(_("too many arguments"), builtin_catfile_usage,
1090+
options);
10881091
} else if (!argc) {
1089-
usage_with_options(usage, options);
1092+
usage_with_options(builtin_catfile_usage, options);
10901093
} else if (argc != 2) {
10911094
usage_msg_optf(_("only two arguments allowed in <type> <object> mode, not %d"),
1092-
usage, options, argc);
1095+
builtin_catfile_usage, options, argc);
10931096
} else if (argc) {
10941097
exp_type = argv[0];
10951098
obj_name = argv[1];

0 commit comments

Comments
 (0)