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

Re: Bug report

From
Jeff King <peff@peff.net>
Date
Oct 6, 2012, 13:31 UTC
Message-ID
<20121006133146.GD11712@sigill.intra.peff.net>
In-Reply-To
<506DB500.4010803@emsoftware.com>
On Thu, Oct 04, 2012 at 11:10:40AM -0500, John Whitney wrote:
> Thank you for your response. I do see the dilemma, but having
> no possible "unmodified" state is extremely inconvenient and,
> as shown, breaks basic git operations.

But you have asked for an impossible state. You have said "this file cannot have CR when you check it in, because we erase them". And yet the version of the file in HEAD has CRs in it. So it must appear modified with respect to HEAD. And the solution is to make a commit with the normalized content.

You said in your test script:
  # Committing test.txt or clearing .gitattributes does clear
  # the "modified" status, but those options are undesirable

Why is the commit undesirable? You have decided that CRs will no longer be tolerated in your repository (by setting .gitattributes). Now you need to record that change in history with a commit that strips out the CRs.

Show 5 quoted lines
> I guess my thought is that if git doesn't allow CRs to be checked
> in, then it should strip the CRs when checking the file out, and
> consider that form (or both forms) as "unmodified". It just
> doesn't make sense to me that files are considered modified
> immediately after checkout.

It is not about having CRs in the working tree file. Those are now considered uninteresting and stripped by git when comparing to the HEAD. The problem is that what's in your _repository_ has CRs.

I wonder if this is a fundamental misunderstanding of how the CRLF handling in git works. It is not "magically make me not care about line endings anymore". It is "the canonical version in the repo is LF-only. Strip anything coming into the repository to match that, and (optionally) add CR to anything going out to the filesystem for my convenience". But you need a flag day to update the in-repository versions to the new scheme.

-Peff
Previous: John WhitneyNext: John Whitney
Message 4 of 12 in “Bug report”
  1. John WhitneyOct 4, 2012
  2. Phil HordOct 4, 2012
  3. John WhitneyOct 4, 2012
  4. Jeff KingOct 6, 2012
  5. John WhitneyOct 7, 2012
  6. Jeff KingOct 7, 2012
  7. John WhitneyOct 9, 2012
  8. John WhitneyOct 9, 2012
  9. Andrew WongOct 4, 2012
  10. John WhitneyOct 4, 2012
  11. John WhitneyOct 4, 2012
  12. Andrew WongOct 4, 2012

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.