From 21083a712933248ecc71a09abd20d548b912b194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sat, 6 Dec 2014 03:12:04 +0100 Subject: [PATCH 1/2] notes: move the notes name argument Make it consistent between git_note_create() and git_note_remote() by putting it after the repository. --- CHANGELOG.md | 3 +++ include/git2/notes.h | 6 +++--- src/notes.c | 2 +- src/rebase.c | 4 ++-- tests/notes/notes.c | 12 ++++++------ tests/notes/notesref.c | 2 +- tests/online/push.c | 4 ++-- tests/rebase/merge.c | 4 ++-- 8 files changed, 20 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bc40c511..a2c219124 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,6 +108,9 @@ v0.21 + 1 * Introduce git_note_author() and git_note_committer() to get the author and committer information on a git_note, respectively. +* git_note_create() has changed the position of the notes reference + name to match git_note_remove(). + * The THREADSAFE option to build libgit2 with threading support has been flipped to be on by default. diff --git a/include/git2/notes.h b/include/git2/notes.h index 1a7794a5c..65ce5480b 100644 --- a/include/git2/notes.h +++ b/include/git2/notes.h @@ -135,10 +135,10 @@ GIT_EXTERN(const git_oid *) git_note_id(const git_note *note); * * @param out pointer to store the OID (optional); NULL in case of error * @param repo repository where to store the note - * @param author signature of the notes commit author - * @param committer signature of the notes commit committer * @param notes_ref canonical name of the reference to use (optional); * defaults to "refs/notes/commits" + * @param author signature of the notes commit author + * @param committer signature of the notes commit committer * @param oid OID of the git object to decorate * @param note Content of the note to add for object oid * @param force Overwrite existing note @@ -148,9 +148,9 @@ GIT_EXTERN(const git_oid *) git_note_id(const git_note *note); GIT_EXTERN(int) git_note_create( git_oid *out, git_repository *repo, + const char *notes_ref, const git_signature *author, const git_signature *committer, - const char *notes_ref, const git_oid *oid, const char *note, int force); diff --git a/src/notes.c b/src/notes.c index 4b15925fd..8fdf388ab 100644 --- a/src/notes.c +++ b/src/notes.c @@ -455,9 +455,9 @@ int git_note_read(git_note **out, git_repository *repo, int git_note_create( git_oid *out, git_repository *repo, + const char *notes_ref, const git_signature *author, const git_signature *committer, - const char *notes_ref, const git_oid *oid, const char *note, int allow_note_overwrite) diff --git a/src/rebase.c b/src/rebase.c index 6453ecc67..2681b3e6a 100644 --- a/src/rebase.c +++ b/src/rebase.c @@ -972,8 +972,8 @@ static int rebase_copy_note( committer = who; } - error = git_note_create(¬e_id, rebase->repo, git_note_author(note), - committer, opts->rewrite_notes_ref, to, git_note_message(note), 0); + error = git_note_create(¬e_id, rebase->repo, opts->rewrite_notes_ref, + git_note_author(note), committer, to, git_note_message(note), 0); done: git_note_free(note); diff --git a/tests/notes/notes.c b/tests/notes/notes.c index 8b1b57866..d3b915e15 100644 --- a/tests/notes/notes.c +++ b/tests/notes/notes.c @@ -34,7 +34,7 @@ static void create_note(git_oid *note_oid, const char *canonical_namespace, cons git_oid oid; cl_git_pass(git_oid_fromstr(&oid, target_sha)); - cl_git_pass(git_note_create(note_oid, _repo, _sig, _sig, canonical_namespace, &oid, message, 0)); + cl_git_pass(git_note_create(note_oid, _repo, canonical_namespace, _sig, _sig, &oid, message, 0)); } static struct { @@ -195,12 +195,12 @@ void test_notes_notes__creating_a_note_on_a_target_which_already_has_one_returns cl_git_pass(git_oid_fromstr(&target_oid, "08b041783f40edfe12bb406c9c9a8a040177c125")); create_note(¬e_oid, NULL, "08b041783f40edfe12bb406c9c9a8a040177c125", "hello world\n"); - error = git_note_create(¬e_oid, _repo, _sig, _sig, NULL, &target_oid, "hello world\n", 0); + error = git_note_create(¬e_oid, _repo, NULL, _sig, _sig, &target_oid, "hello world\n", 0); cl_git_fail(error); cl_assert_equal_i(GIT_EEXISTS, error); create_note(¬e_oid, "refs/notes/some/namespace", "08b041783f40edfe12bb406c9c9a8a040177c125", "hello world\n"); - error = git_note_create(¬e_oid, _repo, _sig, _sig, "refs/notes/some/namespace", &target_oid, "hello world\n", 0); + error = git_note_create(¬e_oid, _repo, "refs/notes/some/namespace", _sig, _sig, &target_oid, "hello world\n", 0); cl_git_fail(error); cl_assert_equal_i(GIT_EEXISTS, error); } @@ -214,13 +214,13 @@ void test_notes_notes__creating_a_note_on_a_target_can_overwrite_existing_note(v cl_git_pass(git_oid_fromstr(&target_oid, "08b041783f40edfe12bb406c9c9a8a040177c125")); create_note(¬e_oid, NULL, "08b041783f40edfe12bb406c9c9a8a040177c125", "hello old world\n"); - cl_git_pass(git_note_create(¬e_oid, _repo, _sig, _sig, NULL, &target_oid, "hello new world\n", 1)); + cl_git_pass(git_note_create(¬e_oid, _repo, NULL, _sig, _sig, &target_oid, "hello new world\n", 1)); cl_git_pass(git_note_read(¬e, _repo, NULL, &target_oid)); assert_note_equal(note, "hello new world\n", ¬e_oid); create_note(¬e_oid, "refs/notes/some/namespace", "08b041783f40edfe12bb406c9c9a8a040177c125", "hello old world\n"); - cl_git_pass(git_note_create(¬e_oid, _repo, _sig, _sig, "refs/notes/some/namespace", &target_oid, "hello new ref world\n", 1)); + cl_git_pass(git_note_create(¬e_oid, _repo, "refs/notes/some/namespace", _sig, _sig, &target_oid, "hello new ref world\n", 1)); cl_git_pass(git_note_read(&namespace_note, _repo, "refs/notes/some/namespace", &target_oid)); assert_note_equal(namespace_note, "hello new ref world\n", ¬e_oid); @@ -269,7 +269,7 @@ void test_notes_notes__can_insert_a_note_in_an_existing_fanout(void) cl_git_pass(git_oid_fromstr(&target_oid, "08b041783f40edfe12bb406c9c9a8a040177c125")); for (i = 0; i < MESSAGES_COUNT; i++) { - cl_git_pass(git_note_create(¬e_oid, _repo, _sig, _sig, "refs/notes/fanout", &target_oid, messages[i], 0)); + cl_git_pass(git_note_create(¬e_oid, _repo, "refs/notes/fanout", _sig, _sig, &target_oid, messages[i], 0)); cl_git_pass(git_note_read(&_note, _repo, "refs/notes/fanout", &target_oid)); git_note_free(_note); diff --git a/tests/notes/notesref.c b/tests/notes/notesref.c index a59af209c..11391e448 100644 --- a/tests/notes/notesref.c +++ b/tests/notes/notesref.c @@ -42,7 +42,7 @@ void test_notes_notesref__config_corenotesref(void) 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", 0)); + cl_git_pass(git_note_create(¬e_oid, _repo, NULL, _sig, _sig, &oid, "test123test\n", 0)); cl_git_pass(git_note_read(&_note, _repo, NULL, &oid)); cl_assert_equal_s("test123test\n", git_note_message(_note)); diff --git a/tests/online/push.c b/tests/online/push.c index 6424b5ba6..86862ee8f 100644 --- a/tests/online/push.c +++ b/tests/online/push.c @@ -863,7 +863,7 @@ void test_online_push__notes(void) /* Create note to push */ cl_git_pass(git_signature_new(&signature, "nulltoken", "emeric.fermas@gmail.com", 1323847743, 60)); /* Wed Dec 14 08:29:03 2011 +0100 */ - cl_git_pass(git_note_create(¬e_oid, _repo, signature, signature, NULL, target_oid, "hello world\n", 0)); + cl_git_pass(git_note_create(¬e_oid, _repo, NULL, signature, signature, target_oid, "hello world\n", 0)); do_push(specs, ARRAY_SIZE(specs), exp_stats, ARRAY_SIZE(exp_stats), @@ -895,7 +895,7 @@ void test_online_push__configured(void) /* Create note to push */ cl_git_pass(git_signature_new(&signature, "nulltoken", "emeric.fermas@gmail.com", 1323847743, 60)); /* Wed Dec 14 08:29:03 2011 +0100 */ - cl_git_pass(git_note_create(¬e_oid, _repo, signature, signature, NULL, target_oid, "hello world\n", 0)); + cl_git_pass(git_note_create(¬e_oid, _repo, NULL, signature, signature, target_oid, "hello world\n", 0)); do_push(NULL, 0, exp_stats, ARRAY_SIZE(exp_stats), diff --git a/tests/rebase/merge.c b/tests/rebase/merge.c index e7eb16713..06177717c 100644 --- a/tests/rebase/merge.c +++ b/tests/rebase/merge.c @@ -416,9 +416,9 @@ static void test_copy_note( branch_ref, GIT_OBJ_COMMIT)); /* Add a note to a commit */ - cl_git_pass(git_note_create(¬e_id, repo, + cl_git_pass(git_note_create(¬e_id, repo, "refs/notes/test", git_commit_author(branch_commit), git_commit_committer(branch_commit), - "refs/notes/test", git_commit_id(branch_commit), + git_commit_id(branch_commit), "This is a commit note.", 0)); cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, opts)); From bfa6cdbf13be242df0cde6cd6e51a005600c0f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sat, 6 Dec 2014 03:13:44 +0100 Subject: [PATCH 2/2] notes: fix comments for git_note_next() The iterator is the last argument. There is also no returned notes, just ids, so the comment about freeing is out of place. --- include/git2/notes.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/git2/notes.h b/include/git2/notes.h index 65ce5480b..bb7c02dda 100644 --- a/include/git2/notes.h +++ b/include/git2/notes.h @@ -59,14 +59,12 @@ GIT_EXTERN(int) git_note_iterator_new( GIT_EXTERN(void) git_note_iterator_free(git_note_iterator *it); /** - * Returns the current item (note_id and annotated_id) and advance the iterator + * Return the current item (note_id and annotated_id) and advance the iterator * internally to the next value * - * The notes must not be freed manually by the user. - * - * @param it pointer to the iterator * @param note_id id of blob containing the message * @param annotated_id id of the git object being annotated + * @param it pointer to the iterator * * @return 0 (no error), GIT_ITEROVER (iteration is done) or an error code * (negative value)