[PATCH] [BUG] Add a test to check git-prune does not throw away revs hidden by a graft.
- From
Yann Dirson <ydirson@altern.org>
- Date
- May 18, 2006, 21:35 UTC
- Message-ID
- <20060518213519.14577.67309.stgit@gandelf.nowhere.earth>
This test fails with 1.3.x and HEAD. This is a very serious bug, since it causes data loss.
I am not sure whether it is normal that git-fsck-objects does not retun an error code, while we can see it reports the inconsistency in --verbose mode. At least trying to directly access the dropped commit triggers an error anyway.
Signed-off-by: Yann Dirson <ydirson@altern.org> ---
t/t6200-prune-grafts.sh | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/t/t6200-prune-grafts.sh b/t/t6200-prune-grafts.sh new file mode 100755 index 0000000..80d0d59 --- /dev/null +++ b/t/t6200-prune-grafts.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# +# Copyright (c) 2006 Yann Dirson +# +set -e + +test_description='Test that git-prune does not nuke revs hidden by a graft' + +. ./test-lib.sh + +echo First > A && git-add A && git-commit -m "Add A." +echo First > B && git-add B && git-commit -m "Add B." +echo Second >> A && git-update-index A && git-commit -m "Append to A." + +test_expect_success 'initial state is valid' 'git-fsck-objects' + +echo $(git-rev-parse HEAD) $(git-rev-parse HEAD^^) > .git/info/grafts + +test_expect_success 'grafted state is valid' 'git-fsck-objects' +test_expect_success 'prune with the graft in effect' 'git-prune' +test_expect_success 'grafted state is valid' 'git-fsck-objects' + +rm .git/info/grafts + +test_expect_success 'grafted state is still valid' 'git-fsck-objects' +test_expect_success 'previously-hidden rev is still there' 'git-cat-file commit HEAD^' + +test_done