From d2fdc89ff3adcede647d9358d35a336a30bc206e Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 1 Apr 2021 11:58:16 -0700 Subject: [PATCH] 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 --- git-filter-repo | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/git-filter-repo b/git-filter-repo index 3a41d952..3e3c2cd3 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -1496,16 +1496,13 @@ class GitUtils(object): args = ['--all'] if len(args) == 1 and isinstance(args[0], list): args = args[0] - p1 = subproc.Popen(["git", "rev-list"] + args, - bufsize=-1, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, - cwd=repo) - p2 = subproc.Popen(["wc", "-l"], stdin=p1.stdout, stdout=subprocess.PIPE) - count = int(p2.communicate()[0]) - if p1.poll() != 0: + p = subproc.Popen(["git", "rev-list", "--count"] + args, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + cwd=repo) + if p.wait() != 0: raise SystemExit(_("%s does not appear to be a valid git repository") % decode(repo)) - return count + return int(p.stdout.read()) @staticmethod def get_total_objects(repo):