Merge branch 'rc/maint-reflog-msg-for-forced-branch'
[git/kirr.git] / t / t3306-notes-prune.sh
bloba0ed0353e69dd6dbc96f1a8e3c9251757b4f408f
1 #!/bin/sh
3 test_description='Test git notes prune'
5 . ./test-lib.sh
7 test_expect_success 'setup: create a few commits with notes' '
9 : > file1 &&
10 git add file1 &&
11 test_tick &&
12 git commit -m 1st &&
13 git notes add -m "Note #1" &&
14 : > file2 &&
15 git add file2 &&
16 test_tick &&
17 git commit -m 2nd &&
18 git notes add -m "Note #2" &&
19 : > file3 &&
20 git add file3 &&
21 test_tick &&
22 git commit -m 3rd &&
23 git notes add -m "Note #3"
26 cat > expect <<END_OF_LOG
27 commit 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29
28 Author: A U Thor <author@example.com>
29 Date: Thu Apr 7 15:15:13 2005 -0700
31 3rd
33 Notes:
34 Note #3
36 commit 08341ad9e94faa089d60fd3f523affb25c6da189
37 Author: A U Thor <author@example.com>
38 Date: Thu Apr 7 15:14:13 2005 -0700
40 2nd
42 Notes:
43 Note #2
45 commit ab5f302035f2e7aaf04265f08b42034c23256e1f
46 Author: A U Thor <author@example.com>
47 Date: Thu Apr 7 15:13:13 2005 -0700
49 1st
51 Notes:
52 Note #1
53 END_OF_LOG
55 test_expect_success 'verify commits and notes' '
57 git log > actual &&
58 test_cmp expect actual
61 test_expect_success 'remove some commits' '
63 git reset --hard HEAD~2 &&
64 git reflog expire --expire=now HEAD &&
65 git gc --prune=now
68 test_expect_success 'verify that commits are gone' '
70 ! git cat-file -p 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
71 ! git cat-file -p 08341ad9e94faa089d60fd3f523affb25c6da189 &&
72 git cat-file -p ab5f302035f2e7aaf04265f08b42034c23256e1f
75 test_expect_success 'verify that notes are still present' '
77 git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
78 git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
79 git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
82 test_expect_success 'prune notes' '
84 git notes prune
87 test_expect_success 'verify that notes are gone' '
89 ! git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
90 ! git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
91 git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
94 test_done