Skip to contentSkip to conversation

fix strbuf take #2

PATCH New Junio C Hamano 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix strbuf take #2

I just remembered why I placed that bogus "sb->len ==0 implies sb->eof" condition there. We need at least something like this to catch the normal EOF (that is, line termination immediately followed by EOF) case. "if (feof(fp))" fires when we have already read the eof, not when we are about read it.

---
git-diff-cache -r -z 0 | ./git-diff-helper -z

strbuf.c +2 -0
@@ -37,6 +37,8 @@ void read_line(struct strbuf *sb, FILE *
 			break;
 		strbuf_add(sb, ch);
 	}
+	if (ch == EOF && sb->len == 0)
+		sb->eof = 1;
 	strbuf_end(sb);
 }