ref-filter.h: add max_count and omit_empty to ref_format
Add an internal 'array_opts' struct to 'struct ref_format' containing formatting options that pertain to the formatting of an entire ref array: 'max_count' and 'omit_empty'. These values are specified by the '--count' and '--omit-empty' options, respectively, to 'for-each-ref'/'tag'/'branch'. Storing these values in the 'ref_format' will simplify the consolidation of ref array formatting logic across builtins in later patches. Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
56d26ade97
commit
9d4fcfe1ff
@ -45,7 +45,6 @@ static const char *head;
|
||||
static struct object_id head_oid;
|
||||
static int recurse_submodules = 0;
|
||||
static int submodule_propagate_branches = 0;
|
||||
static int omit_empty = 0;
|
||||
|
||||
static int branch_use_color = -1;
|
||||
static char branch_colors[][COLOR_MAXLEN] = {
|
||||
@ -480,7 +479,7 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
|
||||
string_list_append(output, out.buf);
|
||||
} else {
|
||||
fwrite(out.buf, 1, out.len, stdout);
|
||||
if (out.len || !omit_empty)
|
||||
if (out.len || !format->array_opts.omit_empty)
|
||||
putchar('\n');
|
||||
}
|
||||
}
|
||||
@ -737,7 +736,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
|
||||
OPT_BIT('D', NULL, &delete, N_("delete branch (even if not merged)"), 2),
|
||||
OPT_BIT('m', "move", &rename, N_("move/rename a branch and its reflog"), 1),
|
||||
OPT_BIT('M', NULL, &rename, N_("move/rename a branch, even if target exists"), 2),
|
||||
OPT_BOOL(0, "omit-empty", &omit_empty,
|
||||
OPT_BOOL(0, "omit-empty", &format.array_opts.omit_empty,
|
||||
N_("do not output a newline after empty formatted refs")),
|
||||
OPT_BIT('c', "copy", ©, N_("copy a branch and its reflog"), 1),
|
||||
OPT_BIT('C', NULL, ©, N_("copy a branch, even if target exists"), 2),
|
||||
|
||||
Reference in New Issue
Block a user