]>
Commit | Line | Data |
---|---|---|
d6576e1f JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='Test git notes prune' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success 'setup: create a few commits with notes' ' | |
8 | ||
9 | : > file1 && | |
10 | git add file1 && | |
11 | test_tick && | |
12 | git commit -m 1st && | |
aaec9bcf | 13 | git notes add -m "Note #1" && |
b99bfc7a | 14 | first=$(git rev-parse HEAD) && |
d6576e1f JH |
15 | : > file2 && |
16 | git add file2 && | |
17 | test_tick && | |
18 | git commit -m 2nd && | |
aaec9bcf | 19 | git notes add -m "Note #2" && |
b99bfc7a | 20 | second=$(git rev-parse HEAD) && |
d6576e1f JH |
21 | : > file3 && |
22 | git add file3 && | |
23 | test_tick && | |
24 | git commit -m 3rd && | |
b99bfc7a | 25 | third=$(git rev-parse HEAD) && |
26 | COMMIT_FILE=$(echo $third | sed "s!^..!.git/objects/&/!") && | |
e3b02bc9 | 27 | test -f $COMMIT_FILE && |
0e496492 | 28 | test-tool chmtime =+0 $COMMIT_FILE && |
aaec9bcf | 29 | git notes add -m "Note #3" |
d6576e1f JH |
30 | ' |
31 | ||
32 | cat > expect <<END_OF_LOG | |
b99bfc7a | 33 | commit $third |
d6576e1f JH |
34 | Author: A U Thor <author@example.com> |
35 | Date: Thu Apr 7 15:15:13 2005 -0700 | |
36 | ||
37 | 3rd | |
38 | ||
39 | Notes: | |
40 | Note #3 | |
41 | ||
b99bfc7a | 42 | commit $second |
d6576e1f JH |
43 | Author: A U Thor <author@example.com> |
44 | Date: Thu Apr 7 15:14:13 2005 -0700 | |
45 | ||
46 | 2nd | |
47 | ||
48 | Notes: | |
49 | Note #2 | |
50 | ||
b99bfc7a | 51 | commit $first |
d6576e1f JH |
52 | Author: A U Thor <author@example.com> |
53 | Date: Thu Apr 7 15:13:13 2005 -0700 | |
54 | ||
55 | 1st | |
56 | ||
57 | Notes: | |
58 | Note #1 | |
59 | END_OF_LOG | |
60 | ||
61 | test_expect_success 'verify commits and notes' ' | |
62 | ||
63 | git log > actual && | |
64 | test_cmp expect actual | |
65 | ' | |
66 | ||
67 | test_expect_success 'remove some commits' ' | |
68 | ||
a9f2adff | 69 | git reset --hard HEAD~1 && |
d6576e1f JH |
70 | git reflog expire --expire=now HEAD && |
71 | git gc --prune=now | |
72 | ' | |
73 | ||
74 | test_expect_success 'verify that commits are gone' ' | |
75 | ||
b99bfc7a | 76 | test_must_fail git cat-file -p $third && |
77 | git cat-file -p $second && | |
78 | git cat-file -p $first | |
d6576e1f JH |
79 | ' |
80 | ||
81 | test_expect_success 'verify that notes are still present' ' | |
82 | ||
b99bfc7a | 83 | git notes show $third && |
84 | git notes show $second && | |
85 | git notes show $first | |
d6576e1f JH |
86 | ' |
87 | ||
a9f2adff MG |
88 | test_expect_success 'prune -n does not remove notes' ' |
89 | ||
90 | git notes list > expect && | |
91 | git notes prune -n && | |
92 | git notes list > actual && | |
93 | test_cmp expect actual | |
94 | ' | |
95 | ||
a9f2adff MG |
96 | |
97 | test_expect_success 'prune -n lists prunable notes' ' | |
98 | ||
b99bfc7a | 99 | echo $third >expect && |
a9f2adff MG |
100 | git notes prune -n > actual && |
101 | test_cmp expect actual | |
102 | ' | |
103 | ||
104 | ||
d6576e1f JH |
105 | test_expect_success 'prune notes' ' |
106 | ||
107 | git notes prune | |
108 | ' | |
109 | ||
a9f2adff MG |
110 | test_expect_success 'verify that notes are gone' ' |
111 | ||
b99bfc7a | 112 | test_must_fail git notes show $third && |
113 | git notes show $second && | |
114 | git notes show $first | |
a9f2adff MG |
115 | ' |
116 | ||
117 | test_expect_success 'remove some commits' ' | |
118 | ||
119 | git reset --hard HEAD~1 && | |
120 | git reflog expire --expire=now HEAD && | |
121 | git gc --prune=now | |
122 | ' | |
123 | ||
a9f2adff MG |
124 | test_expect_success 'prune -v notes' ' |
125 | ||
b99bfc7a | 126 | echo $second >expect && |
a9f2adff MG |
127 | git notes prune -v > actual && |
128 | test_cmp expect actual | |
129 | ' | |
130 | ||
d6576e1f JH |
131 | test_expect_success 'verify that notes are gone' ' |
132 | ||
b99bfc7a | 133 | test_must_fail git notes show $third && |
134 | test_must_fail git notes show $second && | |
135 | git notes show $first | |
d6576e1f JH |
136 | ' |
137 | ||
138 | test_done |