summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2016-04-18 11:40:32 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2016-04-18 11:40:32 +0000
commit02e990d1c97baedad6a753153fb291182684bb5c (patch)
tree9c3ce2f388360b18cb835ad5c1056b221c90ba45
parent56046f267b29072fb6ea4da60520a4ed1a09c8aa (diff)
parent380fd671753dd199e149f10e9f73ec52cdfe4230 (diff)
downloadillumos-joyent-02e990d1c97baedad6a753153fb291182684bb5c.tar.gz
[illumos-gate merge]
commit 380fd671753dd199e149f10e9f73ec52cdfe4230 6913 pbchk throws an error with git rm'd files (use right fd) commit 93d2a904d17ac0073fa98bf62f89294d980c8b3d 6913 pbchk throws an error with git rm'd files
-rw-r--r--usr/src/tools/scripts/git-pbchk.py22
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