Junio C Hamano <gitster@xxxxxxxxx> writes: >> + if (!is_submodule_populated_gently(ce->name, &err)) { >> + struct stat sb; >> + if (lstat(ce->name, &sb)) >> + die(_("could not stat file '%s'"), ce->name); >> + if (!(st.st_mode & S_IFDIR)) >> + unlink_or_warn(ce->name); > > We found that the path ce->name is supposed to be a submodule that > is checked out, we found that the submodule is not yet populated, we > tried to make sure what is on that path, and its failure would cause > us to die(). All that is sensible. > ... > But if that unlink fails, shouldn't we die, just like the case where > we cannot tell what is at the path ce->name? > > And if that unlink succeeds, instead of having an empty directory, > we start the "move-head" call to switch from NULL to ce->oid without > having any directory. Wouldn't we want to mkdir() here (and remove > mkdir() in submodule_move_head() if there is one---if there isn't > then I do not think this codepath would work)? In addition to mkdir(), would we also need the .git file that point into superproject's .git/modules/ too?