]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3306-notes-prune.sh
Merge branch 'jn/grep-open'
[thirdparty/git.git] / t / t3306-notes-prune.sh
CommitLineData
d6576e1f
JH
1#!/bin/sh
2
3test_description='Test git notes prune'
4
5. ./test-lib.sh
6
7test_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 &&
aaec9bcf 23 git notes add -m "Note #3"
d6576e1f
JH
24'
25
26cat > expect <<END_OF_LOG
27commit 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29
28Author: A U Thor <author@example.com>
29Date: Thu Apr 7 15:15:13 2005 -0700
30
31 3rd
32
33Notes:
34 Note #3
35
36commit 08341ad9e94faa089d60fd3f523affb25c6da189
37Author: A U Thor <author@example.com>
38Date: Thu Apr 7 15:14:13 2005 -0700
39
40 2nd
41
42Notes:
43 Note #2
44
45commit ab5f302035f2e7aaf04265f08b42034c23256e1f
46Author: A U Thor <author@example.com>
47Date: Thu Apr 7 15:13:13 2005 -0700
48
49 1st
50
51Notes:
52 Note #1
53END_OF_LOG
54
55test_expect_success 'verify commits and notes' '
56
57 git log > actual &&
58 test_cmp expect actual
59'
60
61test_expect_success 'remove some commits' '
62
a9f2adff 63 git reset --hard HEAD~1 &&
d6576e1f
JH
64 git reflog expire --expire=now HEAD &&
65 git gc --prune=now
66'
67
68test_expect_success 'verify that commits are gone' '
69
70 ! git cat-file -p 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
a9f2adff 71 git cat-file -p 08341ad9e94faa089d60fd3f523affb25c6da189 &&
d6576e1f
JH
72 git cat-file -p ab5f302035f2e7aaf04265f08b42034c23256e1f
73'
74
75test_expect_success 'verify that notes are still present' '
76
77 git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
78 git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
79 git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
80'
81
a9f2adff
MG
82test_expect_success 'prune -n does not remove notes' '
83
84 git notes list > expect &&
85 git notes prune -n &&
86 git notes list > actual &&
87 test_cmp expect actual
88'
89
90cat > expect <<EOF
915ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29
92EOF
93
94test_expect_success 'prune -n lists prunable notes' '
95
96
97 git notes prune -n > actual &&
98 test_cmp expect actual
99'
100
101
d6576e1f
JH
102test_expect_success 'prune notes' '
103
104 git notes prune
105'
106
a9f2adff
MG
107test_expect_success 'verify that notes are gone' '
108
109 ! git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
110 git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
111 git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
112'
113
114test_expect_success 'remove some commits' '
115
116 git reset --hard HEAD~1 &&
117 git reflog expire --expire=now HEAD &&
118 git gc --prune=now
119'
120
121cat > expect <<EOF
12208341ad9e94faa089d60fd3f523affb25c6da189
123EOF
124
125test_expect_success 'prune -v notes' '
126
127 git notes prune -v > actual &&
128 test_cmp expect actual
129'
130
d6576e1f
JH
131test_expect_success 'verify that notes are gone' '
132
133 ! git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
134 ! git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
135 git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
136'
137
138test_done