fetch: reduce duplicate in ref update status lines with placeholder
[gitweb.git] / strbuf.c
index 63896e8f208944a438e46e32a9665d200dec4f4f..1ba600bd780733f7a985c88f797efdd93c1e49fa 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -487,9 +487,15 @@ int strbuf_getwholeline(struct strbuf *sb, FILE *fp, int term)
        if (errno == ENOMEM)
                die("Out of memory, getdelim failed");
 
-       /* Restore slopbuf that we moved out of the way before */
+       /*
+        * Restore strbuf invariants; if getdelim left us with a NULL pointer,
+        * we can just re-init, but otherwise we should make sure that our
+        * length is empty, and that the result is NUL-terminated.
+        */
        if (!sb->buf)
                strbuf_init(sb, 0);
+       else
+               strbuf_reset(sb);
        return EOF;
 }
 #else