]>
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" && |
d6576e1f JH |
14 | : > file2 && |
15 | git add file2 && | |
16 | test_tick && | |
17 | git commit -m 2nd && | |
aaec9bcf | 18 | git notes add -m "Note #2" && |
d6576e1f JH |
19 | : > file3 && |
20 | git add file3 && | |
21 | test_tick && | |
22 | git commit -m 3rd && | |
e3b02bc9 MG |
23 | COMMIT_FILE=.git/objects/5e/e1c35e83ea47cd3cc4f8cbee0568915fbbbd29 && |
24 | test -f $COMMIT_FILE && | |
25 | test-chmtime =+0 $COMMIT_FILE && | |
aaec9bcf | 26 | git notes add -m "Note #3" |
d6576e1f JH |
27 | ' |
28 | ||
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 | |
33 | ||
34 | 3rd | |
35 | ||
36 | Notes: | |
37 | Note #3 | |
38 | ||
39 | commit 08341ad9e94faa089d60fd3f523affb25c6da189 | |
40 | Author: A U Thor <author@example.com> | |
41 | Date: Thu Apr 7 15:14:13 2005 -0700 | |
42 | ||
43 | 2nd | |
44 | ||
45 | Notes: | |
46 | Note #2 | |
47 | ||
48 | commit ab5f302035f2e7aaf04265f08b42034c23256e1f | |
49 | Author: A U Thor <author@example.com> | |
50 | Date: Thu Apr 7 15:13:13 2005 -0700 | |
51 | ||
52 | 1st | |
53 | ||
54 | Notes: | |
55 | Note #1 | |
56 | END_OF_LOG | |
57 | ||
58 | test_expect_success 'verify commits and notes' ' | |
59 | ||
60 | git log > actual && | |
61 | test_cmp expect actual | |
62 | ' | |
63 | ||
64 | test_expect_success 'remove some commits' ' | |
65 | ||
a9f2adff | 66 | git reset --hard HEAD~1 && |
d6576e1f JH |
67 | git reflog expire --expire=now HEAD && |
68 | git gc --prune=now | |
69 | ' | |
70 | ||
71 | test_expect_success 'verify that commits are gone' ' | |
72 | ||
ce14e0b2 | 73 | test_must_fail git cat-file -p 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 && |
a9f2adff | 74 | git cat-file -p 08341ad9e94faa089d60fd3f523affb25c6da189 && |
d6576e1f JH |
75 | git cat-file -p ab5f302035f2e7aaf04265f08b42034c23256e1f |
76 | ' | |
77 | ||
78 | test_expect_success 'verify that notes are still present' ' | |
79 | ||
80 | git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 && | |
81 | git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 && | |
82 | git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f | |
83 | ' | |
84 | ||
a9f2adff MG |
85 | test_expect_success 'prune -n does not remove notes' ' |
86 | ||
87 | git notes list > expect && | |
88 | git notes prune -n && | |
89 | git notes list > actual && | |
90 | test_cmp expect actual | |
91 | ' | |
92 | ||
93 | cat > expect <<EOF | |
94 | 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 | |
95 | EOF | |
96 | ||
97 | test_expect_success 'prune -n lists prunable notes' ' | |
98 | ||
99 | ||
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 | ||
ce14e0b2 | 112 | test_must_fail git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 && |
a9f2adff MG |
113 | git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 && |
114 | git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f | |
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 | ||
124 | cat > expect <<EOF | |
125 | 08341ad9e94faa089d60fd3f523affb25c6da189 | |
126 | EOF | |
127 | ||
128 | test_expect_success 'prune -v notes' ' | |
129 | ||
130 | git notes prune -v > actual && | |
131 | test_cmp expect actual | |
132 | ' | |
133 | ||
d6576e1f JH |
134 | test_expect_success 'verify that notes are gone' ' |
135 | ||
ce14e0b2 JH |
136 | test_must_fail git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 && |
137 | test_must_fail git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 && | |
d6576e1f JH |
138 | git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f |
139 | ' | |
140 | ||
141 | test_done |