Exemple #1
0
int git_note_foreach(
	git_repository *repo,
	const char *notes_ref,
	git_note_foreach_cb note_cb,
	void *payload)
{
	int error;
	git_iterator *iter = NULL;
	git_tree *tree = NULL;
	git_commit *commit = NULL;
	const git_index_entry *item;

	if (!(error = retrieve_note_tree_and_commit(
			&tree, &commit, repo, &notes_ref)) &&
		!(error = git_iterator_for_tree(&iter, tree)))
		error = git_iterator_current(iter, &item);

	while (!error && item) {
		error = process_entry_path(item->path, &item->oid, note_cb, payload);

		if (!error)
			error = git_iterator_advance(iter, &item);
	}

	git_iterator_free(iter);
	git_tree_free(tree);
	git_commit_free(commit);

	return error;
}
Exemple #2
0
int git_note_create(
	git_oid *out,
	git_repository *repo,
	const git_signature *author,
	const git_signature *committer,
	const char *notes_ref,
	const git_oid *oid,
	const char *note)
{
	int error;
	char *target = NULL;
	git_commit *commit = NULL;
	git_tree *tree = NULL;

	target = git_oid_allocfmt(oid);
	GITERR_CHECK_ALLOC(target);

	error = retrieve_note_tree_and_commit(&tree, &commit, repo, &notes_ref);

	if (error < 0 && error != GIT_ENOTFOUND)
		goto cleanup;

	error = note_write(out, repo, author, committer, notes_ref,
			note, tree, target, &commit);

cleanup:
	git__free(target);
	git_commit_free(commit);
	git_tree_free(tree);
	return error;
}
Exemple #3
0
int git_note_read(git_note **out, git_repository *repo,
		  const char *notes_ref, const git_oid *oid)
{
	int error;
	char *target = NULL;
	git_tree *tree = NULL;
	git_commit *commit = NULL;

	target = git_oid_allocfmt(oid);
	GITERR_CHECK_ALLOC(target);

	if (!(error = retrieve_note_tree_and_commit(
			&tree, &commit, repo, &notes_ref)))
		error = note_lookup(out, repo, tree, target);

	git__free(target);
	git_tree_free(tree);
	git_commit_free(commit);
	return error;
}
Exemple #4
0
int git_note_iterator_new(
	git_note_iterator **it,
	git_repository *repo,
	const char *notes_ref)
{
	int error;
	git_commit *commit = NULL;
	git_tree *tree = NULL;

	error = retrieve_note_tree_and_commit(&tree, &commit, repo, &notes_ref);
	if (error < 0)
		goto cleanup;

	if ((error = git_iterator_for_tree(it, tree, 0, NULL, NULL)) < 0)
		git_iterator_free(*it);

cleanup:
	git_tree_free(tree);
	git_commit_free(commit);

	return error;
}
Exemple #5
0
int git_note_remove(git_repository *repo, const char *notes_ref,
		const git_signature *author, const git_signature *committer,
		const git_oid *oid)
{
	int error;
	char *target = NULL;
	git_commit *commit = NULL;
	git_tree *tree = NULL;

	target = git_oid_allocfmt(oid);
	GITERR_CHECK_ALLOC(target);

	if (!(error = retrieve_note_tree_and_commit(
			&tree, &commit, repo, &notes_ref)))
		error = note_remove(
			repo, author, committer, notes_ref, tree, target, &commit);

	git__free(target);
	git_commit_free(commit);
	git_tree_free(tree);
	return error;
}