summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Brown <jed@59A2.org>2014-07-19 11:00:09 -0600
committerJed Brown <jed@59A2.org>2014-07-19 11:00:09 -0600
commit11f2b6c44c42a96a795062aac2777e67a60a0cc3 (patch)
treee51ea33f4f7bac939bd097bf28b86263f9dba0ae
parent074e89199f880146c0402a8c24e1136bf2bf0414 (diff)
parentbcdbb1cc04f5f290ffb53800032d3a2fe79b97db (diff)
downloadgit-fat-11f2b6c44c42a96a795062aac2777e67a60a0cc3.tar.gz
Merge branch 'improve_referenced_objects_performance' of github:jmurty/git-fat (PR #37)
* 'improve_referenced_objects_performance' of github:jmurty/git-fat: Avoid potential infinite loop if unexpected EOF received from cat-file
-rwxr-xr-xgit-fat15
1 files changed, 11 insertions, 4 deletions
diff --git a/git-fat b/git-fat
index 0e5eaa7..ae11dad 100755
--- a/git-fat
+++ b/git-fat
@@ -326,16 +326,23 @@ class GitFat(object):
# is small enough to read into memory and process
content = ''
while bytes_read < size:
- content += p3.stdout.read(size - bytes_read)
- bytes_read = len(content)
+ data = p3.stdout.read(size - bytes_read)
+ if not data:
+ break # EOF
+ content += data
+ bytes_read += len(data)
try:
fathash = self.decode(content)[0]
referenced.add(fathash)
except GitFat.DecodeError:
pass
# Consume LF record delimiter in `cat-file --batch` output
- while not p3.stdout.read(1):
- pass
+ bytes_read = 0
+ while bytes_read < 1:
+ data = p3.stdout.read(1)
+ if not data:
+ break # EOF
+ bytes_read += len(data)
# Ensure everything is cleaned up
cut_thread.join()
filter_thread.join()