[git rebase-update] Handle error when chdir'ing to original workdir.
BUG=
Change-Id: I1dc7f20eea3f4b1be9179aa6d77bdee08ab8a04f
Reviewed-on: https://chromium-review.googlesource.com/431576
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
diff --git a/git_rebase_update.py b/git_rebase_update.py
index 5963f03..0d8710d 100755
--- a/git_rebase_update.py
+++ b/git_rebase_update.py
@@ -311,8 +311,16 @@
% (return_branch, root_branch)
)
git.run('checkout', root_branch)
+
+ # return_workdir may also not be there any more.
if return_workdir:
- os.chdir(return_workdir)
+ try:
+ os.chdir(return_workdir)
+ except OSError as e:
+ print (
+ "Unable to return to original workdir %r: %s"
+ % (return_workdir, e)
+ )
git.set_config(STARTING_BRANCH_KEY, '')
git.set_config(STARTING_WORKDIR_KEY, '')