Code

filter-branch: fix behaviour of '-k'
[git.git] / strbuf.c
index 654330849c3f5d1502d0116c71595b9fa4613186..7f14b0fb59bd7e14979b002f441ae84ff5b0e9a2 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,10 +1,8 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "strbuf.h"
 #include "cache.h"
+#include "strbuf.h"
 
 void strbuf_init(struct strbuf *sb) {
-       sb->buf = 0;
+       sb->buf = NULL;
        sb->eof = sb->alloc = sb->len = 0;
 }
 
@@ -37,6 +35,8 @@ void read_line(struct strbuf *sb, FILE *fp, int term) {
                        break;
                strbuf_add(sb, ch);
        }
+       if (ch == EOF && sb->len == 0)
+               sb->eof = 1;
        strbuf_end(sb);
 }