diff options
| author | Junio C Hamano <gitster@pobox.com> | 2023-04-21 15:35:05 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-04-21 15:35:05 -0700 |
| commit | b64894c2063e5875bfd95b537eafcb3e1abf46ff (patch) | |
| tree | 989d1d734418b366f23738b228b96dcd6ec1acbd /builtin/tag.c | |
| parent | Merge branch 'ah/format-patch-thread-doc' (diff) | |
| parent | branch, for-each-ref, tag: add option to omit empty lines (diff) | |
| download | git-b64894c2063e5875bfd95b537eafcb3e1abf46ff.tar.gz git-b64894c2063e5875bfd95b537eafcb3e1abf46ff.zip | |
Merge branch 'ow/ref-filter-omit-empty'
"git branch --format=..." and "git format-patch --format=..."
learns "--omit-empty" to hide refs that whose formatting result
becomes an empty string from the output.
* ow/ref-filter-omit-empty:
branch, for-each-ref, tag: add option to omit empty lines
Diffstat (limited to 'builtin/tag.c')
| -rw-r--r-- | builtin/tag.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin/tag.c b/builtin/tag.c index 782bb3aa2f..ab5f5c74f4 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -41,6 +41,7 @@ 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) @@ -79,7 +80,8 @@ 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); - putchar('\n'); + if (output.len || !omit_empty) + putchar('\n'); } strbuf_release(&err); @@ -474,6 +476,8 @@ 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, + N_("do not output a newline after empty formatted refs")), OPT_REF_SORT(&sorting_options), { OPTION_CALLBACK, 0, "points-at", &filter.points_at, N_("object"), |
