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
Mark Levedahl <mdl123@verizon.net>
Date
Feb 25, 2007, 20:51 UTC
Message-ID
<45E1F6B5.8030907@verizon.net>
In-Reply-To
<7vlkimrp1f.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 27 quoted lines
> Mark Levedahl <mlevedahl@verizon.net> writes:
> 
>> 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.

I forgot the vital "-a" argument to git commit above. Adding -a gets the desired behavior (the difference disappears). Here is a sequence that is clearly counter-intuitive:

create foo with CRLF endings, then ...
$ git config core.autocrlf input
$ git add foo
$ git commit -m x foo
Created commit a9e9d4e1b88087462a4e15ff9044fa31e16d11bc
  1 files changed, 935 insertions(+), 0 deletions(-)
  create mode 100644 foo
$ git diff
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 add foo
$ git status
# On branch master
nothing to commit (working directory clean)

--- git should not show a just checked in file as being different.
Note: a simple "git add foo" clears the above up, as would
git-update-index foo

Also, if I invoke git-gui on the above repository showing foo as modified...

1) foo shows up in the "Changed But Not Updated" list.
2) Clicking on foo gives message box with "No differences detected. ...
    Clicking the "ok" button invokes a rescan, back to step 1.
3) Adding foo to the commit list in git-gui works.
4) Committing the above from git-gui gives a commit with no
    changes (commit is made, shows up in git log, but has no
    changes associated).

--- I don't think git-gui should make create an empty commit in the 
above case.

Mark
Previous: Mark LevedahlNext: Shawn O. Pearce
Message 8 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.