summaryrefslogtreecommitdiffstats
path: root/builtin/tag.c
diff options
context:
space:
mode:
authorVictoria Dye <vdye@github.com>2023-11-14 20:53:50 +0100
committerJunio C Hamano <gitster@pobox.com>2023-11-16 06:02:59 +0100
commit9d4fcfe1ff5b901f47f8226d078d22370bb955be (patch)
tree80cf79b021c0e117f95659c647973f01d399d22f /builtin/tag.c
parentref-filter.c: really don't sort when using --no-sort (diff)
downloadgit-9d4fcfe1ff5b901f47f8226d078d22370bb955be.tar.xz
git-9d4fcfe1ff5b901f47f8226d078d22370bb955be.zip
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>
Diffstat (limited to 'builtin/tag.c')
-rw-r--r--builtin/tag.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/builtin/tag.c b/builtin/tag.c
index 64f3196cd4..2d599245d4 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -44,7 +44,6 @@ static const char * const git_tag_usage[] = {
static unsigned int colopts;
static int force_sign_annotate;
static int config_sign_tag = -1; /* unspecified */
-static int omit_empty = 0;
static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting,
struct ref_format *format)
@@ -83,7 +82,7 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting,
if (format_ref_array_item(array.items[i], format, &output, &err))
die("%s", err.buf);
fwrite(output.buf, 1, output.len, stdout);
- if (output.len || !omit_empty)
+ if (output.len || !format->array_opts.omit_empty)
putchar('\n');
}
@@ -481,7 +480,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
OPT_WITHOUT(&filter.no_commit, N_("print only tags that don't contain the commit")),
OPT_MERGED(&filter, N_("print only tags that are merged")),
OPT_NO_MERGED(&filter, N_("print only tags that are not merged")),
- 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_REF_SORT(&sorting_options),
{