From d67e7158df1e98a04882fd10696adb65a0c3f511 Mon Sep 17 00:00:00 2001 From: Daniel Cheng Date: Thu, 13 Apr 2017 01:21:03 -0700 Subject: [PATCH] Fix GetOldContents() to return an empty string if the file didn't exist. Bug: 700108 Change-Id: I9010aa3b4aa467c91b93ffac924b3ec5a16cfaa2 Reviewed-on: https://chromium-review.googlesource.com/476590 Reviewed-by: Jochen Eisinger Commit-Queue: Daniel Cheng --- scm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scm.py b/scm.py index 613284556..88016dccd 100644 --- a/scm.py +++ b/scm.py @@ -259,7 +259,10 @@ class GIT(object): if not branch: branch = GIT.GetUpstreamBranch(cwd) command = ['show', '%s:%s' % (branch, filename)] - return GIT.Capture(command, cwd=cwd, strip_out=False) + try: + return GIT.Capture(command, cwd=cwd, strip_out=False) + except subprocess2.CalledProcessError: + return '' @staticmethod def GenerateDiff(cwd, branch=None, branch_head='HEAD', full_move=False,