Re: [PATCH 16/18] entry.c: update submodules when interesting
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 7, 2017, 23:04 UTC
- Message-ID
- <xmqqy3wg4rko.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <xmqqtw746758.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 20 quoted lines
>> + 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?