Skip to content

Commit 6e8d46f

Browse files
committed
revision: read --stdin with strbuf_getline()
Reading with getwholeline() and manually stripping the terminating '\n' would leave CR at the end of the line if the input comes from a DOS editor. Constrasting this with the other changes around "--stdin" in this series, one may realize that the way "log" family of commands read the paths with "--stdin" looks inconsistent and sloppy. It does not allow us to C-quote a textual input, neither does it accept records that are NUL-terminated. These are unfortunately way too late to fix X-<. Signed-off-by: Junio C Hamano <[email protected]>
1 parent c0353c7 commit 6e8d46f

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

revision.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,10 +1635,7 @@ static void append_prune_data(struct cmdline_pathspec *prune, const char **av)
16351635
static void read_pathspec_from_stdin(struct rev_info *revs, struct strbuf *sb,
16361636
struct cmdline_pathspec *prune)
16371637
{
1638-
while (strbuf_getwholeline(sb, stdin, '\n') != EOF) {
1639-
int len = sb->len;
1640-
if (len && sb->buf[len - 1] == '\n')
1641-
sb->buf[--len] = '\0';
1638+
while (strbuf_getline(sb, stdin) != EOF) {
16421639
ALLOC_GROW(prune->path, prune->nr + 1, prune->alloc);
16431640
prune->path[prune->nr++] = xstrdup(sb->buf);
16441641
}
@@ -1655,10 +1652,8 @@ static void read_revisions_from_stdin(struct rev_info *revs,
16551652
warn_on_object_refname_ambiguity = 0;
16561653

16571654
strbuf_init(&sb, 1000);
1658-
while (strbuf_getwholeline(&sb, stdin, '\n') != EOF) {
1655+
while (strbuf_getline(&sb, stdin) != EOF) {
16591656
int len = sb.len;
1660-
if (len && sb.buf[len - 1] == '\n')
1661-
sb.buf[--len] = '\0';
16621657
if (!len)
16631658
break;
16641659
if (sb.buf[0] == '-') {

0 commit comments

Comments
 (0)