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
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 a couple of commits" '
41 cat <<INPUT_END >input &&
42 commit refs/heads/main
43 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
56 cat <<INPUT_END >>input &&
57 commit refs/heads/main
58 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
69 git fast-import --quiet <input
72 test_expect_success
"create a notes tree with both notes and non-notes" '
74 commit1=$(git rev-parse refs/heads/main^) &&
75 commit2=$(git rev-parse refs/heads/main) &&
77 cat <<INPUT_END >input &&
78 commit refs/notes/commits
79 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
96 cat <<INPUT_END >>input &&
97 commit refs/notes/commits
98 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
103 M 644 inline foobar/non-note.txt
105 A non-note in a notes tree
110 edited note for commit #2
115 cat <<INPUT_END >>input &&
116 commit refs/notes/commits
117 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
124 edited note for commit #1
127 M 644 inline deadbeef
129 non-note with SHA1-like name
132 M 644 inline de/adbeef
134 another non-note with SHA1-like name
137 M 644 inline de/adbeefdeadbeefdeadbeefdeadbeefdeadbeef
139 This is actually a valid note, albeit to a non-existing object.
140 It is needed in order to trigger the "mishandling" of the dead/beef non-note.
143 M 644 inline dead/beef
145 yet another non-note with SHA1-like name
149 git fast-import --quiet <input &&
150 git config core.notesRef refs/notes/commits
153 cat >expect
<<EXPECT_END
155 edited note for commit #2
157 edited note for commit #1
160 test_expect_success
"verify contents of notes" '
162 git log | grep "^ " > actual &&
163 test_cmp expect actual
166 cat >expect_nn1
<<EXPECT_END
167 A non-note in a notes tree
169 cat >expect_nn2
<<EXPECT_END
170 non-note with SHA1-like name
172 cat >expect_nn3
<<EXPECT_END
173 another non-note with SHA1-like name
175 cat >expect_nn4
<<EXPECT_END
176 yet another non-note with SHA1-like name
179 test_expect_success
"verify contents of non-notes" '
181 git cat-file -p refs/notes/commits:foobar/non-note.txt > actual_nn1 &&
182 test_cmp expect_nn1 actual_nn1 &&
183 git cat-file -p refs/notes/commits:deadbeef > actual_nn2 &&
184 test_cmp expect_nn2 actual_nn2 &&
185 git cat-file -p refs/notes/commits:de/adbeef > actual_nn3 &&
186 test_cmp expect_nn3 actual_nn3 &&
187 git cat-file -p refs/notes/commits:dead/beef > actual_nn4 &&
188 test_cmp expect_nn4 actual_nn4
191 test_expect_success
"git-notes preserves non-notes" '
194 git notes add -f -m "foo bar"
197 test_expect_success
"verify contents of non-notes after git-notes" '
199 git cat-file -p refs/notes/commits:foobar/non-note.txt > actual_nn1 &&
200 test_cmp expect_nn1 actual_nn1 &&
201 git cat-file -p refs/notes/commits:deadbeef > actual_nn2 &&
202 test_cmp expect_nn2 actual_nn2 &&
203 git cat-file -p refs/notes/commits:de/adbeef > actual_nn3 &&
204 test_cmp expect_nn3 actual_nn3 &&
205 git cat-file -p refs/notes/commits:dead/beef > actual_nn4 &&
206 test_cmp expect_nn4 actual_nn4