filter-repo: handle typechange modifications when first parent is pruned

Commit 509a624b (filter-repo: fix issue with pruning of empty commits,
2019-10-03) added code to get a new list of file changes when the first
parent was pruned.  However, this logic did not handle cases where one
of the file modifications was a typechange.  Add the necessary logic to
handle that case.

Signed-off-by: Elijah Newren <newren@gmail.com>
pull/71/head
Elijah Newren 4 years ago
parent 4f84a74ada
commit e11343e504

@ -1595,7 +1595,7 @@ class GitUtils(object):
oldmode, mode, oldhash, newhash, changetype = fileinfo.split()
if changetype == b'D':
file_changes.append(FileChange(b'D', path))
elif changetype in (b'A', b'M'):
elif changetype in (b'A', b'M', b'T'):
identifier = HASH_TO_ID.get(newhash, newhash)
file_changes.append(FileChange(b'M', path, identifier, mode))
else: # pragma: no cover

@ -1408,6 +1408,43 @@ test_expect_success 'degenerate merge with non-matching filenames' '
)
'
test_expect_success 'degenerate merge with typechange' '
test_create_repo degenerate_merge_with_typechange &&
(
cd degenerate_merge_with_typechange &&
touch irrelevant_file &&
git add irrelevant_file &&
git commit -m "Irrelevant, unwanted file"
git branch A &&
git checkout --orphan B &&
git reset --hard &&
echo hello >world &&
git add world &&
git commit -m "greeting" &&
echo goodbye >planet &&
git add planet &&
git commit -m "farewell" &&
git checkout A &&
git merge --allow-unrelated-histories --no-commit B &&
rm world &&
ln -s planet world &&
git add world &&
git commit &&
git filter-repo --force --path world &&
test_path_is_missing irrelevant_file &&
test_path_is_missing planet &&
echo world >expect &&
git ls-files >actual &&
test_cmp expect actual &&
test_line_count = 2 <(git log --oneline HEAD)
)
'
test_expect_success 'Filtering a blob to make it match previous version' '
test_create_repo remove_unique_bits_of_blob &&
(

Loading…
Cancel
Save