git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Bug-ish: CRLF endings and conflict markers

From
APAndy Parkins <andyparkins@gmail.com>
Date
Jan 11, 2007, 09:41 UTC
Message-ID
<200701110941.22024.andyparkins@gmail.com>
Hello,

I am sure the response to this will be "tough", however I'll mention it anyway. It wasn't a problem for me, as I know git is LF endings only, but others might be a bit confused.

 * Track a file that has CR-LF endings.  Not a problem, git works fine with 
   these and treats the CR as an extra character at the end of the line.
 * Have two branches make conflicting changes to that file
 * Merge, conflict
 * Open the file
 * Find that (almost) every line now displays with a "^M" at the end.  vim has
   found some lines that don't have CR-LF ends so dropped back to UNIX mode.
 * Be careful that your conflict resolution doesn't introduce any new lines as 
   they will not have CR-LF endings.

The "(almost)" above refers of course to the conflict markers. These have LF endings only so force the editor into UNIX mode. Assuming a binary safe editor, things will be fine if the conflict resolution is simply to remove the markers, and edit the existing lines. However, if the user adds any lines during conflict resolution, those new lines will only have LF ends.

This is a problem for compilers that are expecting CR-LF input.
Note: this is not on Windows (spit), this is simply editing a CR-LF file on 
UNIX.

The best solution is probably to use the line ending of the conflicted lines. I've had a look, but I can only fine builtin-rerere.c that generates the markers - would that be the place to make this change?

Andy
-- 
Dr Andy Parkins, M Eng (hons), MIEE
andyparkins@gmail.com
Next: Johannes Schindelin
Message 1 of 8 in “Bug-ish: CRLF endings and conflict markers”
  1. Andy ParkinsJan 11, 2007
  2. Johannes SchindelinJan 11, 2007
  3. Andy ParkinsJan 11, 2007
  4. Shawn O. PearceJan 11, 2007
  5. Johannes SchindelinJan 11, 2007
  6. Shawn O. PearceJan 11, 2007
  7. Johannes SchindelinJan 11, 2007
  8. Shawn O. PearceJan 11, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.