Skip to content

Commit d6b1230

Browse files
stefanbellergitster
authored andcommitted
unpack-trees: pass old oid to verify_clean_submodule
The check (which uses the old oid) is yet to be implemented, but this part is just a refactor, so it can go separately first. Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6e3c159 commit d6b1230

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

unpack-trees.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,8 @@ static void invalidate_ce_path(const struct cache_entry *ce,
14071407
* Currently, git does not checkout subprojects during a superproject
14081408
* checkout, so it is not going to overwrite anything.
14091409
*/
1410-
static int verify_clean_submodule(const struct cache_entry *ce,
1410+
static int verify_clean_submodule(const char *old_sha1,
1411+
const struct cache_entry *ce,
14111412
enum unpack_trees_error_types error_type,
14121413
struct unpack_trees_options *o)
14131414
{
@@ -1427,16 +1428,18 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,
14271428
struct dir_struct d;
14281429
char *pathbuf;
14291430
int cnt = 0;
1430-
unsigned char sha1[20];
14311431

1432-
if (S_ISGITLINK(ce->ce_mode) &&
1433-
resolve_gitlink_ref(ce->name, "HEAD", sha1) == 0) {
1434-
/* If we are not going to update the submodule, then
1432+
if (S_ISGITLINK(ce->ce_mode)) {
1433+
unsigned char sha1[20];
1434+
int sub_head = resolve_gitlink_ref(ce->name, "HEAD", sha1);
1435+
/*
1436+
* If we are not going to update the submodule, then
14351437
* we don't care.
14361438
*/
1437-
if (!hashcmp(sha1, ce->oid.hash))
1439+
if (!sub_head && !hashcmp(sha1, ce->oid.hash))
14381440
return 0;
1439-
return verify_clean_submodule(ce, error_type, o);
1441+
return verify_clean_submodule(sub_head ? NULL : sha1_to_hex(sha1),
1442+
ce, error_type, o);
14401443
}
14411444

14421445
/*

0 commit comments

Comments
 (0)