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 <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Mar 14, 2017 at 14:46 UTC
d6b12300676c85175bb05088c79e4b975aed820c
1 file changed
+10
-7
unpack-trees.c
+10
-7
@@ -1407,7 +1407,8 @@ static void invalidate_ce_path(const struct cache_entry *ce,
1407
* Currently, git does not checkout subprojects during a superproject
1408
* checkout, so it is not going to overwrite anything.
1409
*/
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,
1412
enum unpack_trees_error_types error_type,
1413
struct unpack_trees_options *o)
1414
{
@@ -1427,16 +1428,18 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,
1428
struct dir_struct d;
1429
char *pathbuf;
1430
int cnt = 0;
1430
- unsigned char sha1[20];
1431
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
1437
* we don't care.
1438
*/
1437
- if (!hashcmp(sha1, ce->oid.hash))
1439
+ if (!sub_head && !hashcmp(sha1, ce->oid.hash))
1440
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);
1443
}
1444
1445
/*