summaryrefslogtreecommitdiff
path: root/mktree.c
diff options
context:
space:
mode:
authorPierre Habouzit <madcoder@debian.org>2007-09-17 11:19:04 +0200
committerJunio C Hamano <gitster@pobox.com>2007-09-18 00:55:10 -0700
commite6c019d0b0140fae1cdfd661746cbe319b6c3670 (patch)
tree5711e59da3bda8207a41173df8d6a6b66696b7b5 /mktree.c
parent8b6087fb25068d6af927f112a93dc056930f3108 (diff)
downloadgit-e6c019d0b0140fae1cdfd661746cbe319b6c3670.tar.gz
Drop strbuf's 'eof' marker, and make read_line a first class citizen.
read_line is now strbuf_getline, and is a first class citizen, it returns 0 when reading a line worked, EOF else. The ->eof marker was used non-locally by fast-import.c, mimic the same behaviour using a static int in "read_next_command", that now returns -1 on EOF, and avoids to call strbuf_getline when it's in EOF state. Also no longer automagically strbuf_release the buffer, it's counter intuitive and breaks fast-import in a very subtle way. Note: being at EOF implies that command_buf.len == 0. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'mktree.c')
-rw-r--r--mktree.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mktree.c b/mktree.c
index 5dab4bd367..9c137dec45 100644
--- a/mktree.c
+++ b/mktree.c
@@ -88,8 +88,7 @@ int main(int ac, char **av)
enum object_type type;
char *path;
- read_line(&sb, stdin, line_termination);
- if (sb.eof)
+ if (strbuf_getline(&sb, stdin, line_termination) == EOF)
break;
ptr = sb.buf;
/* Input is non-recursive ls-tree output format
@@ -121,6 +120,7 @@ int main(int ac, char **av)
if (path != ntr)
free(path);
}
+ strbuf_release(&sb);
write_tree(sha1);
puts(sha1_to_hex(sha1));
exit(0);