Skip to content

Commit ccc1885

Browse files
committed
filter-repo: avoid parsing the repository refs repeatedly
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 <[email protected]>
1 parent ec8cb66 commit ccc1885

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

git-filter-repo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4630,6 +4630,7 @@ class RepoFilter(object):
46304630
if not new_refs_initialized:
46314631
target_working_dir = self._args.target or b'.'
46324632
new_refs = GitUtils.get_refs(target_working_dir)
4633+
new_refs_initialized = True
46334634
if refname in new_refs:
46344635
new_hash = new_refs[refname]
46354636
else:
@@ -4639,6 +4640,7 @@ class RepoFilter(object):
46394640
if not new_refs_initialized:
46404641
target_working_dir = self._args.target or b'.'
46414642
new_refs = GitUtils.get_refs(target_working_dir)
4643+
new_refs_initialized = True
46424644
for ref, new_hash in new_refs.items():
46434645
if ref not in orig_refs and not ref.startswith(b'refs/replace/'):
46444646
old_hash = b'0'*len(new_hash)

0 commit comments

Comments
 (0)