diff options
author | Michael Schubert <schu@schu.io> | 2012-04-29 18:42:42 +0200 |
---|---|---|
committer | Michael Schubert <schu@schu.io> | 2012-05-03 22:31:29 +0200 |
commit | caea5e543379c053de5eec45b8f5a0e83c07e3fe (patch) | |
tree | 8809ce6a805b0257bbfc726143ade0390e6b4414 /tests-clar/notes/notesref.c | |
parent | 76873c09053e210c7f739b1cda39cffd6ab865e0 (diff) | |
download | libgit2-caea5e543379c053de5eec45b8f5a0e83c07e3fe.tar.gz |
notes: honor core.notesRef
Setting core.notesRef allows to change the default notes reference used
by Git. Check if set before using GIT_NOTES_DEFAULT_REF. Fixes #649.
Diffstat (limited to 'tests-clar/notes/notesref.c')
-rw-r--r-- | tests-clar/notes/notesref.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests-clar/notes/notesref.c b/tests-clar/notes/notesref.c new file mode 100644 index 000000000..f1456663a --- /dev/null +++ b/tests-clar/notes/notesref.c @@ -0,0 +1,46 @@ +#include "clar_libgit2.h" + +static git_repository *_repo; +static git_note *_note; +static git_signature *_sig; +static git_config *_cfg; + +void test_notes_notesref__initialize(void) +{ + cl_fixture_sandbox("testrepo.git"); + cl_git_pass(git_repository_open(&_repo, "testrepo.git")); +} + +void test_notes_notesref__cleanup(void) +{ + git_note_free(_note); + git_signature_free(_sig); + git_config_free(_cfg); + + git_repository_free(_repo); + cl_fixture_cleanup("testrepo.git"); +} + +void test_notes_notesref__config_corenotesref(void) +{ + git_oid oid, note_oid; + + cl_git_pass(git_signature_now(&_sig, "alice", "alice@example.com")); + cl_git_pass(git_oid_fromstr(&oid, "8496071c1b46c854b31185ea97743be6a8774479")); + + cl_git_pass(git_repository_config(&_cfg, _repo)); + + cl_git_pass(git_config_set_string(_cfg, "core.notesRef", "refs/notes/mydefaultnotesref")); + + cl_git_pass(git_note_create(¬e_oid, _repo, _sig, _sig, NULL, &oid, "test123test\n")); + + cl_git_pass(git_note_read(&_note, _repo, NULL, &oid)); + cl_assert(!strcmp(git_note_message(_note), "test123test\n")); + cl_assert(!git_oid_cmp(git_note_oid(_note), ¬e_oid)); + + git_note_free(_note); + + cl_git_pass(git_note_read(&_note, _repo, "refs/notes/mydefaultnotesref", &oid)); + cl_assert(!strcmp(git_note_message(_note), "test123test\n")); + cl_assert(!git_oid_cmp(git_note_oid(_note), ¬e_oid)); +} |