Re: How to avoid the ^M induced by Meld and Git

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



FYI: It was all down to unexpected dos formatting of one of the files. Here's how i sorted out my unwanted ^M line endings in case anyone stumbles on this thread with the same issue i had. (reposted from http://stackoverflow.com/questions/13799631/why-is-m-being-added-to-a-script-r-after-modifying-with-meld/13879162#13879162 )

Thanks again to those investing effort on this issue - cheers!

In a terminal i ran cat script.r | hexdump -C | head and found a 0d 0a in the file, which is DOS formatting for a new line (carriage return 0d immediately followed by a line feed 0a). I ran the same command on another_script.r i was merging with but only observed 0a, no 0d 0a, indicating Unix formatting.

To check further if this was the source of the ^M line endings, script.r was converted to unix formatting via dos2unix script.r & verified that 0d 0a was converted to 0a using hexdump -C as above. I performed a merge using Meld in attempting to replicate the process which yielded ^M line endings in my script's. I re-oppened both files in Emacs/ESS and found no ^M line endings. Short of converting script.r back to dos formatting and repeating the above procedure to see if the ^M line endings re-appear, i believe i've solved my ^M issue, which simply is that, unbeknownst to me, one of my files was dos formatted. My take home message: in a Windows dominated environ, never assume that one's personal linux environment doesn't contain DOS bits. Or line endings.

On 12/12/12 17:17, Karl Brand wrote:


On 12/12/12 17:08, Michael J Gruber wrote:
Karl Brand venit, vidit, dixit 12.12.2012 16:34:


On 12/12/12 15:57, Michael J Gruber wrote:
Karl Brand venit, vidit, dixit 11.12.2012 13:33:
Esteemed Git users,

What i do:

1. Create a script.r using Emacs/ESS.
2. Make some modifications to script.r with the nice diff gui, Meld
3. Commit these modifications using git commit -am "my message"
4. Reopen script.r in Emacs/ESS to continue working.

The lines added (&/edited ?) using Meld all end with ^M which i
certainly don't want. Lines not added/edited with Meld do NOT end
with ^M.

What happens if you leave out step 3? If the same happens then Meld is
the culprit. (Unless you've set some special options, git does not
modify your file on commit, so this can't be git related.)


Leaving out step 3. results in exactly the same thing. Thus Git doesn't
appear to be responsible for the ^M's. Thanks a lot for your effort on
this and my apologies for not taking the care to dissect this more
carefully as you suggested. Over to the Meld mailing list...

I didn't mean to shy you away ;)

Applying recent lessons form StackO'flow :P

Could it be that there is a ^M very early in the file (or rather
something else which isn't covered by dos2unix) so that Meld thinks it's
DOS and inserts line endings as DOS? At least that's what vim would do.

If there is i don't find it using Emacs, but Emacs may only show what
dos2unix sees... Will post back the Meld insights (here's hoping!)

In any case, Meld people over there should know (or get to know) that
effect.

There are plenty of posts around about these being line endings
used for
windows which can appear when working on a script under a *nix OS
which
has previously been edited in a Windows OS. This is not the case
here -
everything is taking place on Ubuntu 12.04.

FWIW: the directory is being synced by dropbox; and in Meld,
Preferences
   > Encoding tab, "utf8" is entered in the text box.

Current work around is running in a terminal: dos2unix
/path/to/script.r
which strips the ^M's

But this just shouldn't be necessary and I'd really appreciate the
reflections & advice on how to stop inducing these ^M's !

With thanks,

Karl

(re)posted here as suggested off topic at SO:
http://stackoverflow.com/questions/13799631/create-script-r-in-emacs-modify-with-meld-git-commit-reopen-in-emacs-m






--
Karl Brand
Dept of Cardiology and Dept of Bioinformatics
Erasmus MC
Dr Molewaterplein 50
3015 GE Rotterdam
T +31 (0)10 703 2460 |M +31 (0)642 777 268 |F +31 (0)10 704 4161
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]