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

[PATCH 3/4] unpack-trees: Fix same() for submodules

From
Stefan Beller <sbeller@google.com>
Date
Dec 20, 2017, 22:17 UTC
Message-ID
<20171220221725.129162-4-sbeller@google.com>
In-Reply-To
<20171220221725.129162-1-sbeller@google.com>

The function same(a, b) is used to check if two entries a and b are the same. As the index contains the staged files the same() function can be used to check if files between a given revision and the index are the same.

In case of submodules, the gitlink entry is showing up as not modified despite potential changes inside the submodule.

Fix the function to examine submodules by looking inside the submodule. This patch alone doesn't affect any correctness garantuees, but in combination with the next patch this fixes the new test introduced earlier in this series.

This may be a slight performance regression as now we have to inspect any submodule thouroughly.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 unpack-trees.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/unpack-trees.c b/unpack-trees.c
index bf8b602901..4d839e8edb 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1427,6 +1427,8 @@ static int same(const struct cache_entry *a, const struct cache_entry *b)
 		return 1;
 	if ((a->ce_flags | b->ce_flags) & CE_CONFLICTED)
 		return 0;
+	if (S_ISGITLINK(b->ce_mode) && should_update_submodules())
+		return !oidcmp(&a->oid, &b->oid) && !is_submodule_modified(b->name, 0);
 	return a->ce_mode == b->ce_mode &&
 	       !oidcmp(&a->oid, &b->oid);
 }
-- 
2.15.1.620.gb9897f4670-goog
Previous: Stefan BellerNext: Junio C Hamano
Message 4 of 7 in “[PATCHv2 0/4] Fix --recurse-submodules for submodule worktree changes”
  1. Stefan BellerDec 20, 2017
  2. 1/4 t/lib-submodule-update.sh: clarify testStefan Beller, Dec 20, 2017
  3. 2/4 t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulesStefan Beller, Dec 20, 2017
  4. 3/4 unpack-trees: Fix same() for submodulesStefan Beller, Dec 20, 2017
  5. Junio C HamanoDec 22, 2017
  6. 4/4 submodule: submodule_move_head omits old argument in forced caseStefan Beller, Dec 20, 2017
  7. Junio C HamanoDec 22, 2017

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.