From 99845c3e32663e5ed63df28048de6c990535ef53 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Tue, 11 Aug 2015 10:30:27 +0200 Subject: [PATCH] revisions --stdin: accept CRLF line terminators On Windows, 'git rebase -i' with rebase.missingCommitsCheck set to warn or error reports: Dropped commits (newer to older): 'atal: bad revision '410dee56... The error comes from the git rev-list --stdin invocation in git-rebase--interactive.sh (function check_todo_list). It is caused by CRs that end up in the file "$todo".miss, because many tools of the MSYS toolset force LF to CRLF conversion when files are written via stdout. To fix the error, permit CRLF line terminations when revisions and pathspec are read using the --stdin option. Signed-off-by: Johannes Sixt --- revision.c | 4 ++++ t/t6017-rev-list-stdin.sh | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/revision.c b/revision.c index b444afd73b..5b7398f6f5 100644 --- a/revision.c +++ b/revision.c @@ -1654,6 +1654,8 @@ static void read_pathspec_from_stdin(struct rev_info *revs, struct strbuf *sb, int len = sb->len; if (len && sb->buf[len - 1] == '\n') sb->buf[--len] = '\0'; + if (len && sb->buf[len - 1] == '\r') + sb->buf[--len] = '\0'; ALLOC_GROW(prune->path, prune->nr + 1, prune->alloc); prune->path[prune->nr++] = xstrdup(sb->buf); } @@ -1674,6 +1676,8 @@ static void read_revisions_from_stdin(struct rev_info *revs, int len = sb.len; if (len && sb.buf[len - 1] == '\n') sb.buf[--len] = '\0'; + if (len && sb.buf[len - 1] == '\r') + sb.buf[--len] = '\0'; if (!len) break; if (sb.buf[0] == '-') { diff --git a/t/t6017-rev-list-stdin.sh b/t/t6017-rev-list-stdin.sh index 667b37564e..71e3e5937c 100755 --- a/t/t6017-rev-list-stdin.sh +++ b/t/t6017-rev-list-stdin.sh @@ -75,4 +75,20 @@ test_expect_success 'not only --stdin' ' test_cmp expect actual ' +test_expect_success 'accept CRLF line terminators' ' + cat >expect <<-EOF && + 7 + + file-2 + EOF + q_to_cr >input <<-EOF && + masterQ + ^master^Q + --Q + file-2Q + EOF + git log --pretty=tformat:%s --name-only --stdin actual && + test_cmp expect actual +' + test_done -- 2.11.4.GIT