From c87e36aaec74aee6a2b66839c2c4c2fe8a74ca07 Mon Sep 17 00:00:00 2001 From: Robert Iannucci Date: Mon, 23 Jan 2017 17:16:54 -0800 Subject: [PATCH] [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 Commit-Queue: Robbie Iannucci --- git_rebase_update.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/git_rebase_update.py b/git_rebase_update.py index 5963f03f1..0d8710d08 100755 --- a/git_rebase_update.py +++ b/git_rebase_update.py @@ -311,8 +311,16 @@ def main(args=None): % (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, '')