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

Re: Bug-ish: CRLF endings and conflict markers

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jan 11, 2007, 10:41 UTC
Message-ID
<20070111104111.GF28309@spearce.org>
In-Reply-To
<Pine.LNX.4.63.0701111123280.22628@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 6 quoted lines
> On Thu, 11 Jan 2007, Shawn O. Pearce wrote:
> > That's a lot of work and goes very much against the Git mindset that
> > we never alter content, just store it as-is.
> 
> While that is correct, we also _use_ the content, and very much alter it 
> all the time. A diff, for example, is nothing but altered content.

Yes, of course. But we don't take A and store A' in the ODB during a commit. We always assert that if you give us A, you'll get back A. You can always ask us to compute some sort of A' later on, but that is always based on the originally stored A.

You can also ask us to combine an A and B and get some new thing C.
But again, we don't then go off and store C' instead of C.
 
Show 7 quoted lines
> > All I want is to make the user realize what they have done.  "Hey dummy, 
> > you just changed the entire file and the only difference I see for most 
> > lines is simply the addition/removal of a CR.  You shouldn't do that!".  
> > The pre-commit hook is the perfect place for that.
> 
> This sounds sensible. I mistook your task to be integrator for people you 
> can't smack.

To some extent I am. But I have patched the local Cygwin package I use to distribute Git to everyone to have a 1 line pre-commit update hook (and no other hooks) which just invokes a Perl script in /usr/local/bin, and that Perl script is also in the same Cygwin package.

So Cygwin's "feature" of making all Git hooks executable by default in a new repository plays in my favor here. The pre-commit hook is active in every repository by default, and it just execs a standard script which can be modified at any time. So I can easily update everyone's pre-commit hook at once.

Currently the hook script is just the stock one that comes with Git, except it ignores CRLF line endings. I'll likely tweak it as I'm suggesting, make the CRLF->LF/LF->CRLF check an optional feature that can be toggled on/off in the top of the script, and submit the patch to update the stock hook. Others may find the check useful.

-- 
Shawn.
Previous: Johannes Schindelin
Message 8 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.