From 0a9265e2d633b608090eff79ab4553f0e1c8c7c4 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 30 Sep 2019 23:59:27 -0400 Subject: diff: handle errors gracefully If `git diff` fails in any project checkout (e.g. an incomplete sync), make sure we print that error clearly rather than blowing up, and exit non-zero in the process. Bug: https://crbug.com/gerrit/11613 Change-Id: I12f278427cced20f23f8047e7e3dba8f442ee25e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/239236 Reviewed-by: David Pursehouse Tested-by: Mike Frysinger --- subcmds/diff.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'subcmds/diff.py') diff --git a/subcmds/diff.py b/subcmds/diff.py index 1f3abd86..fa41e70e 100644 --- a/subcmds/diff.py +++ b/subcmds/diff.py @@ -37,5 +37,8 @@ to the Unix 'patch' command. help='Paths are relative to the repository root') def Execute(self, opt, args): + ret = 0 for project in self.GetProjects(args): - project.PrintWorkTreeDiff(opt.absolute) + if not project.PrintWorkTreeDiff(opt.absolute): + ret = 1 + return ret -- cgit v1.2.3-54-g00ecf