summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3bb18e5)
raw | patch | inline | side by side (parent: 3bb18e5)
author | Junio C Hamano <gitster@pobox.com> | |
Fri, 20 Nov 2009 10:00:40 +0000 (02:00 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 20 Nov 2009 22:50:43 +0000 (14:50 -0800) |
It is so 2005 (and Linus ;-) to have a fixed 1000-byte buffer that
reads from the user. Let's use strbuf to unlimit the input length.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reads from the user. Let's use strbuf to unlimit the input length.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c | patch | blob | history |
diff --git a/revision.c b/revision.c
index 9fc4e8d3818f29261b1963f4995bc36f8af31179..d56387fe65ea55d48c7eef1dda23f789e334397a 100644 (file)
--- a/revision.c
+++ b/revision.c
void read_revisions_from_stdin(struct rev_info *revs)
{
- char line[1000];
+ struct strbuf sb;
- while (fgets(line, sizeof(line), stdin) != NULL) {
- int len = strlen(line);
- if (len && line[len - 1] == '\n')
- line[--len] = '\0';
+ strbuf_init(&sb, 1000);
+ while (strbuf_getwholeline(&sb, stdin, '\n') != EOF) {
+ int len = sb.len;
+ if (len && sb.buf[len - 1] == '\n')
+ sb.buf[--len] = '\0';
if (!len)
break;
- if (line[0] == '-')
+ if (sb.buf[0] == '-')
die("options not supported in --stdin mode");
- if (handle_revision_arg(line, revs, 0, 1))
- die("bad revision '%s'", line);
+ if (handle_revision_arg(sb.buf, revs, 0, 1))
+ die("bad revision '%s'", sb.buf);
}
+ strbuf_release(&sb);
}
static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token what)