From e6c019d0b0140fae1cdfd661746cbe319b6c3670 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Mon, 17 Sep 2007 11:19:04 +0200 Subject: 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 Signed-off-by: Junio C Hamano --- builtin-checkout-index.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'builtin-checkout-index.c') diff --git a/builtin-checkout-index.c b/builtin-checkout-index.c index 85e8efe22f..a18ecc4bab 100644 --- a/builtin-checkout-index.c +++ b/builtin-checkout-index.c @@ -277,9 +277,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) while (1) { char *path_name; const char *p; - - read_line(&buf, stdin, line_termination); - if (buf.eof) + if (strbuf_getline(&buf, stdin, line_termination) == EOF) break; if (line_termination && buf.buf[0] == '"') path_name = unquote_c_style(buf.buf, NULL); @@ -292,6 +290,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) if (path_name != buf.buf) free(path_name); } + strbuf_release(&buf); } if (all) -- cgit v1.2.3