submodule: fix latent check_has_commit() bug
When check_has_commit() is called on a missing submodule, initialization
of the struct repository fails, but it attempts to clear the struct
anyway (which is a fatal error). This bug is masked by its only caller,
submodule_has_commits(), first calling add_submodule_odb(). The latter
fails if the submodule does not exist, making submodule_has_commits()
exit early and not invoke check_has_commit().
Fix this bug, and because calling add_submodule_odb() is no longer
necessary as of 13a2f620b2 (submodule: pass repo to
check_has_commit(), 2021-10-08), remove that call too.
This is the last caller of add_submodule_odb(), so remove that
function. (Submodule ODBs are still added as alternates via
add_submodule_odb_by_path().)
Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
b90d9f7632
commit
5fff35d880
@@ -103,12 +103,11 @@ int submodule_uses_gitfile(const char *path);
|
||||
int bad_to_remove_submodule(const char *path, unsigned flags);
|
||||
|
||||
/*
|
||||
* Call add_submodule_odb() to add the submodule at the given path to a list.
|
||||
* When register_all_submodule_odb_as_alternates() is called, the object stores
|
||||
* of all submodules in that list will be added as alternates in
|
||||
* the_repository.
|
||||
* Call add_submodule_odb_by_path() to add the submodule at the given
|
||||
* path to a list. When register_all_submodule_odb_as_alternates() is
|
||||
* called, the object stores of all submodules in that list will be
|
||||
* added as alternates in the_repository.
|
||||
*/
|
||||
int add_submodule_odb(const char *path);
|
||||
void add_submodule_odb_by_path(const char *path);
|
||||
int register_all_submodule_odb_as_alternates(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user