{"thread":{"id":"21604","subject":"git am and CRLF files","startedAt":"2009-11-13T09:44:47Z","lastAt":"2009-11-30T12:50:51Z","messageCount":7,"participants":["Stefan Naewe","Nanako Shiraishi","Erik Faye-Lund","Daniele Segato","Ismael Luceno"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"127503","messageId":"4AFD2A8F.7000806@atlas-elektronik.com","threadId":"21604","inReplyTo":null,"subject":"git am and CRLF files","fromName":"Stefan Naewe","fromEmail":"stefan.naewe@atlas-elektronik.com","sentAt":"2009-11-13T09:44:47Z","receivedAt":"2009-11-13T09:44:47Z","isPatch":false,"sender":{"key":"stefan.naewe@gmail.com","avatar":"https://avatars.githubusercontent.com/u/4468?v=4"},"body":"Hi there.\nI have:\n\n$ git version\ngit version 1.6.5.1.1367.gcd48\n\n$ git config --get core.autocrlf\nfalse\n\nA repository with some UNIX (LF) and some Windows (CRLF) files.\n(and no: I will not change the files. My editors handle CRLF and LF correctly)\n\nMy problem:\n\n'git am' can't handle changes in CRLF files because the patch\ngets converted (by git mailsplit) to contain only LF.\n\nWhich is wrong IMHO.\n\ngit-am on my msysgit version looks like this (lines: 214++)\n\n<---------->\nsplit_patches () {\n\tcase \"$patch_format\" in\n\tmbox)\n\t\tcase \"$rebasing\" in\n\t\t'')\n\t\t\tkeep_cr= ;;\n\t\t?*)\n\t\t\tkeep_cr=--keep-cr ;;\n\t\tesac\n\t\tgit mailsplit -d\"$prec\" -o\"$dotest\" -b $keep_cr -- \"$@\" > \"$dotest/last\" ||\n\t\tclean_abort\n\t\t;;\n<---------->\n\nThe '--keep-cr' flags is passed to git mailsplit when git am is in 'rebasing' mode.\nBy looking through git-am I found that I can pass \"--rebasing\" to git am to get my\npatch applied correctly.\nBut why is git am behaving that way ?\n\nPuzzled,\n\nStefan\n-- \n----------------------------------------------------------------\n/dev/random says: I'm dangerous when I know what I'm doing.\n"},{"id":"127661","messageId":"4B01004A.8060600@atlas-elektronik.com","threadId":"21604","inReplyTo":"4AFD2A8F.7000806@atlas-elektronik.com","subject":"Re: git am and CRLF files","fromName":"Stefan Naewe","fromEmail":"stefan.naewe@atlas-elektronik.com","sentAt":"2009-11-16T07:33:30Z","receivedAt":"2009-11-16T07:33:30Z","isPatch":false,"sender":{"key":"stefan.naewe@gmail.com","avatar":"https://avatars.githubusercontent.com/u/4468?v=4"},"body":"On 11/13/2009 10:44 AM, Stefan Naewe wrote:\n> Hi there.\n> I have:\n> \n> $ git version\n> git version 1.6.5.1.1367.gcd48\n> \n> $ git config --get core.autocrlf\n> false\n> \n> A repository with some UNIX (LF) and some Windows (CRLF) files.\n> (and no: I will not change the files. My editors handle CRLF and LF correctly)\n> \n> My problem:\n> \n> 'git am' can't handle changes in CRLF files because the patch\n> gets converted (by git mailsplit) to contain only LF.\n> \n> Which is wrong IMHO.\n> \n> git-am on my msysgit version looks like this (lines: 214++)\n> \n> <---------->\n> split_patches () {\n> \tcase \"$patch_format\" in\n> \tmbox)\n> \t\tcase \"$rebasing\" in\n> \t\t'')\n> \t\t\tkeep_cr= ;;\n> \t\t?*)\n> \t\t\tkeep_cr=--keep-cr ;;\n> \t\tesac\n> \t\tgit mailsplit -d\"$prec\" -o\"$dotest\" -b $keep_cr -- \"$@\" > \"$dotest/last\" ||\n> \t\tclean_abort\n> \t\t;;\n> <---------->\n> \n> The '--keep-cr' flags is passed to git mailsplit when git am is in 'rebasing' mode.\n> By looking through git-am I found that I can pass \"--rebasing\" to git am to get my\n> patch applied correctly.\n> But why is git am behaving that way ?\n> \n> Puzzled,\n> \n> Stefan\n\nDoes anyone have any comment on this ?\n\nRegards,\n\nStefan\n-- \n----------------------------------------------------------------\n/dev/random says: Microsoft Windows... a virus with mouse support.\n"},{"id":"127669","messageId":"20091116195036.6117@nanako3.lavabit.com","threadId":"21604","inReplyTo":"4B01004A.8060600@atlas-elektronik.com","subject":"Re: git am and CRLF files","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-11-16T10:50:36Z","receivedAt":"2009-11-16T10:50:36Z","isPatch":false,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Stefan Naewe <stefan.naewe@atlas-elektronik.com>\n\n>> A repository with some UNIX (LF) and some Windows (CRLF) files.\n>> (and no: I will not change the files. My editors handle CRLF and LF correctly)\n>> \n>> My problem:\n>> \n>> 'git am' can't handle changes in CRLF files because the patch\n>> gets converted (by git mailsplit) to contain only LF.\n>\n>> Stefan\n>\n> Does anyone have any comment on this ?\n\nThis was done very much on purpose.\n\nThe \"am\" command is meant to handle e-mailed patches, and traditionally\nmails are known to clobber carriage returns.\n\nSee commit c2ca1d79dbd54b06a05e5d14a897699e59dc9f9f\n\n    Allow mailsplit (and hence git-am) to handle mails with CRLF line-endings\n    \n    It is not that uncommon to have mails with DOS line-ending, notably\n    Thunderbird and web mailers like Gmail (when saving what they call\n    \"original\" message).  So modify mailsplit to convert CRLF line-endings to\n    just LF.\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"127674","messageId":"4B013460.2030406@atlas-elektronik.com","threadId":"21604","inReplyTo":"20091116195036.6117@nanako3.lavabit.com","subject":"Re: git am and CRLF files","fromName":"Stefan Naewe","fromEmail":"stefan.naewe@atlas-elektronik.com","sentAt":"2009-11-16T11:15:44Z","receivedAt":"2009-11-16T11:15:44Z","isPatch":false,"sender":{"key":"stefan.naewe@gmail.com","avatar":"https://avatars.githubusercontent.com/u/4468?v=4"},"body":"On 11/16/2009 11:50 AM, Nanako Shiraishi wrote:\n> Quoting Stefan Naewe <stefan.naewe@atlas-elektronik.com>\n> \n>>> A repository with some UNIX (LF) and some Windows (CRLF) files.\n>>> (and no: I will not change the files. My editors handle CRLF and LF correctly)\n>>>\n>>> My problem:\n>>>\n>>> 'git am' can't handle changes in CRLF files because the patch\n>>> gets converted (by git mailsplit) to contain only LF.\n>>> Stefan\n>> Does anyone have any comment on this ?\n> \n> This was done very much on purpose.\n> \n> The \"am\" command is meant to handle e-mailed patches, and traditionally\n> mails are known to clobber carriage returns.\n> \n> See commit c2ca1d79dbd54b06a05e5d14a897699e59dc9f9f\n> \n>     Allow mailsplit (and hence git-am) to handle mails with CRLF line-endings\n>     \n>     It is not that uncommon to have mails with DOS line-ending, notably\n>     Thunderbird and web mailers like Gmail (when saving what they call\n>     \"original\" message).  So modify mailsplit to convert CRLF line-endings to\n>     just LF.\n> \n\nI've noticed that.\nBut converting everything just breaks git am for CRLF files, doesn't it ?\nWouldn't it be possible (and sensible) to not convert the diff text, but\nonly the rest (mail text, headers, etc.) ?\n\nRegards,\n\nStefan\n-- \n----------------------------------------------------------------\n/dev/random says: Change is inevitable, except from a vending machine.\n"},{"id":"127675","messageId":"40aa078e0911160343k41393197s56d26576bcbfbe90@mail.gmail.com","threadId":"21604","inReplyTo":"20091116195036.6117@nanako3.lavabit.com","subject":"Re: git am and CRLF files","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2009-11-16T11:43:36Z","receivedAt":"2009-11-16T11:43:36Z","isPatch":false,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Mon, Nov 16, 2009 at 11:50 AM, Nanako Shiraishi <nanako3@lavabit.com> wrote:\n> Quoting Stefan Naewe <stefan.naewe@atlas-elektronik.com>\n>\n>>> A repository with some UNIX (LF) and some Windows (CRLF) files.\n>>> (and no: I will not change the files. My editors handle CRLF and LF correctly)\n>>>\n>>> My problem:\n>>>\n>>> 'git am' can't handle changes in CRLF files because the patch\n>>> gets converted (by git mailsplit) to contain only LF.\n>>\n>>> Stefan\n>>\n>> Does anyone have any comment on this ?\n>\n> This was done very much on purpose.\n>\n> The \"am\" command is meant to handle e-mailed patches, and traditionally\n> mails are known to clobber carriage returns.\n>\n\nAccording to RFC 5322, email messages use CRLF as the\nnewline-sequence. In order to be able to distinguish between CRLF and\nLF in an e-mail patch, the message needs to be use some\ntransfer-encoding that preserves newline style (like base64).\n\nPerhaps this would be better fixed by having format-patch (or prehaps\nthe MUA ?) base64-encode the message body if the file contains\nnon-LF-newlines, and normalizing CRLF to LF before transport-decoding?\nOr does some MUAs transport-decode before storing the message to disk?\n\nI realize this might make it a bit tricky to review patches that\ncontains CRLF-newlines before mailing them out, but perhaps inspecting\nthe format-patch output is the wrong place to do this?\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"128760","messageId":"9accb4400911300406l592306c8t889c28ba7b48674b@mail.gmail.com","threadId":"21604","inReplyTo":"40aa078e0911160343k41393197s56d26576bcbfbe90@mail.gmail.com","subject":"Re: git am and CRLF files","fromName":"Daniele Segato","fromEmail":"daniele.bilug@gmail.com","sentAt":"2009-11-30T12:06:04Z","receivedAt":"2009-11-30T12:06:04Z","isPatch":false,"sender":{"key":"daniele.bilug@gmail.com","avatar":null},"body":"On Mon, Nov 16, 2009 at 12:43 PM, Erik Faye-Lund\n<kusmabite@googlemail.com> wrote:\n> According to RFC 5322, email messages use CRLF as the\n> newline-sequence. In order to be able to distinguish between CRLF and\n> LF in an e-mail patch, the message needs to be use some\n> transfer-encoding that preserves newline style (like base64).\n>\n> Perhaps this would be better fixed by having format-patch (or prehaps\n> the MUA ?) base64-encode the message body if the file contains\n> non-LF-newlines, and normalizing CRLF to LF before transport-decoding?\n> Or does some MUAs transport-decode before storing the message to disk?\n>\n> I realize this might make it a bit tricky to review patches that\n> contains CRLF-newlines before mailing them out, but perhaps inspecting\n> the format-patch output is the wrong place to do this?\n\n\nwhy don't adding that information in the mail header?\nor may be made format-patch create a \"comment line\" with that information?\n\nif that line is missing it could keep the default behavior (what it\ndid until now)\n"},{"id":"128763","messageId":"4B13BFAB.3050002@gmail.com","threadId":"21604","inReplyTo":"9accb4400911300406l592306c8t889c28ba7b48674b@mail.gmail.com","subject":"Re: git am and CRLF files","fromName":"Ismael Luceno","fromEmail":"ismael.luceno@gmail.com","sentAt":"2009-11-30T12:50:51Z","receivedAt":"2009-11-30T12:50:51Z","isPatch":false,"sender":{"key":"ismael.luceno@gmail.com","avatar":"https://gravatar.com/avatar/b0ee2c769d00610efaff4dc838a7d2f2bcaf253941fb5739d66b51bae47cbd5d?d=mp&s=160"},"body":"Daniele Segato escribió:\n> On Mon, Nov 16, 2009 at 12:43 PM, Erik Faye-Lund\n> <kusmabite@googlemail.com> wrote:\n>> According to RFC 5322, email messages use CRLF as the\n>> newline-sequence. In order to be able to distinguish between CRLF and\n>> LF in an e-mail patch, the message needs to be use some\n>> transfer-encoding that preserves newline style (like base64).\n>>\n>> Perhaps this would be better fixed by having format-patch (or prehaps\n>> the MUA ?) base64-encode the message body if the file contains\n>> non-LF-newlines, and normalizing CRLF to LF before transport-decoding?\n>> Or does some MUAs transport-decode before storing the message to disk?\n>>\n>> I realize this might make it a bit tricky to review patches that\n>> contains CRLF-newlines before mailing them out, but perhaps inspecting\n>> the format-patch output is the wrong place to do this?\n> \n> \n> why don't adding that information in the mail header?\n> or may be made format-patch create a \"comment line\" with that information?\n> \n> if that line is missing it could keep the default behavior (what it\n> did until now)\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\nIt would make more sense to simply use MIME attachments...\n\n-- \nIsmael Luceno\n\n"}]}