Skip to content

Commit 7b18e6d

Browse files
committed
filter-repo: fix --prune-degenerate=never with path filtering
When combining `--prune-degenerate never` with a `--path` specification, we could end up trying to write a parent out to the fast-import stream whose value was actually None. The problem occurs when the parents of a merge commit are filtered out by the path specification, leaving us only with no-longer-extant parents. In such a case, we need to filter out these 'None' (i.e. invalid) parents. The point of `--prune-degenerate never` is to avoid removing parents that are either the same as or an ancestor of another parent, not to avoid removing non-existent parents. Remove the non-existent parent(s). Reported-by: Gaurav Kanoongo (@gauravkanoongo on GitHub) Signed-off-by: Elijah Newren <[email protected]>
1 parent df6c865 commit 7b18e6d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

git-filter-repo

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3025,8 +3025,6 @@ class RepoFilter(object):
30253025
Returns a tuple:
30263026
(parents, new_first_parent_if_would_become_non_merge)'''
30273027

3028-
if self._args.prune_degenerate == 'never':
3029-
return parents, None
30303028
always_prune = (self._args.prune_degenerate == 'always')
30313029

30323030
# Pruning of empty commits means multiple things:
@@ -3051,6 +3049,10 @@ class RepoFilter(object):
30513049
if len(parents) < 2:
30523050
return parents, None
30533051

3052+
# Don't remove redundant parents if user doesn't want us to
3053+
if self._args.prune_degenerate == 'never':
3054+
return parents, None
3055+
30543056
# Remove duplicate parents (if both sides of history have lots of commits
30553057
# which become empty due to pruning, the most recent ancestor on both
30563058
# sides may be the same commit), except only remove parents that have

0 commit comments

Comments
 (0)