Re: [PATCH 2/5] for-each-ref: refactor refname handling

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 2/5] for-each-ref: refactor refname handling

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:46:34

Jeff King [off-list ref] writes:
This code handles some special magic like *-deref and the
:short formatting specifier. The next patch will add another
field which outputs a ref and wants to use the same code.

This patch splits the "which ref are we outputting" from the
actual formatting. There should be no behavioral change.

Signed-off-by: Jeff King <redacted>
---
The diff is scary, but it is mostly reindentation.
... and an introduction of a bug ;-)
quoted hunk
 builtin-for-each-ref.c |   47 ++++++++++++++++++++++++++---------------------
 1 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 4aaf75c..b50c93b 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -672,32 +672,37 @@ static void populate_value(struct refinfo *ref)
...
+		/* look for "short" refname format */
+		if (formatp) {
+			formatp++;
+			if (!strcmp(formatp, "short"))
+				refname = get_short_ref(refname);
+			else
+				die("unknown %.*s format %s",
+					formatp - name, name, formatp);
				die("unknown %.*s format %s",
                                    (int)(formatp - name), name, formatp);

Re: [PATCH 2/5] for-each-ref: refactor refname handling

From: Jeff King <hidden>
Date: 2016-06-15 22:46:34

On Tue, Apr 07, 2009 at 11:22:51PM -0700, Junio C Hamano wrote:
quoted
The diff is scary, but it is mostly reindentation.
... and an introduction of a bug ;-)
Oops. 
quoted
+				die("unknown %.*s format %s",
+					formatp - name, name, formatp);
				die("unknown %.*s format %s",
                                    (int)(formatp - name), name, formatp);
Hey, it's all 32 bits, right? ;)

Thanks for spotting it.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help