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>
This commit is contained in:

committed by
Junio C Hamano

parent
8b6087fb25
commit
e6c019d0b0
@ -327,8 +327,7 @@ static void read_index_info(int line_termination)
|
||||
* This format is to put higher order stages into the
|
||||
* index file and matches git-ls-files --stage output.
|
||||
*/
|
||||
read_line(&buf, stdin, line_termination);
|
||||
if (buf.eof)
|
||||
if (strbuf_getline(&buf, stdin, line_termination) == EOF)
|
||||
break;
|
||||
|
||||
errno = 0;
|
||||
@ -391,6 +390,7 @@ static void read_index_info(int line_termination)
|
||||
bad_line:
|
||||
die("malformed index info %s", buf.buf);
|
||||
}
|
||||
strbuf_release(&buf);
|
||||
}
|
||||
|
||||
static const char update_index_usage[] =
|
||||
@ -719,8 +719,7 @@ int cmd_update_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);
|
||||
@ -735,6 +734,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
|
||||
if (path_name != buf.buf)
|
||||
free(path_name);
|
||||
}
|
||||
strbuf_release(&buf);
|
||||
}
|
||||
|
||||
finish:
|
||||
|
Reference in New Issue
Block a user