summaryrefslogtreecommitdiff
path: root/src/notes.c
diff options
context:
space:
mode:
authorRichard Ipsum <richardipsum@fastmail.co.uk>2017-09-23 17:46:46 +0100
committerRichard Ipsum <richardipsum@fastmail.co.uk>2017-10-07 00:31:54 +0100
commita46e743d0153b9a565614776b9f3a71e0aebff25 (patch)
treed769167f466dacc8b08259774a9fa06c4e6d0778 /src/notes.c
parent5b1641fb22111b36f47dd2cacb9b06ace3a6d9cb (diff)
downloadlibgit2-a46e743d0153b9a565614776b9f3a71e0aebff25.tar.gz
notes: Add git_note_commit_create
This adds a new function that will allow creation of notes without necessarily updating a particular ref, the notes tree is obtained from the git_commit object parameter, a new commit object pointing to the current tip of the notes tree is optionally returned via the 'note_commit_out' parameter, optionally the blob id for the note is returned through the 'note_blob_out' object.
Diffstat (limited to 'src/notes.c')
-rw-r--r--src/notes.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/notes.c b/src/notes.c
index bed489014..9bace25f4 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -497,6 +497,37 @@ cleanup:
return error;
}
+int git_note_commit_create(
+ git_oid *notes_commit_out,
+ git_oid *notes_blob_out,
+ git_repository *repo,
+ git_commit *parent,
+ const git_signature *author,
+ const git_signature *committer,
+ const git_oid *oid,
+ const char *note,
+ int allow_note_overwrite)
+{
+ int error;
+ git_tree *tree = NULL;
+ char target[GIT_OID_HEXSZ + 1];
+
+ git_oid_tostr(target, sizeof(target), oid);
+
+ if (parent != NULL && (error = git_commit_tree(&tree, parent)) < 0)
+ goto cleanup;
+
+ error = note_write(notes_commit_out, notes_blob_out, repo, author,
+ committer, NULL, note, tree, target, &parent, allow_note_overwrite);
+
+ if (error < 0)
+ goto cleanup;
+
+cleanup:
+ git_tree_free(tree);
+ return error;
+}
+
int git_note_remove(git_repository *repo, const char *notes_ref_in,
const git_signature *author, const git_signature *committer,
const git_oid *oid)