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" &&
14 first=$(git rev-parse HEAD) &&
19 git notes add -m "Note #2" &&
20 second=$(git rev-parse HEAD) &&
25 third=$(git rev-parse HEAD) &&
26 COMMIT_FILE=$(echo $third | sed "s!^..!.git/objects/&/!") &&
27 test -f $COMMIT_FILE &&
28 test-tool chmtime =+0 $COMMIT_FILE &&
29 git notes add -m "Note #3"
32 cat > expect
<<END_OF_LOG
34 Author: A U Thor <author@example.com>
35 Date: Thu Apr 7 15:15:13 2005 -0700
43 Author: A U Thor <author@example.com>
44 Date: Thu Apr 7 15:14:13 2005 -0700
52 Author: A U Thor <author@example.com>
53 Date: Thu Apr 7 15:13:13 2005 -0700
61 test_expect_success
'verify commits and notes' '
64 test_cmp expect actual
67 test_expect_success
'remove some commits' '
69 git reset --hard HEAD~1 &&
70 git reflog expire --expire=now HEAD &&
74 test_expect_success
'verify that commits are gone' '
76 test_must_fail git cat-file -p $third &&
77 git cat-file -p $second &&
78 git cat-file -p $first
81 test_expect_success
'verify that notes are still present' '
83 git notes show $third &&
84 git notes show $second &&
88 test_expect_success
'prune -n does not remove notes' '
90 git notes list > expect &&
92 git notes list > actual &&
93 test_cmp expect actual
97 test_expect_success
'prune -n lists prunable notes' '
99 echo $third >expect &&
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 $third &&
113 git notes show $second &&
114 git notes show $first
117 test_expect_success
'remove some commits' '
119 git reset --hard HEAD~1 &&
120 git reflog expire --expire=now HEAD &&
124 test_expect_success
'prune -v notes' '
126 echo $second >expect &&
127 git notes prune -v > actual &&
128 test_cmp expect actual
131 test_expect_success
'verify that notes are gone' '
133 test_must_fail git notes show $third &&
134 test_must_fail git notes show $second &&
135 git notes show $first