Skip to content

Commit 5b1641f

Browse files
committed
notes: Make note_write return commit oid
For the new 'commit' API it will be necessary to know the OID of the notes commit that was written as well as the OID of the notes blob.
1 parent ffd4df6 commit 5b1641f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/notes.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ static int insert_note_in_tree_enotfound_cb(git_tree **out,
268268
GIT_FILEMODE_BLOB);
269269
}
270270

271-
static int note_write(git_oid *out,
271+
static int note_write(
272+
git_oid *notes_commit_out,
273+
git_oid *notes_blob_out,
272274
git_repository *repo,
273275
const git_signature *author,
274276
const git_signature *committer,
@@ -294,13 +296,17 @@ static int note_write(git_oid *out,
294296
insert_note_in_tree_enotfound_cb)) < 0)
295297
goto cleanup;
296298

297-
if (out)
298-
git_oid_cpy(out, &oid);
299+
if (notes_blob_out)
300+
git_oid_cpy(notes_blob_out, &oid);
301+
299302

300303
error = git_commit_create(&oid, repo, notes_ref, author, committer,
301304
NULL, GIT_NOTES_DEFAULT_MSG_ADD,
302305
tree, *parents == NULL ? 0 : 1, (const git_commit **) parents);
303306

307+
if (notes_commit_out)
308+
git_oid_cpy(notes_commit_out, &oid);
309+
304310
cleanup:
305311
git_tree_free(tree);
306312
return error;
@@ -480,7 +486,7 @@ int git_note_create(
480486
if (error < 0 && error != GIT_ENOTFOUND)
481487
goto cleanup;
482488

483-
error = note_write(out, repo, author, committer, notes_ref,
489+
error = note_write(NULL, out, repo, author, committer, notes_ref,
484490
note, tree, target, &commit, allow_note_overwrite);
485491

486492
cleanup:

0 commit comments

Comments
 (0)