Thread (12 messages) 12 messages, 2 authors, 2016-06-15

[PATCH 2/2] Small code readability improvement in show_reference() in builtin-tag.c

STALE3762d

From: Mike Hommey <hidden>
Date: 2016-06-15 22:43:46
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: Mike Hommey <redacted>
---
 builtin-tag.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/builtin-tag.c b/builtin-tag.c
index e57f57f..3ed5759 100644
--- a/builtin-tag.c
+++ b/builtin-tag.c
@@ -84,14 +84,13 @@ static int show_reference(const char *refname, const unsigned char *sha1,
 		sp = buf = read_sha1_file(sha1, &type, &size);
 		if (!buf)
 			return 0;
-		if (!size) {
+		/* skip header */
+		sp = strstr(buf, "\n\n");
+
+		if (!sp || !size) {
 			free(buf);
 			return 0;
 		}
-		/* skip header */
-		while (sp + 1 < buf + size &&
-				!(sp[0] == '\n' && sp[1] == '\n'))
-			sp++;
 		/* only take up to "lines" lines, and strip the signature */
 		for (i = 0, sp += 2;
 				i < filter->lines && sp < buf + size &&
-- 
1.5.3.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help