Skip to content

Commit a099469

Browse files
jherlandgitster
authored andcommitted
Add selftests verifying concatenation of multiple notes for the same commit
Also verify that multiple references to the _same_ note blob are _not_ concatenated. Signed-off-by: Johan Herland <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ef8db63 commit a099469

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

t/t3303-notes-subtrees.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,88 @@ test_expect_success 'verify notes in 4/36-fanout' 'verify_notes'
101101
test_expect_success 'test notes in 2/2/36-fanout' 'test_sha1_based "s|^\(..\)\(..\)|\1/\2/|"'
102102
test_expect_success 'verify notes in 2/2/36-fanout' 'verify_notes'
103103

104+
test_same_notes () {
105+
(
106+
start_note_commit &&
107+
nr=$number_of_commits &&
108+
git rev-list refs/heads/master |
109+
while read sha1; do
110+
first_note_path=$(echo "$sha1" | sed "$1")
111+
second_note_path=$(echo "$sha1" | sed "$2")
112+
cat <<INPUT_END &&
113+
M 100644 inline $second_note_path
114+
data <<EOF
115+
note for commit #$nr
116+
EOF
117+
118+
M 100644 inline $first_note_path
119+
data <<EOF
120+
note for commit #$nr
121+
EOF
122+
123+
INPUT_END
124+
125+
nr=$(($nr-1))
126+
done
127+
) |
128+
git fast-import --quiet
129+
}
130+
131+
test_expect_success 'test same notes in 4/36-fanout and 2/38-fanout' 'test_same_notes "s|^..|&/|" "s|^....|&/|"'
132+
test_expect_success 'verify same notes in 4/36-fanout and 2/38-fanout' 'verify_notes'
133+
134+
test_expect_success 'test same notes in 2/38-fanout and 2/2/36-fanout' 'test_same_notes "s|^\(..\)\(..\)|\1/\2/|" "s|^..|&/|"'
135+
test_expect_success 'verify same notes in 2/38-fanout and 2/2/36-fanout' 'verify_notes'
136+
137+
test_expect_success 'test same notes in 4/36-fanout and 2/2/36-fanout' 'test_same_notes "s|^\(..\)\(..\)|\1/\2/|" "s|^....|&/|"'
138+
test_expect_success 'verify same notes in 4/36-fanout and 2/2/36-fanout' 'verify_notes'
139+
140+
test_concatenated_notes () {
141+
(
142+
start_note_commit &&
143+
nr=$number_of_commits &&
144+
git rev-list refs/heads/master |
145+
while read sha1; do
146+
first_note_path=$(echo "$sha1" | sed "$1")
147+
second_note_path=$(echo "$sha1" | sed "$2")
148+
cat <<INPUT_END &&
149+
M 100644 inline $second_note_path
150+
data <<EOF
151+
second note for commit #$nr
152+
EOF
153+
154+
M 100644 inline $first_note_path
155+
data <<EOF
156+
first note for commit #$nr
157+
EOF
158+
159+
INPUT_END
160+
161+
nr=$(($nr-1))
162+
done
163+
) |
164+
git fast-import --quiet
165+
}
166+
167+
verify_concatenated_notes () {
168+
git log | grep "^ " > output &&
169+
i=$number_of_commits &&
170+
while [ $i -gt 0 ]; do
171+
echo " commit #$i" &&
172+
echo " first note for commit #$i" &&
173+
echo " second note for commit #$i" &&
174+
i=$(($i-1));
175+
done > expect &&
176+
test_cmp expect output
177+
}
178+
179+
test_expect_success 'test notes in 4/36-fanout concatenated with 2/38-fanout' 'test_concatenated_notes "s|^..|&/|" "s|^....|&/|"'
180+
test_expect_success 'verify notes in 4/36-fanout concatenated with 2/38-fanout' 'verify_concatenated_notes'
181+
182+
test_expect_success 'test notes in 2/38-fanout concatenated with 2/2/36-fanout' 'test_concatenated_notes "s|^\(..\)\(..\)|\1/\2/|" "s|^..|&/|"'
183+
test_expect_success 'verify notes in 2/38-fanout concatenated with 2/2/36-fanout' 'verify_concatenated_notes'
184+
185+
test_expect_success 'test notes in 4/36-fanout concatenated with 2/2/36-fanout' 'test_concatenated_notes "s|^\(..\)\(..\)|\1/\2/|" "s|^....|&/|"'
186+
test_expect_success 'verify notes in 4/36-fanout concatenated with 2/2/36-fanout' 'verify_concatenated_notes'
187+
104188
test_done

0 commit comments

Comments
 (0)