Skip to content

Commit

Permalink
filter-repo: avoid parsing the repository refs repeatedly
Browse files Browse the repository at this point in the history
In commit 704e258 (filter-repo: limit searches for ref values to
actual refs, 2024-10-21), we added code to be more careful to only
look for ref values corresponding to actual repository refs, but in
doing so, added a bug where we'd repeatedly invoke `git show-ref`
and parse the output, once for every updated ref.  This could be
quite slow, and was entirely unnecessary.  Part of the code was in
place to avoid this, but the key missing setting was overlooked.

Signed-off-by: Elijah Newren <newren@gmail.com>
  • Loading branch information
newren committed Feb 19, 2025
1 parent ec8cb66 commit ccc1885
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions git-filter-repo
Original file line number Diff line number Diff line change
Expand Up @@ -4630,6 +4630,7 @@ class RepoFilter(object):
if not new_refs_initialized:
target_working_dir = self._args.target or b'.'
new_refs = GitUtils.get_refs(target_working_dir)
new_refs_initialized = True
if refname in new_refs:
new_hash = new_refs[refname]
else:
Expand All @@ -4639,6 +4640,7 @@ class RepoFilter(object):
if not new_refs_initialized:
target_working_dir = self._args.target or b'.'
new_refs = GitUtils.get_refs(target_working_dir)
new_refs_initialized = True
for ref, new_hash in new_refs.items():
if ref not in orig_refs and not ref.startswith(b'refs/replace/'):
old_hash = b'0'*len(new_hash)
Expand Down

0 comments on commit ccc1885

Please sign in to comment.