mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
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>
This commit is contained in:
parent
38062e73e0
commit
a2c75526d2
|
@ -24,7 +24,7 @@ struct batch_options {
|
|||
int buffer_output;
|
||||
int all_objects;
|
||||
int unordered;
|
||||
int cmdmode; /* may be 'w' or 'c' for --filters or --textconv */
|
||||
int transform_mode; /* may be 'w' or 'c' for --filters or --textconv */
|
||||
const char *format;
|
||||
};
|
||||
|
||||
|
@ -302,19 +302,19 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
|
|||
if (data->type == OBJ_BLOB) {
|
||||
if (opt->buffer_output)
|
||||
fflush(stdout);
|
||||
if (opt->cmdmode) {
|
||||
if (opt->transform_mode) {
|
||||
char *contents;
|
||||
unsigned long size;
|
||||
|
||||
if (!data->rest)
|
||||
die("missing path for '%s'", oid_to_hex(oid));
|
||||
|
||||
if (opt->cmdmode == 'w') {
|
||||
if (opt->transform_mode == 'w') {
|
||||
if (filter_object(data->rest, 0100644, oid,
|
||||
&contents, &size))
|
||||
die("could not convert '%s' %s",
|
||||
oid_to_hex(oid), data->rest);
|
||||
} else if (opt->cmdmode == 'c') {
|
||||
} else if (opt->transform_mode == 'c') {
|
||||
enum object_type type;
|
||||
if (!textconv_object(the_repository,
|
||||
data->rest, 0100644, oid,
|
||||
|
@ -326,7 +326,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
|
|||
die("could not convert '%s' %s",
|
||||
oid_to_hex(oid), data->rest);
|
||||
} else
|
||||
BUG("invalid cmdmode: %c", opt->cmdmode);
|
||||
BUG("invalid transform_mode: %c", opt->transform_mode);
|
||||
batch_write(opt, contents, size);
|
||||
free(contents);
|
||||
} else {
|
||||
|
@ -529,7 +529,7 @@ static int batch_objects(struct batch_options *opt)
|
|||
strbuf_expand(&output, opt->format, expand_format, &data);
|
||||
data.mark_query = 0;
|
||||
strbuf_release(&output);
|
||||
if (opt->cmdmode)
|
||||
if (opt->transform_mode)
|
||||
data.split_on_whitespace = 1;
|
||||
|
||||
/*
|
||||
|
@ -742,7 +742,7 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
|
|||
/* Return early if we're in batch mode? */
|
||||
if (batch.enabled) {
|
||||
if (opt_cw)
|
||||
batch.cmdmode = opt;
|
||||
batch.transform_mode = opt;
|
||||
else if (opt && opt != 'b')
|
||||
usage_msg_optf(_("'-%c' is incompatible with batch mode"),
|
||||
usage, options, opt);
|
||||
|
|
Loading…
Reference in a new issue