Skip to content

Commit

Permalink
filter-repo: avoid depending on wc binary being present
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
newren committed Apr 1, 2021
1 parent 9a210a1 commit 1db2f69
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions git-filter-repo
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 1db2f69

Please sign in to comment.