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

[PATCH 1/3] Fix gitlink index entry filesystem matching

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Apr 13, 2007, 16:24 UTC
Message-ID
<Pine.LNX.4.64.0704130923440.28042@woody.linux-foundation.org>
In-Reply-To
<Pine.LNX.4.64.0704130919070.28042@woody.linux-foundation.org>

The code to match up index entries with the filesystem was stupidly broken. We shouldn't compare the filesystem stat() information with S_IFDIRLNK, since that's purely a git-internal value, and not what the filesystem uses (on the filesystem, it's just a regular directory).

Also, don't bother to make the stat() time comparisons etc for DIRLNK entries in ce_match_stat_basic(), since we do an exact match for these things, and the hints in the stat data simply doesn't matter.

This fixes "git status" with submodules that haven't been checked out in the supermodule.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 read-cache.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index 4040fac..72d7d7c 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -123,9 +123,9 @@ static int ce_modified_check_fs(struct cache_entry *ce, struct stat *st)
 		if (ce_compare_link(ce, xsize_t(st->st_size)))
 			return DATA_CHANGED;
 		break;
-	case S_IFDIRLNK:
-		/* No need to do anything, we did the exact compare in "match_stat_basic" */
-		break;
+	case S_IFDIR:
+		if (S_ISDIRLNK(ntohl(ce->ce_mode)))
+			return 0;
 	default:
 		return TYPE_CHANGED;
 	}
@@ -156,7 +156,7 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
 			changed |= TYPE_CHANGED;
 		else if (ce_compare_gitlink(ce))
 			changed |= DATA_CHANGED;
-		break;
+		return changed;
 	default:
 		die("internal error: ce_mode is %o", ntohl(ce->ce_mode));
 	}
-- 
1.5.1.1.786.gdc49a-dirty
Previous: Linus TorvaldsNext: Linus Torvalds
Message 2 of 4 in “resend/cleanup: Fix up subproject support”
  1. 0/3 resend/cleanup: Fix up subproject supportLinus Torvalds, Apr 13, 2007
  2. 1/3 Fix gitlink index entry filesystem matchingLinus Torvalds, Apr 13, 2007
  3. 2/3 Teach git list-objects logic to not follow gitlinksLinus Torvalds, Apr 13, 2007
  4. 3/3 Teach "git-read-tree -u" to check out submodules as a directoryLinus Torvalds, Apr 13, 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.