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

Re: [TESTCASE] Failing 'git am' when core.autocrlf=true

From
Marius Storm-Olsen <marius@trolltech.com>
Date
Aug 23, 2007, 20:11 UTC
Message-ID
<46CDE9E9.8070702@trolltech.com>
In-Reply-To
<alpine.LFD.0.999.0708231153150.30176@woody.linux-foundation.org>
Linus Torvalds wrote:
Show 20 quoted lines
> So the call-chain for this is:
> 
> 	cmd_write_tree ->
> 	  write_tree ->
> 	    write_index ->
> 	      ce_smudge_racily_clean_entry -> 
> 		ce_modified_check_fs ->
> 		  ce_compare_data ->
> 		    index_fd ->
> 		      convert_to_git ->
> 			** wrong answer unless auto_crlf is set **
> 
> 		and now "ce_smudge_racily_clean_entry()" will do
> 			ce->ce_size = htonl(0);
> 
> and the one-liner fix I sent out is actually the right fix.
> 
> This was harder to find than it should have been, because it
> actually depends on the datestamp of the index file matching the
> datestamp of the file in question!

Thanks for the detailed analysis of the chain of events. It really helps understand the inner-workings of Git.

I also tried to track this down after your initial patch, but couldn't find it. The fact that the index is smudged at the time of the second commit, so the third failed, made me look in the wrong place.

How about adding a trace for the smudged case, so it's easier to find similar issues in the future?

-- .marius

From b858610ff4cd42f57a05c815a3e3b43428d67f99 Mon Sep 17 00:00:00 2001
From: Marius Storm-Olsen <mstormo_git@storm-olsen.com>
Date: Thu, 23 Aug 2007 22:03:35 +0200
Subject: [PATCH] Add a trace to more easily show that the index has been smudged.
Signed-off-by: Marius Storm-Olsen <mstormo_git@storm-olsen.com>
---
 read-cache.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index 849e8d6..000451c 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1088,6 +1088,7 @@ static void ce_smudge_racily_clean_entry(struct cache_entry *ce)
 		 * for "frotz" stays 6 which does not match the filesystem.
 		 */
 		ce->ce_size = htonl(0);
+		trace_printf("trace: index: Index object for '%s' smudged due to being racily clean\n", ce->name);
 	}
 }
 
-- 
1.5.3.rc4.mingw.2.3.g3318a-dirty
Previous: Junio C Hamano
Message 8 of 8 in “[TESTCASE] Failing 'git am' when core.autocrlf=true”
  1. Marius Storm-OlsenAug 23, 2007
  2. Linus TorvaldsAug 23, 2007
  3. Marius Storm-OlsenAug 23, 2007
  4. Junio C HamanoAug 23, 2007
  5. Linus TorvaldsAug 23, 2007
  6. Linus TorvaldsAug 23, 2007
  7. Junio C HamanoAug 23, 2007
  8. Marius Storm-OlsenAug 23, 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.