diff options
Diffstat (limited to 'builtin/for-each-ref.c')
-rw-r--r-- | builtin/for-each-ref.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 8520008604..b529228c62 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -22,6 +22,8 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) struct ref_array array; struct ref_filter filter; struct ref_format format = REF_FORMAT_INIT; + struct strbuf output = STRBUF_INIT; + struct strbuf err = STRBUF_INIT; struct option opts[] = { OPT_BIT('s', "shell", &format.quote_style, @@ -81,17 +83,16 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) if (!maxcount || array.nr < maxcount) maxcount = array.nr; for (i = 0; i < maxcount; i++) { - struct strbuf output = STRBUF_INIT; - struct strbuf err = STRBUF_INIT; - + strbuf_reset(&err); + strbuf_reset(&output); if (format_ref_array_item(array.items[i], &format, &output, &err)) die("%s", err.buf); fwrite(output.buf, 1, output.len, stdout); putchar('\n'); - - strbuf_release(&err); - strbuf_release(&output); } + + strbuf_release(&err); + strbuf_release(&output); ref_array_clear(&array); return 0; } |