Skip to content

Commit b9c6254

Browse files
committed
filter-repo: fix cache of file renames
Users may have long lists of --path, --path-rename, --path-regex, etc. flags (or even a --paths-from-file option with a lot of entries in the file). In such cases, we may have to compare any given path against a lot of different values. In order to avoid having to repeat that long list of comparisons every time a given path is updated, we long ago added a cache of the renames so that we can compute the new name for a path once and then just reuse it each time a new commit updates the old filepath. Sadly, I flubbed the implementation and instead of setting cache[oldname] = newname I somehow did the boneheaded cache[newname] = newname For most repositories and rewrites, this would just have the effect of making the cache useless, but it could wreak various kinds of havoc if a newname matched the oldname of some other file. Make sure we record the mapping from OLDNAME to newname to fix these issues. Signed-off-by: Elijah Newren <[email protected]>
1 parent 85c8e36 commit b9c6254

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

git-filter-repo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3254,11 +3254,12 @@ class RepoFilter(object):
32543254
if change.filename in self._newnames:
32553255
change.filename = self._newnames[change.filename]
32563256
else:
3257+
original_filename = change.filename
32573258
change.filename = newname(args.path_changes, change.filename,
32583259
args.use_base_name, args.inclusive)
32593260
if self._filename_callback:
32603261
change.filename = self._filename_callback(change.filename)
3261-
self._newnames[change.filename] = change.filename
3262+
self._newnames[original_filename] = change.filename
32623263
if not change.filename:
32633264
continue # Filtering criteria excluded this file; move on to next one
32643265
if change.filename in new_file_changes:

0 commit comments

Comments
 (0)