{"thread":{"id":"21241","subject":"[msysgit? bug] CRLF in info/grafts causes parse error","startedAt":"2009-10-14T14:07:49Z","lastAt":"2009-10-14T18:51:03Z","messageCount":2,"participants":["Yann Dirson","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"124973","messageId":"ecf590a0d9e21f480529f64e465825c5.squirrel@intranet.linagora.com","threadId":"21241","inReplyTo":null,"subject":"[msysgit? bug] CRLF in info/grafts causes parse error","fromName":"Yann Dirson","fromEmail":"ydirson@linagora.com","sentAt":"2009-10-14T14:07:49Z","receivedAt":"2009-10-14T14:07:49Z","isPatch":false,"sender":{"key":"ydirson@linagora.com","avatar":null},"body":"When creating an info/grafts under windows, one typically gets a CRLF file.\nThen:\n\n* gitk loudly complains about \"bad graft data\"\n* \"git log > /dev/null\" does not report any problem\n* \"git log > foo\" does report the problem on sdterr, but exit code is still 0\n\nRecreating the graft as a LF file (eg with \"echo\" or \"printf\") causes the\ngraft to be properly interpreted.\n"},{"id":"125004","messageId":"7vbpk9ermw.fsf@alter.siamese.dyndns.org","threadId":"21241","inReplyTo":"ecf590a0d9e21f480529f64e465825c5.squirrel@intranet.linagora.com","subject":"Re: [msysgit? bug] CRLF in info/grafts causes parse error","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-14T18:51:03Z","receivedAt":"2009-10-14T18:51:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Yann Dirson\" <ydirson@linagora.com> writes:\n\n> When creating an info/grafts under windows, one typically gets a CRLF file.\n> Then:\n>\n> * gitk loudly complains about \"bad graft data\"\n> * \"git log > /dev/null\" does not report any problem\n> * \"git log > foo\" does report the problem on sdterr, but exit code is still 0\n>\n> Recreating the graft as a LF file (eg with \"echo\" or \"printf\") causes the\n> graft to be properly interpreted.\n\nI do not see any reason to forbid trailing CR at the end of the line (for\nthat matter, any trailing whitespaces) in the said file.\n\nHow about doing this?\n\n commit.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex fedbd5e..0db2124 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -132,8 +132,8 @@ struct commit_graft *read_graft_line(char *buf, int len)\n \tint i;\n \tstruct commit_graft *graft = NULL;\n \n-\tif (buf[len-1] == '\\n')\n-\t\tbuf[--len] = 0;\n+\twhile (isspace(buf[len-1]))\n+\t\tbuf[--len] = '\\0';\n \tif (buf[0] == '#' || buf[0] == '\\0')\n \t\treturn NULL;\n \tif ((len + 1) % 41) {\n"}]}