Commit 21083a712933248ecc71a09abd20d548b912b194

Carlos Martín Nieto 2014-12-06T03:12:04

notes: move the notes name argument Make it consistent between git_note_create() and git_note_remote() by putting it after the repository.

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7bc40c5..a2c2191 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 1a7794a..65ce548 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 4b15925..8fdf388 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 6453ecc..2681b3e 100644
--- a/src/rebase.c
+++ b/src/rebase.c
@@ -972,8 +972,8 @@ static int rebase_copy_note(
 		committer = who;
 	}
 
-	error = git_note_create(&note_id, rebase->repo, git_note_author(note),
-		committer, opts->rewrite_notes_ref, to, git_note_message(note), 0);
+	error = git_note_create(&note_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 8b1b578..d3b915e 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(&note_oid, NULL, "08b041783f40edfe12bb406c9c9a8a040177c125", "hello world\n");
-	error = git_note_create(&note_oid, _repo, _sig, _sig, NULL, &target_oid, "hello world\n", 0);
+	error = git_note_create(&note_oid, _repo, NULL, _sig, _sig, &target_oid, "hello world\n", 0);
 	cl_git_fail(error);
 	cl_assert_equal_i(GIT_EEXISTS, error);
 
 	create_note(&note_oid, "refs/notes/some/namespace", "08b041783f40edfe12bb406c9c9a8a040177c125", "hello world\n");
-	error = git_note_create(&note_oid, _repo, _sig, _sig, "refs/notes/some/namespace", &target_oid, "hello world\n", 0);
+	error = git_note_create(&note_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(&note_oid, NULL, "08b041783f40edfe12bb406c9c9a8a040177c125", "hello old world\n");
-	cl_git_pass(git_note_create(&note_oid, _repo, _sig, _sig, NULL, &target_oid, "hello new world\n", 1));
+	cl_git_pass(git_note_create(&note_oid, _repo, NULL, _sig, _sig, &target_oid, "hello new world\n", 1));
 
 	cl_git_pass(git_note_read(&note, _repo, NULL, &target_oid));
 	assert_note_equal(note, "hello new world\n", &note_oid);
 
 	create_note(&note_oid, "refs/notes/some/namespace", "08b041783f40edfe12bb406c9c9a8a040177c125", "hello old world\n");
-	cl_git_pass(git_note_create(&note_oid, _repo, _sig, _sig, "refs/notes/some/namespace", &target_oid, "hello new ref world\n", 1));
+	cl_git_pass(git_note_create(&note_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", &note_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(&note_oid, _repo, _sig, _sig, "refs/notes/fanout", &target_oid, messages[i], 0));
+		cl_git_pass(git_note_create(&note_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 a59af20..11391e4 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(&note_oid, _repo, _sig, _sig, NULL, &oid, "test123test\n", 0));
+	cl_git_pass(git_note_create(&note_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 6424b5b..86862ee 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(&note_oid, _repo, signature, signature, NULL, target_oid, "hello world\n", 0));
+	cl_git_pass(git_note_create(&note_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(&note_oid, _repo, signature, signature, NULL, target_oid, "hello world\n", 0));
+	cl_git_pass(git_note_create(&note_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 e7eb167..0617771 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(&note_id, repo,
+	cl_git_pass(git_note_create(&note_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));