From 93d2a904d17ac0073fa98bf62f89294d980c8b3d Mon Sep 17 00:00:00 2001 From: Paul Dagnelie Date: Thu, 14 Apr 2016 15:44:14 -0700 Subject: 6913 pbchk throws an error with git rm'd files Reviewed by: Matthew Ahrens Reviewed by: Prakash Surya Reviewed by: Dan McDonald Reviewed by: Igor Kozhukhov Approved by: Robert Mustacchi --- usr/src/tools/scripts/git-pbchk.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'usr/src/tools/scripts/git-pbchk.py') diff --git a/usr/src/tools/scripts/git-pbchk.py b/usr/src/tools/scripts/git-pbchk.py index def3b2617e..ce016b684d 100644 --- a/usr/src/tools/scripts/git-pbchk.py +++ b/usr/src/tools/scripts/git-pbchk.py @@ -19,7 +19,7 @@ # Copyright 2008, 2012 Richard Lowe # Copyright 2014 Garrett D'Amore # Copyright (c) 2014, Joyent, Inc. -# Copyright (c) 2015 by Delphix. All rights reserved. +# Copyright (c) 2015, 2016 by Delphix. All rights reserved. # import getopt @@ -164,9 +164,7 @@ def git_file_list(parent, paths=None): ret = set() for fname in p: - res = git("diff %s HEAD %s" % (parent, fname)) - empty = not res.readline() - if fname and not fname.isspace() and fname not in ret and not empty: + if fname and not fname.isspace() and fname not in ret: ret.add(fname.strip()) return ret @@ -201,7 +199,17 @@ def gen_files(root, parent, paths, exclude): for f in git_file_list(parent, paths): f = relpath(f, '.') - if (os.path.exists(f) and select(f) and not exclude(f)): + try: + res = git("diff %s HEAD %s" % (parent, f)) + except GitError, e: + # This ignores all the errors that can be thrown. Usually, this means + # that git returned non-zero because the file doesn't exist, but it + # could also fail if git can't create a new file or it can't be + # executed. Such errors are 1) unlikely, and 2) will be caught by other + # invocations of git(). + continue + empty = not res.readline() + if (os.path.exists(f) and not empty and select(f) and not exclude(f)): yield f return ret -- cgit v1.2.3