Skip to content

Commit 1db2f69

Browse files
committed
filter-repo: avoid depending on wc binary being present
rev-list already has --count option anyway, so piping output to wc -l to count the number of lines was a total waste of time. Plus, it might cause failures for the testsuite on some Windows boxes. Signed-off-by: Elijah Newren <[email protected]>
1 parent 9a210a1 commit 1db2f69

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

git-filter-repo

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,16 +1496,13 @@ class GitUtils(object):
14961496
args = ['--all']
14971497
if len(args) == 1 and isinstance(args[0], list):
14981498
args = args[0]
1499-
p1 = subproc.Popen(["git", "rev-list"] + args,
1500-
bufsize=-1,
1501-
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
1502-
cwd=repo)
1503-
p2 = subproc.Popen(["wc", "-l"], stdin=p1.stdout, stdout=subprocess.PIPE)
1504-
count = int(p2.communicate()[0])
1505-
if p1.poll() != 0:
1499+
p = subproc.Popen(["git", "rev-list", "--count"] + args,
1500+
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
1501+
cwd=repo)
1502+
if p.wait() != 0:
15061503
raise SystemExit(_("%s does not appear to be a valid git repository")
15071504
% decode(repo))
1508-
return count
1505+
return int(p.stdout.read())
15091506

15101507
@staticmethod
15111508
def get_total_objects(repo):

0 commit comments

Comments
 (0)