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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Apr 2, 2025 at 13:13 UTC
84a1d0039a7d9974d4900d730ba7edeef31b8e43
1 file changed
+25
-22
builtin/cat-file.c
+25
-22
@@ -941,7 +941,7 @@ int cmd_cat_file(int argc,
941
int input_nul_terminated = 0;
942
int nul_terminated = 0;
943
944
- const char * const usage[] = {
944
+ const char * const builtin_catfile_usage[] = {
945
N_("git cat-file <type> <object>"),
946
N_("git cat-file (-e | -p) <object>"),
947
N_("git cat-file (-t | -s) [--allow-unknown-type] <object>"),
@@ -1007,7 +1007,7 @@ int cmd_cat_file(int argc,
1007
1008
batch.buffer_output = -1;
1009
1010
- argc = parse_options(argc, argv, prefix, options, usage, 0);
1010
+ argc = parse_options(argc, argv, prefix, options, builtin_catfile_usage, 0);
1011
opt_cw = (opt == 'c' || opt == 'w');
1012
opt_epts = (opt == 'e' || opt == 'p' || opt == 't' || opt == 's');
1013
@@ -1021,7 +1021,7 @@ int cmd_cat_file(int argc,
1021
/* Option compatibility */
1022
if (force_path && !opt_cw)
1023
usage_msg_optf(_("'%s=<%s>' needs '%s' or '%s'"),
1024
- usage, options,
1024
+ builtin_catfile_usage, options,
1025
"--path", _("path|tree-ish"), "--filters",
1026
"--textconv");
1027
@@ -1029,20 +1029,20 @@ int cmd_cat_file(int argc,
1029
if (batch.enabled)
1030
;
1031
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");
1034
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");
1037
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");
1040
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");
1043
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");
1046
1047
batch.input_delim = batch.output_delim = '\n';
1048
if (input_nul_terminated)
@@ -1063,10 +1063,10 @@ int cmd_cat_file(int argc,
1063
batch.transform_mode = opt;
1064
else if (opt && opt != 'b')
1065
usage_msg_optf(_("'-%c' is incompatible with batch mode"),
1066
- usage, options, opt);
1066
+ builtin_catfile_usage, options, opt);
1067
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);
1070
1071
return batch_objects(&batch);
1072
}
@@ -1074,22 +1074,25 @@ int cmd_cat_file(int argc,
1074
if (opt) {
1075
if (!argc && opt == 'c')
1076
usage_msg_optf(_("<rev> required with '%s'"),
1077
- usage, options, "--textconv");
1077
+ builtin_catfile_usage, options,
1078
+ "--textconv");
1079
else if (!argc && opt == 'w')
1080
usage_msg_optf(_("<rev> required with '%s'"),
1080
- usage, options, "--filters");
1081
+ builtin_catfile_usage, options,
1082
+ "--filters");
1083
else if (!argc && opt_epts)
1084
usage_msg_optf(_("<object> required with '-%c'"),
1083
- usage, options, opt);
1085
+ builtin_catfile_usage, options, opt);
1086
else if (argc == 1)
1087
obj_name = argv[0];
1088
else
1087
- usage_msg_opt(_("too many arguments"), usage, options);
1089
+ usage_msg_opt(_("too many arguments"), builtin_catfile_usage,
1090
+ options);
1091
} else if (!argc) {
1089
- usage_with_options(usage, options);
1092
+ usage_with_options(builtin_catfile_usage, options);
1093
} else if (argc != 2) {
1094
usage_msg_optf(_("only two arguments allowed in <type> <object> mode, not %d"),
1092
- usage, options, argc);
1095
+ builtin_catfile_usage, options, argc);
1096
} else if (argc) {
1097
exp_type = argv[0];
1098
obj_name = argv[1];