diff options
Diffstat (limited to 'builtin/tag.c')
-rw-r--r-- | builtin/tag.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/builtin/tag.c b/builtin/tag.c index 782bb3aa2f..1850a6a6fd 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -7,12 +7,15 @@ */ #include "cache.h" +#include "advice.h" #include "config.h" #include "builtin.h" +#include "editor.h" #include "environment.h" #include "gettext.h" #include "hex.h" #include "refs.h" +#include "object-name.h" #include "object-store.h" #include "tag.h" #include "run-command.h" @@ -41,6 +44,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 +83,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 +479,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"), |