[PATCH 3/3] add tests for reflogs of deleted refs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



These tests cover the basic functionality of retaining
reflogs for deleted refs.

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
 t/t1413-reflog-deletion.sh | 74 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100755 t/t1413-reflog-deletion.sh

diff --git a/t/t1413-reflog-deletion.sh b/t/t1413-reflog-deletion.sh
new file mode 100755
index 0000000..e00d038
--- /dev/null
+++ b/t/t1413-reflog-deletion.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+test_description='test retention of reflog after ref deletion'
+. ./test-lib.sh
+
+test_expect_success 'setup deleted branch' '
+	test_tick && echo one >file && git add file && git commit -m one &&
+	test_tick && echo two >file && git add file && git commit -m two &&
+	git checkout -b foo/bar &&
+	test_tick && echo three >file && git add file && git commit -m three &&
+	git checkout master &&
+	git branch -D foo/bar &&
+	rm -f .git/logs/HEAD
+'
+
+test_expect_success 'branch is no longer accessible' '
+	test_must_fail git rev-parse --verify foo/bar
+'
+
+test_expect_success 'final reflog is null sha1' '
+	echo $_z40 >expect &&
+	git rev-parse --verify foo/bar@{0} >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'deleted reflog entries are accessible' '
+	cat >expect <<-\EOF &&
+	three
+	two
+	EOF
+	{
+		git log -1 --format=%s foo/bar@{1}
+		git log -1 --format=%s foo/bar@{2}
+	} >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'reflog walker can find deleted entries' '
+	cat >expect <<-\EOF &&
+	three
+	two
+	EOF
+	git log -g --format=%s foo/bar@{1} >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'can still create/delete same ref' '
+	git branch foo/bar &&
+	git branch -D foo/bar
+'
+
+test_expect_success 'can still create/delete parent ref' '
+	git branch foo &&
+	git branch -D foo
+'
+
+test_expect_success 'can still create/delete child ref' '
+	git branch foo/bar/baz &&
+	git branch -D foo/bar/baz
+'
+
+test_expect_success 'deleted reflog entries are still reachable' '
+	>expect &&
+	git fsck --unreachable >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'deleted reflog entries are expired normally' '
+	git reflog expire --all --expire=now &&
+	git fsck --unreachable >actual &&
+	test_line_count = 3 actual
+'
+
+test_done
-- 
1.7.10.5.40.g059818d
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]