mirror of
				https://git.proxmox.com/git/libgit2
				synced 2025-11-04 07:09:14 +00:00 
			
		
		
		
	Merge pull request #2747 from libgit2/cmn/notes-consistency
Notes API consistency fixes
This commit is contained in:
		
						commit
						df86d43cf8
					
				@ -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.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
@ -135,10 +133,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 +146,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);
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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));
 | 
			
		||||
 | 
			
		||||
@ -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),
 | 
			
		||||
 | 
			
		||||
@ -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));
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user