cat-file: rename cmdmode to transform_mode
In the next patch, we will add an enum on the batch_options struct that indicates which type of batch operation will be used: --batch, --batch-check and the soon to be --batch-command that will read commands from stdin. --batch-command mode might get confused with the cmdmode flag. There is value in renaming cmdmode in any case. cmdmode refers to how the result output of the blob will be transformed, either according to --filter or --textconv. So transform_mode is a more descriptive name for the flag. Rename cmdmode to transform_mode in cat-file.c Signed-off-by: John Cai <johncai86@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
John Cai committed
Feb 18, 2022 at 18:23 UTC
a2c75526d21939d5d4e36dbbd6093a5e2c14c39f
1 file changed
+7
-7
builtin/cat-file.c
+7
-7
@@ -24,7 +24,7 @@ struct batch_options {
24
int buffer_output;
25
int all_objects;
26
int unordered;
27
- int cmdmode; /* may be 'w' or 'c' for --filters or --textconv */
27
+ int transform_mode; /* may be 'w' or 'c' for --filters or --textconv */
28
const char *format;
29
};
30
@@ -302,19 +302,19 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
302
if (data->type == OBJ_BLOB) {
303
if (opt->buffer_output)
304
fflush(stdout);
305
- if (opt->cmdmode) {
305
+ if (opt->transform_mode) {
306
char *contents;
307
unsigned long size;
308
309
if (!data->rest)
310
die("missing path for '%s'", oid_to_hex(oid));
311
312
- if (opt->cmdmode == 'w') {
312
+ if (opt->transform_mode == 'w') {
313
if (filter_object(data->rest, 0100644, oid,
314
&contents, &size))
315
die("could not convert '%s' %s",
316
oid_to_hex(oid), data->rest);
317
- } else if (opt->cmdmode == 'c') {
317
+ } else if (opt->transform_mode == 'c') {
318
enum object_type type;
319
if (!textconv_object(the_repository,
320
data->rest, 0100644, oid,
@@ -326,7 +326,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
326
die("could not convert '%s' %s",
327
oid_to_hex(oid), data->rest);
328
} else
329
- BUG("invalid cmdmode: %c", opt->cmdmode);
329
+ BUG("invalid transform_mode: %c", opt->transform_mode);
330
batch_write(opt, contents, size);
331
free(contents);
332
} else {
@@ -529,7 +529,7 @@ static int batch_objects(struct batch_options *opt)
529
strbuf_expand(&output, opt->format, expand_format, &data);
530
data.mark_query = 0;
531
strbuf_release(&output);
532
- if (opt->cmdmode)
532
+ if (opt->transform_mode)
533
data.split_on_whitespace = 1;
534
535
/*
@@ -742,7 +742,7 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
742
/* Return early if we're in batch mode? */
743
if (batch.enabled) {
744
if (opt_cw)
745
- batch.cmdmode = opt;
745
+ batch.transform_mode = opt;
746
else if (opt && opt != 'b')
747
usage_msg_optf(_("'-%c' is incompatible with batch mode"),
748
usage, options, opt);