aboutsummaryrefslogtreecommitdiffstats
path: root/object-file.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2021-10-08 14:08:18 -0700
committerJunio C Hamano <gitster@pobox.com>2021-10-08 15:06:06 -0700
commiteef71904ff68e90f2db37aa9e25fe82c3fccf2a0 (patch)
treeeece2d56814c5a970e2b7d7aa7389724c3e4677f /object-file.c
parentmerge-{ort,recursive}: remove add_submodule_odb() (diff)
downloadgit-eef71904ff68e90f2db37aa9e25fe82c3fccf2a0.tar.gz
git-eef71904ff68e90f2db37aa9e25fe82c3fccf2a0.zip
object-file: only register submodule ODB if needed
In a35e03dee0 ("submodule: lazily add submodule ODBs as alternates", 2021-09-08), Git was taught to add all known submodule ODBs as alternates when attempting to read an object that doesn't exist, as a fallback for when a submodule object is read as if it were in the_repository. However, this behavior wasn't restricted to happen only when reading from the_repository. Fix this. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-file.c')
-rw-r--r--object-file.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/object-file.c b/object-file.c
index be4f94ecf3..0a1835fe30 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1614,7 +1614,14 @@ static int do_oid_object_info_extended(struct repository *r,
break;
}
- if (register_all_submodule_odb_as_alternates())
+ /*
+ * If r is the_repository, this might be an attempt at
+ * accessing a submodule object as if it were in the_repository
+ * (having called add_submodule_odb() on that submodule's ODB).
+ * If any such ODBs exist, register them and try again.
+ */
+ if (r == the_repository &&
+ register_all_submodule_odb_as_alternates())
/* We added some alternates; retry */
continue;