Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2021-10-09 00:08:19 +0300
committerJunio C Hamano <gitster@pobox.com>2021-10-09 01:06:06 +0300
commit13a2f620b27c0fa29de026de5d74a2434c565ece (patch)
tree1e35f6c3af73eae9296ebec5d671ab2a8eed8f3c /submodule.c
parenteef71904ff68e90f2db37aa9e25fe82c3fccf2a0 (diff)
submodule: pass repo to check_has_commit()
Pass the repo explicitly when calling check_has_commit() to avoid relying on add_submodule_odb(). With this commit and the parent commit, the last remaining tests no longer rely on add_submodule_odb(), so mark these tests accordingly. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'submodule.c')
-rw-r--r--submodule.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/submodule.c b/submodule.c
index 62beb8fd5f..4bf552b0e5 100644
--- a/submodule.c
+++ b/submodule.c
@@ -928,23 +928,33 @@ struct has_commit_data {
static int check_has_commit(const struct object_id *oid, void *data)
{
struct has_commit_data *cb = data;
+ struct repository subrepo;
+ enum object_type type;
- enum object_type type = oid_object_info(cb->repo, oid, NULL);
+ if (repo_submodule_init(&subrepo, cb->repo, cb->path, null_oid())) {
+ cb->result = 0;
+ goto cleanup;
+ }
+
+ type = oid_object_info(&subrepo, oid, NULL);
switch (type) {
case OBJ_COMMIT:
- return 0;
+ goto cleanup;
case OBJ_BAD:
/*
* Object is missing or invalid. If invalid, an error message
* has already been printed.
*/
cb->result = 0;
- return 0;
+ goto cleanup;
default:
die(_("submodule entry '%s' (%s) is a %s, not a commit"),
cb->path, oid_to_hex(oid), type_name(type));
}
+cleanup:
+ repo_clear(&subrepo);
+ return 0;
}
static int submodule_has_commits(struct repository *r,