[PATCH] revisions --stdin: accept CRLF line terminators
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Aug 11, 2015, 20:21 UTC
- Message-ID
- <55CA594D.5020103@kdbg.org>
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 regular files are written via stdout.
To fix the error, permit CRLF line terminators when revisions and pathspec are read using the --stdin option.
Signed-off-by: Johannes Sixt <j6t@kdbg.org> --- This fixes a new failure in the test suite (t3404.8[67]) on Windows, but I got around to debug it only now.
revision.c | 4 ++++ t/t6017-rev-list-stdin.sh | 16 ++++++++++++++++ 2 files changed, 20 insertions(+)
diff --git a/revision.c b/revision.c index cf60c5d..4efedeb 100644 --- a/revision.c +++ b/revision.c @@ -1641,6 +1641,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); } @@ -1661,6 +1663,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 667b375..34c43cf 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 <input >actual && + test_cmp expect actual +' + test_done
-- 2.3.2.245.gb5bf9d3 -- -- *** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free. You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to msysgit@googlegroups.com To unsubscribe from this group, send email to msysgit+unsubscribe@googlegroups.com For more options, and view previous threads, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en --- You received this message because you are subscribed to the Google Groups "Git for Windows" group. To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout.