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
This commit is contained in:
@ -22,7 +22,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
|
||||
int i;
|
||||
struct ref_sorting *sorting;
|
||||
struct string_list sorting_options = STRING_LIST_INIT_DUP;
|
||||
int maxcount = 0, icase = 0;
|
||||
int maxcount = 0, icase = 0, omit_empty = 0;
|
||||
struct ref_array array;
|
||||
struct ref_filter filter;
|
||||
struct ref_format format = REF_FORMAT_INIT;
|
||||
@ -40,6 +40,8 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
|
||||
N_("quote placeholders suitably for python"), QUOTE_PYTHON),
|
||||
OPT_BIT(0 , "tcl", &format.quote_style,
|
||||
N_("quote placeholders suitably for Tcl"), QUOTE_TCL),
|
||||
OPT_BOOL(0, "omit-empty", &omit_empty,
|
||||
N_("do not output a newline after empty formatted refs")),
|
||||
|
||||
OPT_GROUP(""),
|
||||
OPT_INTEGER( 0 , "count", &maxcount, N_("show only <n> matched refs")),
|
||||
@ -112,7 +114,8 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
|
||||
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);
|
||||
|
Reference in New Issue
Block a user