3 test_description
='Test git notes prune'
7 test_expect_success
'setup: create a few commits with notes' '
13 git notes add -m "Note #1" &&
18 git notes add -m "Note #2" &&
23 COMMIT_FILE=.git/objects/5e/e1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
24 test -f $COMMIT_FILE &&
25 test-chmtime =+0 $COMMIT_FILE &&
26 git notes add -m "Note #3"
29 cat > expect
<<END_OF_LOG
30 commit 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29
31 Author: A U Thor <author@example.com>
32 Date: Thu Apr 7 15:15:13 2005 -0700
39 commit 08341ad9e94faa089d60fd3f523affb25c6da189
40 Author: A U Thor <author@example.com>
41 Date: Thu Apr 7 15:14:13 2005 -0700
48 commit ab5f302035f2e7aaf04265f08b42034c23256e1f
49 Author: A U Thor <author@example.com>
50 Date: Thu Apr 7 15:13:13 2005 -0700
58 test_expect_success
'verify commits and notes' '
61 test_cmp expect actual
64 test_expect_success
'remove some commits' '
66 git reset --hard HEAD~1 &&
67 git reflog expire --expire=now HEAD &&
71 test_expect_success
'verify that commits are gone' '
73 test_must_fail git cat-file -p 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
74 git cat-file -p 08341ad9e94faa089d60fd3f523affb25c6da189 &&
75 git cat-file -p ab5f302035f2e7aaf04265f08b42034c23256e1f
78 test_expect_success
'verify that notes are still present' '
80 git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
81 git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
82 git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
85 test_expect_success
'prune -n does not remove notes' '
87 git notes list > expect &&
89 git notes list > actual &&
90 test_cmp expect actual
94 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29
97 test_expect_success
'prune -n lists prunable notes' '
100 git notes prune -n > actual &&
101 test_cmp expect actual
105 test_expect_success
'prune notes' '
110 test_expect_success
'verify that notes are gone' '
112 test_must_fail git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
113 git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
114 git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
117 test_expect_success
'remove some commits' '
119 git reset --hard HEAD~1 &&
120 git reflog expire --expire=now HEAD &&
125 08341ad9e94faa089d60fd3f523affb25c6da189
128 test_expect_success
'prune -v notes' '
130 git notes prune -v > actual &&
131 test_cmp expect actual
134 test_expect_success
'verify that notes are gone' '
136 test_must_fail git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
137 test_must_fail git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
138 git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f