3 test_description
='Test notes trees that also contain non-notes'
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" &&
36 test_cmp expect output
39 test_expect_success
"setup: create a couple of commits" '
42 cat <<INPUT_END >input &&
43 commit refs/heads/main
44 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
57 cat <<INPUT_END >>input &&
58 commit refs/heads/main
59 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
70 git fast-import --quiet <input
73 test_expect_success
"create a notes tree with both notes and non-notes" '
75 commit1=$(git rev-parse refs/heads/main^) &&
76 commit2=$(git rev-parse refs/heads/main) &&
78 cat <<INPUT_END >input &&
79 commit refs/notes/commits
80 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
97 cat <<INPUT_END >>input &&
98 commit refs/notes/commits
99 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
104 M 644 inline foobar/non-note.txt
106 A non-note in a notes tree
111 edited note for commit #2
116 cat <<INPUT_END >>input &&
117 commit refs/notes/commits
118 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
125 edited note for commit #1
128 M 644 inline deadbeef
130 non-note with SHA1-like name
133 M 644 inline de/adbeef
135 another non-note with SHA1-like name
138 M 644 inline de/adbeefdeadbeefdeadbeefdeadbeefdeadbeef
140 This is actually a valid note, albeit to a non-existing object.
141 It is needed in order to trigger the "mishandling" of the dead/beef non-note.
144 M 644 inline dead/beef
146 yet another non-note with SHA1-like name
150 git fast-import --quiet <input &&
151 git config core.notesRef refs/notes/commits
154 cat >expect
<<EXPECT_END
156 edited note for commit #2
158 edited note for commit #1
161 test_expect_success
"verify contents of notes" '
163 git log | grep "^ " > actual &&
164 test_cmp expect actual
167 cat >expect_nn1
<<EXPECT_END
168 A non-note in a notes tree
170 cat >expect_nn2
<<EXPECT_END
171 non-note with SHA1-like name
173 cat >expect_nn3
<<EXPECT_END
174 another non-note with SHA1-like name
176 cat >expect_nn4
<<EXPECT_END
177 yet another non-note with SHA1-like name
180 test_expect_success
"verify contents of non-notes" '
182 git cat-file -p refs/notes/commits:foobar/non-note.txt > actual_nn1 &&
183 test_cmp expect_nn1 actual_nn1 &&
184 git cat-file -p refs/notes/commits:deadbeef > actual_nn2 &&
185 test_cmp expect_nn2 actual_nn2 &&
186 git cat-file -p refs/notes/commits:de/adbeef > actual_nn3 &&
187 test_cmp expect_nn3 actual_nn3 &&
188 git cat-file -p refs/notes/commits:dead/beef > actual_nn4 &&
189 test_cmp expect_nn4 actual_nn4
192 test_expect_success
"git-notes preserves non-notes" '
195 git notes add -f -m "foo bar"
198 test_expect_success
"verify contents of non-notes after git-notes" '
200 git cat-file -p refs/notes/commits:foobar/non-note.txt > actual_nn1 &&
201 test_cmp expect_nn1 actual_nn1 &&
202 git cat-file -p refs/notes/commits:deadbeef > actual_nn2 &&
203 test_cmp expect_nn2 actual_nn2 &&
204 git cat-file -p refs/notes/commits:de/adbeef > actual_nn3 &&
205 test_cmp expect_nn3 actual_nn3 &&
206 git cat-file -p refs/notes/commits:dead/beef > actual_nn4 &&
207 test_cmp expect_nn4 actual_nn4