From aad56eca6aa219f458761559b3056eeb83b649f5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 3 Feb 2012 15:44:59 -0800 Subject: [PATCH] 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 --- src/workflow/land/ArcanistLandWorkflow.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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;