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

Re: autoCRLF, git status, git-gui, what is the desired behavior?

From
Junio C Hamano <junkio@cox.net>
Date
Feb 25, 2007, 19:54 UTC
Message-ID
<7vlkimrp1f.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<45E1E47C.5090908@verizon.net>
Mark Levedahl <mlevedahl@verizon.net> writes:
Show 21 quoted lines
> I am trying autoCRLF in git compiled from next (75415c455dd307), find
> some behavior that is probably different than desired dealing with a
> file where the only changes are to line endings:
>
> create a text file (foo) with \n endings, check it in.
> $ u2d foo
> $ git diff foo
> diff --git a/foo b/foo
> $ git status
> # On branch master
> # Changed but not updated:
> #   (use "git add <file>..." to update what will be committed)
> #
> #       modified:   foo
> #
> $ git ci -m 'x' foo
> # On branch master
> nothing to commit (working directory clean)
>
> So, git commit will not check in the file, but git status shows an
> unclean file and git diff shows no actual differences.

Unless you are doing something other than what you demonstrated above, I think what 'diff' and 'commit' steps show is expected, even without autoCRLF. 'git status' might be buggy.

	create a file (foo), check it in.
	$ touch foo
        $ git diff foo
        diff --git a/foo b/foo
        $ git commit -m 'x' foo
        # On branch master
        nothing to commit (working directory clean)

So in order to validate my conjecture that 'git-status' is buggy, can you try this:

	(1) Do your sequence from "create a text file (foo) with
            \n endings" to "git ci -m 'x' foo", as you depicted
            above.
	(2) Without doing anything else, run "git diff" again, 

With my sequence above, "git diff" should say nothing because "update-index --refresh" run inside "git-status" (and "git-commit") would notice 'foo' has not changed.

Ah, I know what is going on. "update-index --refresh" notices that lstat(2) says the size is different between what is recorded in the index, and does not actually compare and refresh the entry.

But that is a very important optimization, and I do not think we would want to cripple that for autoCRLF.

I think this should work for you.
        create a text file (foo) with \n endings, check it in.
        $ u2d foo
	$ git update-index foo
        $ git diff foo
        $ git status
	$ git commit

I think the same --refresh check kicks in for "git add" (I did not try), so if you replace the above "git update-index foo" with "git add foo" it may not work. You would want to try that, too.

Previous: Mark LevedahlNext: Junio C Hamano
Message 2 of 11 in “autoCRLF, git status, git-gui, what is the desired behavior?”
  1. Mark LevedahlFeb 25, 2007
  2. Junio C HamanoFeb 25, 2007
  3. Junio C HamanoFeb 25, 2007
  4. Mark LevedahlFeb 25, 2007
  5. Junio C HamanoFeb 25, 2007
  6. Mark LevedahlFeb 25, 2007
  7. Mark LevedahlFeb 25, 2007
  8. Mark LevedahlFeb 25, 2007
  9. Shawn O. PearceFeb 26, 2007
  10. Junio C HamanoFeb 26, 2007
  11. Shawn O. PearceFeb 26, 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.