Skip to content

Commit eef7190

Browse files
jonathantanmygitster
authored andcommitted
object-file: only register submodule ODB if needed
In a35e03d ("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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 155b517 commit eef7190

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

object-file.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,14 @@ static int do_oid_object_info_extended(struct repository *r,
16141614
break;
16151615
}
16161616

1617-
if (register_all_submodule_odb_as_alternates())
1617+
/*
1618+
* If r is the_repository, this might be an attempt at
1619+
* accessing a submodule object as if it were in the_repository
1620+
* (having called add_submodule_odb() on that submodule's ODB).
1621+
* If any such ODBs exist, register them and try again.
1622+
*/
1623+
if (r == the_repository &&
1624+
register_all_submodule_odb_as_alternates())
16181625
/* We added some alternates; retry */
16191626
continue;
16201627

0 commit comments

Comments
 (0)