t7003: ensure --prune-empty can prune root commit

New test to expose a bug in filter-branch whereby the root commit is
never pruned, even though its tree is empty and --prune-empty is given.

The setup isn't exactly pretty, but I couldn't think of a simpler way to
create a parallel commit graph sans the first commit.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Devin J. Pohly 2017-02-23 02:27:33 -06:00 коммит произвёл Junio C Hamano
Родитель 3b9e3c2ced
Коммит 377a354389
1 изменённых файлов: 30 добавлений и 0 удалений

Просмотреть файл

@ -313,6 +313,27 @@ test_expect_success 'Tag name filtering allows slashes in tag names' '
git cat-file tag X/2 > actual &&
test_cmp expect actual
'
test_expect_success 'setup --prune-empty comparisons' '
git checkout --orphan master-no-a &&
git rm -rf . &&
unset test_tick &&
test_tick &&
GIT_COMMITTER_DATE="@0 +0000" GIT_AUTHOR_DATE="@0 +0000" &&
test_commit --notick B B.t B Bx &&
git checkout -b branch-no-a Bx &&
test_commit D D.t D Dx &&
mkdir dir &&
test_commit dir/D dir/D.t dir/D dir/Dx &&
test_commit E E.t E Ex &&
git checkout master-no-a &&
test_commit C C.t C Cx &&
git checkout branch-no-a &&
git merge Cx -m "Merge tag '\''C'\'' into branch" &&
git tag Fx &&
test_commit G G.t G Gx &&
test_commit H H.t H Hx &&
git checkout branch
'
test_expect_success 'Prune empty commits' '
git rev-list HEAD > expect &&
@ -341,6 +362,15 @@ test_expect_success 'prune empty works even without index/tree filters' '
test_cmp expect actual
'
test_expect_failure '--prune-empty is able to prune root commit' '
git rev-list branch-no-a >expect &&
git branch testing H &&
git filter-branch -f --prune-empty --index-filter "git update-index --remove A.t" testing &&
git rev-list testing >actual &&
git branch -D testing &&
test_cmp expect actual
'
test_expect_success '--remap-to-ancestor with filename filters' '
git checkout master &&
git reset --hard A &&