Skip to main content

submodule_head_object_broken

Function submodule_head_object_broken 

Source
pub fn submodule_head_object_broken(sub_dir: &Path) -> bool
Expand description

True when a populated submodule checkout is broken: its HEAD resolves to a commit OID, but that commit object cannot be read from the submodule’s own object database.

This mirrors Git’s [is_submodule_modified], which shells out to git status --porcelain=2 inside the submodule; when the submodule’s object store is corrupt (e.g. rm -r .git/objects), that inner status fails and Git aborts the surrounding status/diff/fetch. We detect the same condition in-process so the superproject operation can return a fatal error rather than silently treating the submodule as clean (t5526 “fetching submodule into a broken repository”).

Returns false when the submodule is not checked out, has no embedded git dir, or has an unresolvable HEAD (those are handled separately by the unpopulated/placeholder logic).