3 test_description
='Test commit notes organized in subtrees'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
13 start_note_commit
() {
16 commit refs/notes/commits
17 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
22 from refs/notes/commits^0
29 git log |
grep "^ " > output
&&
30 i
=$number_of_commits &&
31 while [ $i -gt 0 ]; do
33 echo " note for commit #$i" &&
34 i
=$
(($i-1)) ||
return 1
36 test_cmp expect output
39 test_expect_success
"setup: create $number_of_commits commits" '
43 while [ $nr -lt $number_of_commits ]; do
46 cat <<INPUT_END || return 1
47 commit refs/heads/main
48 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
63 commit refs/notes/commits
64 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
74 git fast-import --quiet &&
75 git config core.notesRef refs/notes/commits
81 nr
=$number_of_commits &&
82 git rev-list refs
/heads
/main
>out
&&
84 note_path
=$
(echo "$sha1" |
sed "$1")
86 M 100644 inline $note_path
96 git fast-import
--quiet <gfi
99 test_expect_success
'test notes in 2/38-fanout' 'test_sha1_based "s|^..|&/|"'
100 test_expect_success
'verify notes in 2/38-fanout' 'verify_notes'
102 test_expect_success
'test notes in 2/2/36-fanout' 'test_sha1_based "s|^\(..\)\(..\)|\1/\2/|"'
103 test_expect_success
'verify notes in 2/2/36-fanout' 'verify_notes'
105 test_expect_success
'test notes in 2/2/2/34-fanout' 'test_sha1_based "s|^\(..\)\(..\)\(..\)|\1/\2/\3/|"'
106 test_expect_success
'verify notes in 2/2/2/34-fanout' 'verify_notes'
111 nr
=$number_of_commits &&
112 git rev-list refs
/heads
/main |
114 first_note_path
=$
(echo "$sha1" |
sed "$1")
115 second_note_path
=$
(echo "$sha1" |
sed "$2")
117 M 100644 inline $second_note_path
122 M 100644 inline $first_note_path
132 git fast-import
--quiet
135 test_expect_success
'test same notes in no fanout and 2/38-fanout' 'test_same_notes "s|^..|&/|" ""'
136 test_expect_success
'verify same notes in no fanout and 2/38-fanout' 'verify_notes'
138 test_expect_success
'test same notes in no fanout and 2/2/36-fanout' 'test_same_notes "s|^\(..\)\(..\)|\1/\2/|" ""'
139 test_expect_success
'verify same notes in no fanout and 2/2/36-fanout' 'verify_notes'
141 test_expect_success
'test same notes in 2/38-fanout and 2/2/36-fanout' 'test_same_notes "s|^\(..\)\(..\)|\1/\2/|" "s|^..|&/|"'
142 test_expect_success
'verify same notes in 2/38-fanout and 2/2/36-fanout' 'verify_notes'
144 test_expect_success
'test same notes in 2/2/2/34-fanout and 2/2/36-fanout' 'test_same_notes "s|^\(..\)\(..\)|\1/\2/|" "s|^\(..\)\(..\)\(..\)|\1/\2/\3/|"'
145 test_expect_success
'verify same notes in 2/2/2/34-fanout and 2/2/36-fanout' 'verify_notes'
147 test_concatenated_notes
() {
150 nr
=$number_of_commits &&
151 git rev-list refs
/heads
/main |
153 first_note_path
=$
(echo "$sha1" |
sed "$1")
154 second_note_path
=$
(echo "$sha1" |
sed "$2")
156 M 100644 inline $second_note_path
158 second note for commit #$nr
161 M 100644 inline $first_note_path
163 first note for commit #$nr
171 git fast-import
--quiet
174 verify_concatenated_notes
() {
175 git log |
grep "^ " > output
&&
176 i
=$number_of_commits &&
177 while [ $i -gt 0 ]; do
178 echo " commit #$i" &&
179 echo " first note for commit #$i" &&
181 echo " second note for commit #$i" &&
182 i
=$
(($i-1)) ||
return 1
184 test_cmp expect output
187 test_expect_success
'test notes in no fanout concatenated with 2/38-fanout' 'test_concatenated_notes "s|^..|&/|" ""'
188 test_expect_success
'verify notes in no fanout concatenated with 2/38-fanout' 'verify_concatenated_notes'
190 test_expect_success
'test notes in no fanout concatenated with 2/2/36-fanout' 'test_concatenated_notes "s|^\(..\)\(..\)|\1/\2/|" ""'
191 test_expect_success
'verify notes in no fanout concatenated with 2/2/36-fanout' 'verify_concatenated_notes'
193 test_expect_success
'test notes in 2/38-fanout concatenated with 2/2/36-fanout' 'test_concatenated_notes "s|^\(..\)\(..\)|\1/\2/|" "s|^..|&/|"'
194 test_expect_success
'verify notes in 2/38-fanout concatenated with 2/2/36-fanout' 'verify_concatenated_notes'
196 test_expect_success
'test notes in 2/2/36-fanout concatenated with 2/2/2/34-fanout' 'test_concatenated_notes "s|^\(..\)\(..\)\(..\)|\1/\2/\3/|" "s|^\(..\)\(..\)|\1/\2/|"'
197 test_expect_success
'verify notes in 2/2/36-fanout concatenated with 2/2/2/34-fanout' 'verify_concatenated_notes'