{"thread":{"id":"32312","subject":"How to avoid the ^M induced by Meld and Git","startedAt":"2012-12-11T12:33:37Z","lastAt":"2012-12-14T13:45:00Z","messageCount":6,"participants":["Karl Brand","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"204677","messageId":"50C72821.10908@erasmusmc.nl","threadId":"32312","inReplyTo":null,"subject":"How to avoid the ^M induced by Meld and Git","fromName":"Karl Brand","fromEmail":"k.brand@erasmusmc.nl","sentAt":"2012-12-11T12:33:37Z","receivedAt":"2012-12-11T12:33:37Z","isPatch":false,"sender":{"key":"k.brand@erasmusmc.nl","avatar":null},"body":"Esteemed Git users,\n\nWhat i do:\n\n1. Create a script.r using Emacs/ESS.\n2. Make some modifications to script.r with the nice diff gui, Meld\n3. Commit these modifications using git commit -am \"my message\"\n4. Reopen script.r in Emacs/ESS to continue working.\n\nThe lines added (&/edited ?) using Meld all end with ^M which i \ncertainly don't want. Lines not added/edited with Meld do NOT end with ^M.\n\nThere are plenty of posts around about these being line endings used for \nwindows which can appear when working on a script under a *nix OS which \nhas previously been edited in a Windows OS. This is not the case here - \neverything is taking place on Ubuntu 12.04.\n\nFWIW: the directory is being synced by dropbox; and in Meld, Preferences \n > Encoding tab, \"utf8\" is entered in the text box.\n\nCurrent work around is running in a terminal: dos2unix /path/to/script.r \nwhich strips the ^M's\n\nBut this just shouldn't be necessary and I'd really appreciate the \nreflections & advice on how to stop inducing these ^M's !\n\nWith thanks,\n\nKarl\n\n(re)posted here as suggested off topic at SO:\nhttp://stackoverflow.com/questions/13799631/create-script-r-in-emacs-modify-with-meld-git-commit-reopen-in-emacs-m\n\n-- \nKarl Brand\nDept of Cardiology and Dept of Bioinformatics\nErasmus MC\nDr Molewaterplein 50\n3015 GE Rotterdam\nT +31 (0)10 703 2460 |M +31 (0)642 777 268 |F +31 (0)10 704 4161\n"},{"id":"204745","messageId":"50C89B68.8090309@drmicha.warpmail.net","threadId":"32312","inReplyTo":"50C72821.10908@erasmusmc.nl","subject":"Re: How to avoid the ^M induced by Meld and Git","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2012-12-12T14:57:44Z","receivedAt":"2012-12-12T14:57:44Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Karl Brand venit, vidit, dixit 11.12.2012 13:33:\n> Esteemed Git users,\n> \n> What i do:\n> \n> 1. Create a script.r using Emacs/ESS.\n> 2. Make some modifications to script.r with the nice diff gui, Meld\n> 3. Commit these modifications using git commit -am \"my message\"\n> 4. Reopen script.r in Emacs/ESS to continue working.\n> \n> The lines added (&/edited ?) using Meld all end with ^M which i \n> certainly don't want. Lines not added/edited with Meld do NOT end with ^M.\n\nWhat happens if you leave out step 3? If the same happens then Meld is\nthe culprit. (Unless you've set some special options, git does not\nmodify your file on commit, so this can't be git related.)\n\n> There are plenty of posts around about these being line endings used for \n> windows which can appear when working on a script under a *nix OS which \n> has previously been edited in a Windows OS. This is not the case here - \n> everything is taking place on Ubuntu 12.04.\n> \n> FWIW: the directory is being synced by dropbox; and in Meld, Preferences \n>  > Encoding tab, \"utf8\" is entered in the text box.\n> \n> Current work around is running in a terminal: dos2unix /path/to/script.r \n> which strips the ^M's\n> \n> But this just shouldn't be necessary and I'd really appreciate the \n> reflections & advice on how to stop inducing these ^M's !\n> \n> With thanks,\n> \n> Karl\n> \n> (re)posted here as suggested off topic at SO:\n> http://stackoverflow.com/questions/13799631/create-script-r-in-emacs-modify-with-meld-git-commit-reopen-in-emacs-m\n> \n"},{"id":"204749","messageId":"50C8A403.9050304@erasmusmc.nl","threadId":"32312","inReplyTo":"50C89B68.8090309@drmicha.warpmail.net","subject":"Re: How to avoid the ^M induced by Meld and Git","fromName":"Karl Brand","fromEmail":"k.brand@erasmusmc.nl","sentAt":"2012-12-12T15:34:27Z","receivedAt":"2012-12-12T15:34:27Z","isPatch":false,"sender":{"key":"k.brand@erasmusmc.nl","avatar":null},"body":"\n\nOn 12/12/12 15:57, Michael J Gruber wrote:\n> Karl Brand venit, vidit, dixit 11.12.2012 13:33:\n>> Esteemed Git users,\n>>\n>> What i do:\n>>\n>> 1. Create a script.r using Emacs/ESS.\n>> 2. Make some modifications to script.r with the nice diff gui, Meld\n>> 3. Commit these modifications using git commit -am \"my message\"\n>> 4. Reopen script.r in Emacs/ESS to continue working.\n>>\n>> The lines added (&/edited ?) using Meld all end with ^M which i\n>> certainly don't want. Lines not added/edited with Meld do NOT end with ^M.\n>\n> What happens if you leave out step 3? If the same happens then Meld is\n> the culprit. (Unless you've set some special options, git does not\n> modify your file on commit, so this can't be git related.)\n>\n\nLeaving out step 3. results in exactly the same thing. Thus Git doesn't \nappear to be responsible for the ^M's. Thanks a lot for your effort on \nthis and my apologies for not taking the care to dissect this more \ncarefully as you suggested. Over to the Meld mailing list...\n\n>> There are plenty of posts around about these being line endings used for\n>> windows which can appear when working on a script under a *nix OS which\n>> has previously been edited in a Windows OS. This is not the case here -\n>> everything is taking place on Ubuntu 12.04.\n>>\n>> FWIW: the directory is being synced by dropbox; and in Meld, Preferences\n>>   > Encoding tab, \"utf8\" is entered in the text box.\n>>\n>> Current work around is running in a terminal: dos2unix /path/to/script.r\n>> which strips the ^M's\n>>\n>> But this just shouldn't be necessary and I'd really appreciate the\n>> reflections & advice on how to stop inducing these ^M's !\n>>\n>> With thanks,\n>>\n>> Karl\n>>\n>> (re)posted here as suggested off topic at SO:\n>> http://stackoverflow.com/questions/13799631/create-script-r-in-emacs-modify-with-meld-git-commit-reopen-in-emacs-m\n>>\n>\n\n-- \nKarl Brand\nDept of Cardiology and Dept of Bioinformatics\nErasmus MC\nDr Molewaterplein 50\n3015 GE Rotterdam\nT +31 (0)10 703 2460 |M +31 (0)642 777 268 |F +31 (0)10 704 4161\n"},{"id":"204751","messageId":"50C8AC0A.1010306@drmicha.warpmail.net","threadId":"32312","inReplyTo":"50C8A403.9050304@erasmusmc.nl","subject":"Re: How to avoid the ^M induced by Meld and Git","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2012-12-12T16:08:42Z","receivedAt":"2012-12-12T16:08:42Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Karl Brand venit, vidit, dixit 12.12.2012 16:34:\n> \n> \n> On 12/12/12 15:57, Michael J Gruber wrote:\n>> Karl Brand venit, vidit, dixit 11.12.2012 13:33:\n>>> Esteemed Git users,\n>>>\n>>> What i do:\n>>>\n>>> 1. Create a script.r using Emacs/ESS.\n>>> 2. Make some modifications to script.r with the nice diff gui, Meld\n>>> 3. Commit these modifications using git commit -am \"my message\"\n>>> 4. Reopen script.r in Emacs/ESS to continue working.\n>>>\n>>> The lines added (&/edited ?) using Meld all end with ^M which i\n>>> certainly don't want. Lines not added/edited with Meld do NOT end with ^M.\n>>\n>> What happens if you leave out step 3? If the same happens then Meld is\n>> the culprit. (Unless you've set some special options, git does not\n>> modify your file on commit, so this can't be git related.)\n>>\n> \n> Leaving out step 3. results in exactly the same thing. Thus Git doesn't \n> appear to be responsible for the ^M's. Thanks a lot for your effort on \n> this and my apologies for not taking the care to dissect this more \n> carefully as you suggested. Over to the Meld mailing list...\n\nI didn't mean to shy you away ;)\n\nCould it be that there is a ^M very early in the file (or rather\nsomething else which isn't covered by dos2unix) so that Meld thinks it's\nDOS and inserts line endings as DOS? At least that's what vim would do.\n\nIn any case, Meld people over there should know (or get to know) that\neffect.\n\n>>> There are plenty of posts around about these being line endings used for\n>>> windows which can appear when working on a script under a *nix OS which\n>>> has previously been edited in a Windows OS. This is not the case here -\n>>> everything is taking place on Ubuntu 12.04.\n>>>\n>>> FWIW: the directory is being synced by dropbox; and in Meld, Preferences\n>>>   > Encoding tab, \"utf8\" is entered in the text box.\n>>>\n>>> Current work around is running in a terminal: dos2unix /path/to/script.r\n>>> which strips the ^M's\n>>>\n>>> But this just shouldn't be necessary and I'd really appreciate the\n>>> reflections & advice on how to stop inducing these ^M's !\n>>>\n>>> With thanks,\n>>>\n>>> Karl\n>>>\n>>> (re)posted here as suggested off topic at SO:\n>>> http://stackoverflow.com/questions/13799631/create-script-r-in-emacs-modify-with-meld-git-commit-reopen-in-emacs-m\n>>>\n>>\n> \n"},{"id":"204753","messageId":"50C8AE14.4000704@erasmusmc.nl","threadId":"32312","inReplyTo":"50C8AC0A.1010306@drmicha.warpmail.net","subject":"Re: How to avoid the ^M induced by Meld and Git","fromName":"Karl Brand","fromEmail":"k.brand@erasmusmc.nl","sentAt":"2012-12-12T16:17:24Z","receivedAt":"2012-12-12T16:17:24Z","isPatch":false,"sender":{"key":"k.brand@erasmusmc.nl","avatar":null},"body":"\n\nOn 12/12/12 17:08, Michael J Gruber wrote:\n> Karl Brand venit, vidit, dixit 12.12.2012 16:34:\n>>\n>>\n>> On 12/12/12 15:57, Michael J Gruber wrote:\n>>> Karl Brand venit, vidit, dixit 11.12.2012 13:33:\n>>>> Esteemed Git users,\n>>>>\n>>>> What i do:\n>>>>\n>>>> 1. Create a script.r using Emacs/ESS.\n>>>> 2. Make some modifications to script.r with the nice diff gui, Meld\n>>>> 3. Commit these modifications using git commit -am \"my message\"\n>>>> 4. Reopen script.r in Emacs/ESS to continue working.\n>>>>\n>>>> The lines added (&/edited ?) using Meld all end with ^M which i\n>>>> certainly don't want. Lines not added/edited with Meld do NOT end with ^M.\n>>>\n>>> What happens if you leave out step 3? If the same happens then Meld is\n>>> the culprit. (Unless you've set some special options, git does not\n>>> modify your file on commit, so this can't be git related.)\n>>>\n>>\n>> Leaving out step 3. results in exactly the same thing. Thus Git doesn't\n>> appear to be responsible for the ^M's. Thanks a lot for your effort on\n>> this and my apologies for not taking the care to dissect this more\n>> carefully as you suggested. Over to the Meld mailing list...\n>\n> I didn't mean to shy you away ;)\n\nApplying recent lessons form StackO'flow :P\n>\n> Could it be that there is a ^M very early in the file (or rather\n> something else which isn't covered by dos2unix) so that Meld thinks it's\n> DOS and inserts line endings as DOS? At least that's what vim would do.\n>\nIf there is i don't find it using Emacs, but Emacs may only show what \ndos2unix sees... Will post back the Meld insights (here's hoping!)\n\n> In any case, Meld people over there should know (or get to know) that\n> effect.\n>\n>>>> There are plenty of posts around about these being line endings used for\n>>>> windows which can appear when working on a script under a *nix OS which\n>>>> has previously been edited in a Windows OS. This is not the case here -\n>>>> everything is taking place on Ubuntu 12.04.\n>>>>\n>>>> FWIW: the directory is being synced by dropbox; and in Meld, Preferences\n>>>>    > Encoding tab, \"utf8\" is entered in the text box.\n>>>>\n>>>> Current work around is running in a terminal: dos2unix /path/to/script.r\n>>>> which strips the ^M's\n>>>>\n>>>> But this just shouldn't be necessary and I'd really appreciate the\n>>>> reflections & advice on how to stop inducing these ^M's !\n>>>>\n>>>> With thanks,\n>>>>\n>>>> Karl\n>>>>\n>>>> (re)posted here as suggested off topic at SO:\n>>>> http://stackoverflow.com/questions/13799631/create-script-r-in-emacs-modify-with-meld-git-commit-reopen-in-emacs-m\n>>>>\n>>>\n>>\n\n-- \nKarl Brand\nDept of Cardiology and Dept of Bioinformatics\nErasmus MC\nDr Molewaterplein 50\n3015 GE Rotterdam\nT +31 (0)10 703 2460 |M +31 (0)642 777 268 |F +31 (0)10 704 4161\n"},{"id":"204869","messageId":"50CB2D5C.6010201@erasmusmc.nl","threadId":"32312","inReplyTo":"50C8AE14.4000704@erasmusmc.nl","subject":"Re: How to avoid the ^M induced by Meld and Git","fromName":"Karl Brand","fromEmail":"k.brand@erasmusmc.nl","sentAt":"2012-12-14T13:45:00Z","receivedAt":"2012-12-14T13:45:00Z","isPatch":false,"sender":{"key":"k.brand@erasmusmc.nl","avatar":null},"body":"FYI: It was all down to unexpected dos formatting of one of the files. \nHere's how i sorted out my unwanted ^M line endings in case anyone \nstumbles on this thread with the same issue i had. (reposted from \nhttp://stackoverflow.com/questions/13799631/why-is-m-being-added-to-a-script-r-after-modifying-with-meld/13879162#13879162 \n)\n\nThanks again to those investing effort on this issue - cheers!\n\nIn a terminal i ran cat script.r | hexdump -C | head and found a 0d 0a \nin the file, which is DOS formatting for a new line (carriage return 0d \nimmediately followed by a line feed 0a). I ran the same command on \nanother_script.r i was merging with but only observed 0a, no 0d 0a, \nindicating Unix formatting.\n\nTo check further if this was the source of the ^M line endings, script.r \nwas converted to unix formatting via dos2unix script.r & verified that \n0d 0a was converted to 0a using hexdump -C as above. I performed a merge \nusing Meld in attempting to replicate the process which yielded ^M line \nendings in my script's. I re-oppened both files in Emacs/ESS and found \nno ^M line endings. Short of converting script.r back to dos formatting \nand repeating the above procedure to see if the ^M line endings \nre-appear, i believe i've solved my ^M issue, which simply is that, \nunbeknownst to me, one of my files was dos formatted. My take home \nmessage: in a Windows dominated environ, never assume that one's \npersonal linux environment doesn't contain DOS bits. Or line endings.\n\nOn 12/12/12 17:17, Karl Brand wrote:\n>\n>\n> On 12/12/12 17:08, Michael J Gruber wrote:\n>> Karl Brand venit, vidit, dixit 12.12.2012 16:34:\n>>>\n>>>\n>>> On 12/12/12 15:57, Michael J Gruber wrote:\n>>>> Karl Brand venit, vidit, dixit 11.12.2012 13:33:\n>>>>> Esteemed Git users,\n>>>>>\n>>>>> What i do:\n>>>>>\n>>>>> 1. Create a script.r using Emacs/ESS.\n>>>>> 2. Make some modifications to script.r with the nice diff gui, Meld\n>>>>> 3. Commit these modifications using git commit -am \"my message\"\n>>>>> 4. Reopen script.r in Emacs/ESS to continue working.\n>>>>>\n>>>>> The lines added (&/edited ?) using Meld all end with ^M which i\n>>>>> certainly don't want. Lines not added/edited with Meld do NOT end\n>>>>> with ^M.\n>>>>\n>>>> What happens if you leave out step 3? If the same happens then Meld is\n>>>> the culprit. (Unless you've set some special options, git does not\n>>>> modify your file on commit, so this can't be git related.)\n>>>>\n>>>\n>>> Leaving out step 3. results in exactly the same thing. Thus Git doesn't\n>>> appear to be responsible for the ^M's. Thanks a lot for your effort on\n>>> this and my apologies for not taking the care to dissect this more\n>>> carefully as you suggested. Over to the Meld mailing list...\n>>\n>> I didn't mean to shy you away ;)\n>\n> Applying recent lessons form StackO'flow :P\n>>\n>> Could it be that there is a ^M very early in the file (or rather\n>> something else which isn't covered by dos2unix) so that Meld thinks it's\n>> DOS and inserts line endings as DOS? At least that's what vim would do.\n>>\n> If there is i don't find it using Emacs, but Emacs may only show what\n> dos2unix sees... Will post back the Meld insights (here's hoping!)\n>\n>> In any case, Meld people over there should know (or get to know) that\n>> effect.\n>>\n>>>>> There are plenty of posts around about these being line endings\n>>>>> used for\n>>>>> windows which can appear when working on a script under a *nix OS\n>>>>> which\n>>>>> has previously been edited in a Windows OS. This is not the case\n>>>>> here -\n>>>>> everything is taking place on Ubuntu 12.04.\n>>>>>\n>>>>> FWIW: the directory is being synced by dropbox; and in Meld,\n>>>>> Preferences\n>>>>>    > Encoding tab, \"utf8\" is entered in the text box.\n>>>>>\n>>>>> Current work around is running in a terminal: dos2unix\n>>>>> /path/to/script.r\n>>>>> which strips the ^M's\n>>>>>\n>>>>> But this just shouldn't be necessary and I'd really appreciate the\n>>>>> reflections & advice on how to stop inducing these ^M's !\n>>>>>\n>>>>> With thanks,\n>>>>>\n>>>>> Karl\n>>>>>\n>>>>> (re)posted here as suggested off topic at SO:\n>>>>> http://stackoverflow.com/questions/13799631/create-script-r-in-emacs-modify-with-meld-git-commit-reopen-in-emacs-m\n>>>>>\n>>>>>\n>>>>\n>>>\n>\n\n-- \nKarl Brand\nDept of Cardiology and Dept of Bioinformatics\nErasmus MC\nDr Molewaterplein 50\n3015 GE Rotterdam\nT +31 (0)10 703 2460 |M +31 (0)642 777 268 |F +31 (0)10 704 4161\n"}]}