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
12 start_note_commit
() {
15 commit refs/notes/commits
16 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
21 from refs/notes/commits^0
28 git log |
grep "^ " > output
&&
29 i
=$number_of_commits &&
30 while [ $i -gt 0 ]; do
32 echo " note for commit #$i" &&
35 test_cmp expect output
38 test_expect_success
"setup: create $number_of_commits commits" '
42 while [ $nr -lt $number_of_commits ]; do
46 commit refs/heads/main
47 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
62 commit refs/notes/commits
63 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
73 git fast-import --quiet &&
74 git config core.notesRef refs/notes/commits
80 nr
=$number_of_commits &&
81 git rev-list refs
/heads
/main |
83 note_path
=$
(echo "$sha1" |
sed "$1")
85 M 100644 inline $note_path
95 git fast-import
--quiet
98 test_expect_success
'test notes in 2/38-fanout' 'test_sha1_based "s|^..|&/|"'
99 test_expect_success
'verify notes in 2/38-fanout' 'verify_notes'
101 test_expect_success
'test notes in 2/2/36-fanout' 'test_sha1_based "s|^\(..\)\(..\)|\1/\2/|"'
102 test_expect_success
'verify notes in 2/2/36-fanout' 'verify_notes'
104 test_expect_success
'test notes in 2/2/2/34-fanout' 'test_sha1_based "s|^\(..\)\(..\)\(..\)|\1/\2/\3/|"'
105 test_expect_success
'verify notes in 2/2/2/34-fanout' 'verify_notes'
110 nr
=$number_of_commits &&
111 git rev-list refs
/heads
/main |
113 first_note_path
=$
(echo "$sha1" |
sed "$1")
114 second_note_path
=$
(echo "$sha1" |
sed "$2")
116 M 100644 inline $second_note_path
121 M 100644 inline $first_note_path
131 git fast-import
--quiet
134 test_expect_success
'test same notes in no fanout and 2/38-fanout' 'test_same_notes "s|^..|&/|" ""'
135 test_expect_success
'verify same notes in no fanout and 2/38-fanout' 'verify_notes'
137 test_expect_success
'test same notes in no fanout and 2/2/36-fanout' 'test_same_notes "s|^\(..\)\(..\)|\1/\2/|" ""'
138 test_expect_success
'verify same notes in no fanout and 2/2/36-fanout' 'verify_notes'
140 test_expect_success
'test same notes in 2/38-fanout and 2/2/36-fanout' 'test_same_notes "s|^\(..\)\(..\)|\1/\2/|" "s|^..|&/|"'
141 test_expect_success
'verify same notes in 2/38-fanout and 2/2/36-fanout' 'verify_notes'
143 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/|"'
144 test_expect_success
'verify same notes in 2/2/2/34-fanout and 2/2/36-fanout' 'verify_notes'
146 test_concatenated_notes
() {
149 nr
=$number_of_commits &&
150 git rev-list refs
/heads
/main |
152 first_note_path
=$
(echo "$sha1" |
sed "$1")
153 second_note_path
=$
(echo "$sha1" |
sed "$2")
155 M 100644 inline $second_note_path
157 second note for commit #$nr
160 M 100644 inline $first_note_path
162 first note for commit #$nr
170 git fast-import
--quiet
173 verify_concatenated_notes
() {
174 git log |
grep "^ " > output
&&
175 i
=$number_of_commits &&
176 while [ $i -gt 0 ]; do
177 echo " commit #$i" &&
178 echo " first note for commit #$i" &&
180 echo " second note for commit #$i" &&
183 test_cmp expect output
186 test_expect_success
'test notes in no fanout concatenated with 2/38-fanout' 'test_concatenated_notes "s|^..|&/|" ""'
187 test_expect_success
'verify notes in no fanout concatenated with 2/38-fanout' 'verify_concatenated_notes'
189 test_expect_success
'test notes in no fanout concatenated with 2/2/36-fanout' 'test_concatenated_notes "s|^\(..\)\(..\)|\1/\2/|" ""'
190 test_expect_success
'verify notes in no fanout concatenated with 2/2/36-fanout' 'verify_concatenated_notes'
192 test_expect_success
'test notes in 2/38-fanout concatenated with 2/2/36-fanout' 'test_concatenated_notes "s|^\(..\)\(..\)|\1/\2/|" "s|^..|&/|"'
193 test_expect_success
'verify notes in 2/38-fanout concatenated with 2/2/36-fanout' 'verify_concatenated_notes'
195 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/|"'
196 test_expect_success
'verify notes in 2/2/36-fanout concatenated with 2/2/2/34-fanout' 'verify_concatenated_notes'