summaryrefslogtreecommitdiff
path: root/object-file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-11-24 15:46:39 -0800
committerJunio C Hamano <gitster@pobox.com>2025-11-24 15:46:40 -0800
commitd91d79f26d5f2fb0468f42bf5d44356dce15a414 (patch)
treede53faa3734dbc893bceabc212dfdbd70ffa5acf /object-file.c
parent54f7817456940bb1f72cb747328e5fde75307dc3 (diff)
parent6fe288bfbcbbabc3d399dd71f876dccf71affff0 (diff)
Merge branch 'bc/submodule-force-same-hash'
Adding a repository that uses a different hash function is a no-no, but "git submodule add" did nt prevent it, which has been corrected. * bc/submodule-force-same-hash: read-cache: drop submodule check from add_to_cache() object-file: disallow adding submodules of different hash algo
Diffstat (limited to 'object-file.c')
-rw-r--r--object-file.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/object-file.c b/object-file.c
index 4675c8ed6b..a7438b6205 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1661,7 +1661,11 @@ int index_path(struct index_state *istate, struct object_id *oid,
strbuf_release(&sb);
break;
case S_IFDIR:
- return repo_resolve_gitlink_ref(istate->repo, path, "HEAD", oid);
+ if (repo_resolve_gitlink_ref(istate->repo, path, "HEAD", oid))
+ return error(_("'%s' does not have a commit checked out"), path);
+ if (&hash_algos[oid->algo] != istate->repo->hash_algo)
+ return error(_("cannot add a submodule of a different hash algorithm"));
+ break;
default:
return error(_("%s: unsupported file type"), path);
}