git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] revisions --stdin: accept CRLF line terminators
@ 2015-08-11 20:21 Johannes Sixt
  2015-08-11 21:35 ` Junio C Hamano
  0 siblings, 1 reply; 114+ messages in thread
From: Johannes Sixt @ 2015-08-11 20:21 UTC (permalink / raw)
  To: Git Mailing List, msysGit

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.

^ permalink raw reply related	[flat|nested] 114+ messages in thread

end of thread, other threads:[~2016-01-15 23:31 UTC | newest]

Thread overview: 114+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-11 20:21 [PATCH] revisions --stdin: accept CRLF line terminators Johannes Sixt
2015-08-11 21:35 ` Junio C Hamano
2015-08-11 22:14   ` Junio C Hamano
2015-08-12 18:24     ` Johannes Sixt
2015-10-28 22:25     ` [PATCH 00/17] Peace with CRLF Junio C Hamano
2015-10-28 22:25       ` [PATCH 01/17] strbuf: add strbuf_gets() Junio C Hamano
2015-10-28 22:25       ` [PATCH 02/17] check-attr, check-ignore, checkout-index: read paths with strbuf_gets() Junio C Hamano
2015-10-28 22:25       ` [PATCH 03/17] update-index: read --index-info " Junio C Hamano
2015-10-28 22:25       ` [PATCH 04/17] update-index: read list of paths with strbuf_gets() under --stdin Junio C Hamano
2015-10-28 22:25       ` [PATCH 05/17] mktree: read textual tree representation with strbuf_gets() Junio C Hamano
2015-10-28 22:25       ` [PATCH 06/17] hash-object: read --stdin-paths " Junio C Hamano
2015-10-28 22:25       ` [PATCH 07/17] revision: read --stdin " Junio C Hamano
2015-10-28 22:25       ` [PATCH 08/17] rev-parse: read parseopt spec " Junio C Hamano
2015-10-28 22:25       ` [PATCH 09/17] ident.c: read /etc/mailname " Junio C Hamano
2015-10-28 22:25       ` [PATCH 10/17] remote.c: read $GIT_DIR/remotes/* " Junio C Hamano
2015-10-28 22:25       ` [PATCH 11/17] clone/sha1_file: read info/alternates " Junio C Hamano
2015-10-28 22:25       ` [PATCH 12/17] transport-helper: read helper response " Junio C Hamano
2015-10-28 22:25       ` [PATCH 13/17] cat-file: read batch stream " Junio C Hamano
2015-10-28 22:25       ` [PATCH 14/17] column: read lines " Junio C Hamano
2015-10-28 22:25       ` [PATCH 15/17] send-pack: read list of refs " Junio C Hamano
2015-10-28 22:26       ` [PATCH 16/17] grep: read -f file " Junio C Hamano
2015-10-28 22:26       ` [PATCH 17/17] test-sha1-array: read command stream " Junio C Hamano
2015-12-16 22:03       ` [PATCH v2 00/17] Peace with CRLF Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 01/17] strbuf: make strbuf_getline_crlf() global Junio C Hamano
2016-01-04 12:25           ` Johannes Schindelin
2016-01-04 19:17             ` Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 02/17] check-attr, check-ignore, checkout-index: read paths with strbuf_getline_crlf() Junio C Hamano
2016-01-04 12:25           ` Johannes Schindelin
2016-01-04 12:27             ` Johannes Schindelin
2016-01-04 19:20               ` Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 03/17] update-index: read --index-info " Junio C Hamano
2016-01-04 12:27           ` Johannes Schindelin
2016-01-04 19:50             ` Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 04/17] update-index: read list of paths with strbuf_getline_crlf() under --stdin Junio C Hamano
2016-01-04 12:27           ` Johannes Schindelin
2015-12-16 22:03         ` [PATCH v2 05/17] mktree: read textual tree representation with strbuf_getline_crlf() Junio C Hamano
2016-01-04 12:27           ` Johannes Schindelin
2015-12-16 22:03         ` [PATCH v2 06/17] hash-object: read --stdin-paths " Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 07/17] revision: read --stdin " Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 08/17] rev-parse: read parseopt spec " Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 09/17] ident.c: read /etc/mailname " Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 10/17] remote.c: read $GIT_DIR/remotes/* " Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 11/17] clone/sha1_file: read info/alternates " Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 12/17] transport-helper: read helper response " Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 13/17] cat-file: read batch stream " Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 14/17] column: read lines " Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 15/17] send-pack: read list of refs " Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 16/17] grep: read -f file " Junio C Hamano
2016-01-04 12:27           ` Johannes Schindelin
2016-01-04 19:30             ` Junio C Hamano
2015-12-16 22:03         ` [PATCH v2 17/17] test-sha1-array: read command stream " Junio C Hamano
2016-01-04 12:27           ` Johannes Schindelin
2016-01-04 12:25         ` [PATCH v2 00/17] Peace with CRLF Johannes Schindelin
2016-01-14  3:03         ` [PREVIEW v3 0/9] Preview of "Peace with CRLF" rerolled Junio C Hamano
2016-01-14  3:03           ` [PREVIEW v3 1/9] strbuf: miniscule style fix Junio C Hamano
2016-01-14  3:03           ` [PREVIEW v3 2/9] strbuf: make strbuf_getline_crlf() global Junio C Hamano
2016-01-14  3:03           ` [PREVIEW v3 3/9] strbuf: introduce strbuf_getline_{lf,nul}() Junio C Hamano
2016-01-14  3:03           ` [PREVIEW v3 4/9] mktree: there are only two line terminators Junio C Hamano
2016-01-14 10:11             ` Jeff King
2016-01-14  3:03           ` [PREVIEW v3 5/9] check-attr: " Junio C Hamano
2016-01-14  3:03           ` [PREVIEW v3 6/9] check-ignore: " Junio C Hamano
2016-01-14  3:03           ` [PREVIEW v3 7/9] update-index: " Junio C Hamano
2016-01-14 10:09             ` Jeff King
2016-01-14  3:03           ` [PREVIEW v3 8/9] checkout-index: " Junio C Hamano
2016-01-14 10:18             ` Jeff King
2016-01-14 17:13               ` Junio C Hamano
2016-01-14 20:13                 ` Jeff King
2016-01-14  3:03           ` [PREVIEW v3 9/9] strbuf: give strbuf_getline() to the "most text friendly" variant Junio C Hamano
2016-01-14  3:03           ` [PREVIEW v3 9/9] strbuf: retire strbuf_getline() for now Junio C Hamano
2016-01-14  3:09             ` Junio C Hamano
2016-01-14 10:23           ` [PREVIEW v3 0/9] Preview of "Peace with CRLF" rerolled Jeff King
2016-01-14 23:58           ` [PATCH v4 00/21] Peace with CRLF Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 01/21] strbuf: miniscule style fix Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 02/21] strbuf: make strbuf_getline_crlf() global Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 03/21] strbuf: introduce strbuf_getline_{lf,nul}() Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 04/21] mktree: there are only two possible line terminations Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 05/21] check-attr: " Junio C Hamano
2016-01-15 19:16               ` Jeff King
2016-01-15 19:36                 ` Jeff King
2016-01-15 21:20                   ` Junio C Hamano
2016-01-15 21:23                     ` Jeff King
2016-01-15 21:29                       ` Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 06/21] check-ignore: " Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 07/21] update-index: " Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 08/21] checkout-index: " Junio C Hamano
2016-01-15 20:08               ` Jeff King
2016-01-15 20:20                 ` Jeff King
2016-01-15 21:22                 ` Junio C Hamano
2016-01-15 23:31                   ` Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 09/21] strbuf: give strbuf_getline() to the "most text friendly" variant Junio C Hamano
2016-01-15  1:46               ` Eric Sunshine
2016-01-15 18:02                 ` Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 10/21] hash-object: read --stdin-paths with strbuf_getline() Junio C Hamano
2016-01-15 20:23               ` Jeff King
2016-01-14 23:58             ` [PATCH v4 11/21] revision: read --stdin " Junio C Hamano
2016-01-15  1:50               ` Eric Sunshine
2016-01-15 18:38                 ` Junio C Hamano
2016-01-15 20:27               ` Jeff King
2016-01-14 23:58             ` [PATCH v4 12/21] rev-parse: read parseopt spec " Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 13/21] ident.c: read /etc/mailname " Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 14/21] remote.c: read $GIT_DIR/remotes/* " Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 15/21] clone/sha1_file: read info/alternates " Junio C Hamano
2016-01-15  1:52               ` Eric Sunshine
2016-01-14 23:58             ` [PATCH v4 16/21] transport-helper: read helper response " Junio C Hamano
2016-01-15 20:31               ` Jeff King
2016-01-14 23:58             ` [PATCH v4 17/21] cat-file: read batch stream " Junio C Hamano
2016-01-15 20:41               ` Jeff King
2016-01-14 23:58             ` [PATCH v4 18/21] column: read lines " Junio C Hamano
2016-01-15 20:43               ` Jeff King
2016-01-14 23:58             ` [PATCH v4 19/21] send-pack: read list of refs " Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 20/21] grep: read -f file " Junio C Hamano
2016-01-14 23:58             ` [PATCH v4 21/21] test-sha1-array: read command stream " Junio C Hamano
2016-01-15 19:10             ` [PATCH v4 00/21] Peace with CRLF Jeff King
2016-01-15 20:49             ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).