blob: 256687ffb53aef91666561bd91e0188ff62d8690 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
#!/bin/sh
test_description='Test notes trees that also contain non-notes'
. ./test-lib.sh
number_of_commits=100
start_note_commit () {
test_tick &&
cat <<INPUT_END
commit refs/notes/commits
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
notes
COMMIT
from refs/notes/commits^0
deleteall
INPUT_END
}
verify_notes () {
git log | grep "^ " > output &&
i=$number_of_commits &&
while [ $i -gt 0 ]; do
echo " commit #$i" &&
echo " note for commit #$i" &&
i=$(($i-1));
done > expect &&
test_cmp expect output
}
test_expect_success "setup: create a couple of commits" '
test_tick &&
cat <<INPUT_END >input &&
commit refs/heads/master
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
commit #1
COMMIT
M 644 inline file
data <<EOF
file in commit #1
EOF
INPUT_END
test_tick &&
cat <<INPUT_END >>input &&
commit refs/heads/master
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
commit #2
COMMIT
M 644 inline file
data <<EOF
file in commit #2
EOF
INPUT_END
git fast-import --quiet <input
'
test_expect_success "create a notes tree with both notes and non-notes" '
commit1=$(git rev-parse refs/heads/master^) &&
commit2=$(git rev-parse refs/heads/master) &&
test_tick &&
cat <<INPUT_END >input &&
commit refs/notes/commits
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
notes commit #1
COMMIT
N inline $commit1
data <<EOF
note for commit #1
EOF
N inline $commit2
data <<EOF
note for commit #2
EOF
INPUT_END
test_tick &&
cat <<INPUT_END >>input &&
commit refs/notes/commits
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
notes commit #2
COMMIT
M 644 inline foobar/non-note.txt
data <<EOF
A non-note in a notes tree
EOF
N inline $commit2
data <<EOF
edited note for commit #2
EOF
INPUT_END
test_tick &&
cat <<INPUT_END >>input &&
commit refs/notes/commits
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
notes commit #3
COMMIT
N inline $commit1
data <<EOF
edited note for commit #1
EOF
M 644 inline deadbeef
data <<EOF
non-note with SHA1-like name
EOF
M 644 inline de/adbeef
data <<EOF
another non-note with SHA1-like name
EOF
INPUT_END
git fast-import --quiet <input &&
git config core.notesRef refs/notes/commits
'
cat >expect <<EXPECT_END
commit #2
edited note for commit #2
commit #1
edited note for commit #1
EXPECT_END
test_expect_success "verify contents of notes" '
git log | grep "^ " > actual &&
test_cmp expect actual
'
cat >expect_nn1 <<EXPECT_END
A non-note in a notes tree
EXPECT_END
cat >expect_nn2 <<EXPECT_END
non-note with SHA1-like name
EXPECT_END
cat >expect_nn3 <<EXPECT_END
another non-note with SHA1-like name
EXPECT_END
test_expect_success "verify contents of non-notes" '
git cat-file -p refs/notes/commits:foobar/non-note.txt > actual_nn1 &&
test_cmp expect_nn1 actual_nn1 &&
git cat-file -p refs/notes/commits:deadbeef > actual_nn2 &&
test_cmp expect_nn2 actual_nn2 &&
git cat-file -p refs/notes/commits:de/adbeef > actual_nn3 &&
test_cmp expect_nn3 actual_nn3
'
test_done
|