On Mon, May 1, 2017 at 11:36 AM, Brandon Williams <bmwill@xxxxxxxxxx> wrote: > if (flags & REATTACH_HEAD_DIE_ON_ERROR) > die(...); > > return -1; > > It just feels weird to me to have the inverted logic, that's my opinion > though. Yeah, me too. But my feelings were not as important as staying under 80 characters a line. And as the error message is longer than the "return -1", I wanted to have it not indented yet another level. > >> + } >> + >> + if (!sub->branch) { >> + if (!(flags & REATTACH_HEAD_DIE_ON_ERROR)) >> + return -1; >> + die(_("no branch configured to follow for submodule '%s'"), >> + sub->path); >> + } >> + >> + /* lookup branch value in .gitmodules */ >> + if (strcmp(".", sub->branch)) { >> + branch = sub->branch; >> + } else { >> + /* special care for '.': Is the superproject on a branch? */ >> + struct object_id oid; >> + branch = resolve_refdup("HEAD", 0, oid.hash, NULL); >> + if (!branch) { >> + if (!(flags & REATTACH_HEAD_DIE_ON_ERROR)) >> + return -1; >> + die(_("Not on any branch, but submodule configured to follow superprojects branch")); >> + } >> + } >> + >> + if (!strcmp("HEAD", branch)) >> + return 0; > > So this is the case where the superproject is in a detached-HEAD state? and the submodule config is branch='.' > In that case then we don't need to continue because if the superproject > isn't on a branch, then there isn't a reason the submodule should be on > a branch. agreed.