diff --git a/src/workflow/ArcanistPatchWorkflow.php b/src/workflow/ArcanistPatchWorkflow.php --- a/src/workflow/ArcanistPatchWorkflow.php +++ b/src/workflow/ArcanistPatchWorkflow.php @@ -714,9 +714,6 @@ throw new ArcanistUsageException(pht('Unable to apply patch!')); } - // in case there were any submodule changes involved - $repository_api->execPassthru('submodule update --init --recursive'); - if ($this->shouldCommit()) { if ($bundle->getFullAuthor()) { $author_cmd = csprintf('--author=%s', $bundle->getFullAuthor()); @@ -754,6 +751,11 @@ } } + // Synchronize submodule state, since the patch may have made changes + // to ".gitmodules". We do this after we finish managing branches so + // the behavior is correct under "--nobranch"; see PHI648. + $repository_api->execPassthru('submodule update --init --recursive'); + echo phutil_console_format( "** %s ** %s\n", pht('OKAY'),