Skip to content

Commit 4623c25

Browse files
committed
notes: Add test that read of noteless commit fails
1 parent d788f42 commit 4623c25

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/notes/notes.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,31 @@ void test_notes_notes__can_read_a_note_from_a_commit(void)
415415
git_note_free(note);
416416
}
417417

418+
/* Test that we can read a commit with no note fails */
419+
void test_notes_notes__attempt_to_read_a_note_from_a_commit_with_no_note_fails(void)
420+
{
421+
git_oid oid, notes_commit_oid;
422+
git_commit *notes_commit;
423+
git_note *note;
424+
425+
cl_git_pass(git_oid_fromstr(&oid, "4a202b346bb0fb0db7eff3cffeb3c70babbd2045"));
426+
427+
cl_git_pass(git_note_commit_create(&notes_commit_oid, NULL, _repo, NULL, _sig, _sig, &oid, "I decorate 4a20\n", 1));
428+
429+
git_commit_lookup(&notes_commit, _repo, &notes_commit_oid);
430+
431+
cl_git_pass(git_note_commit_remove(&notes_commit_oid, _repo, notes_commit, _sig, _sig, &oid));
432+
git_commit_free(notes_commit);
433+
434+
git_commit_lookup(&notes_commit, _repo, &notes_commit_oid);
435+
436+
cl_assert(notes_commit);
437+
438+
cl_git_fail_with(GIT_ENOTFOUND, git_note_commit_read(&note, _repo, notes_commit, &oid));
439+
440+
git_commit_free(notes_commit);
441+
}
442+
418443
/*
419444
* $ git ls-tree refs/notes/fanout
420445
* 040000 tree 4b22b35d44b5a4f589edf3dc89196399771796ea 84

0 commit comments

Comments
 (0)