diff options
-rw-r--r-- | usr/src/tools/scripts/git-pbchk.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/usr/src/tools/scripts/git-pbchk.py b/usr/src/tools/scripts/git-pbchk.py index 63453070df..ddaa65a622 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 <garrett@damore.org> # Copyright (c) 2014, Joyent, Inc. -# Copyright (c) 2015 by Delphix. All rights reserved. +# Copyright (c) 2015, 2016 by Delphix. All rights reserved. # import getopt @@ -71,13 +71,13 @@ def git(command): try: p = subprocess.Popen(command, stdout=tmpfile, - stderr=subprocess.STDOUT) + stderr=subprocess.PIPE) except OSError, e: raise GitError("could not execute %s: %s\n" (command, e)) err = p.wait() if err != 0: - raise GitError(p.stdout.read()) + raise GitError(p.stderr.read()) tmpfile.seek(0) return tmpfile @@ -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 |