Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin/for-each-ref.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index a9d189c..1390da8 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -989,29 +989,12 @@ static void emit(struct strbuf *sb, const char *cp, const char *ep) } } -static void show_ref(struct strbuf *sb, struct refinfo *info, - const char *format, int quote_style) -{ - const char *cp, *sp, *ep; - - for (cp = format; *cp && (sp = find_next(cp)); cp = ep + 1) { - ep = strchr(sp, ')'); - if (cp < sp) - emit(sb, cp, sp); - print_value(sb, info, parse_atom(sp + 2, ep), quote_style); - } - if (*cp) { - sp = cp + strlen(cp); - emit(sb, cp, sp); - } - strbuf_addch(sb, '\n'); -} - static void show_refs(struct refinfo **refs, int maxcount, const char *format, int quote_style) { struct strbuf *sb; - int i; + const char *cp, *sp, *ep; + int i, atom; sb = xmalloc(sizeof(*sb) * maxcount); for (i = 0; i < maxcount; i++) { @@ -1022,8 +1005,24 @@ static void show_refs(struct refinfo **refs, int maxcount, } } + for (cp = format; *cp && (sp = find_next(cp)); cp = ep + 1) { + ep = strchr(sp, ')'); + if (cp < sp) { + for (i = 0; i < maxcount; i++) + emit(sb + i, cp, sp); + } + atom = parse_atom(sp + 2, ep); + for (i = 0; i < maxcount; i++) + print_value(sb + i, refs[i], atom, quote_style); + } + if (*cp) { + sp = cp + strlen(cp); + for (i = 0; i < maxcount; i++) + emit(sb + i, cp, sp); + } + for (i = 0; i < maxcount; i++) { - show_ref(sb + i, refs[i], format, quote_style); + strbuf_addch(sb + i, '\n'); fputs(sb[i].buf, stdout); strbuf_release(sb + i); } -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html