From: epriestley Date: Fri, 3 Feb 2012 23:44:59 +0000 (-0800) Subject: Switch back to former branch after landing some other branch X-Git-Tag: conduit-4~157 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=aad56eca6aa219f458761559b3056eeb83b649f5;p=arcanist.git Switch back to former branch after landing some other branch Summary: If you're on A and run "arc land B", run "git checkout A" after everything's said and done. Test Plan: Ran "arc land B" from A, got switched back to it. Reviewers: davidreuss, kdeggelman, btrahan Reviewed By: btrahan CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1568 --- diff --git a/src/workflow/land/ArcanistLandWorkflow.php b/src/workflow/land/ArcanistLandWorkflow.php index f81f7349..76f10da6 100644 --- a/src/workflow/land/ArcanistLandWorkflow.php +++ b/src/workflow/land/ArcanistLandWorkflow.php @@ -109,6 +109,8 @@ EOTEXT $this->requireCleanWorkingCopy(); $repository_api->parseRelativeLocalCommit(array($remote.'/'.$onto)); + $old_branch = $repository_api->getBranchName(); + execx( '(cd %s && git checkout %s)', $repository_api->getPath(), @@ -284,6 +286,18 @@ EOTEXT $branch); } + // If we were on some branch A and the user ran "arc land B", switch back + // to A. + if (($old_branch != $branch) && ($old_branch != $onto)) { + execx( + '(cd %s && git checkout %s)', + $repository_api->getPath(), + $old_branch); + echo phutil_console_format( + "Switched back to branch **%s**.\n", + $old_branch); + } + echo "Done.\n"; return 0;