diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2020-05-27 22:47:31 +0100 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2020-05-29 11:33:58 +0100 |
| commit | 143f545ba99663eebb6087ccac3595c94e9d70e9 (patch) | |
| tree | 7d548d82997807c8927dd174fae10abb54ca6c71 | |
| parent | 56b37fbf750a8200301f1e85191804726742db4f (diff) | |
| download | libgit2-143f545ba99663eebb6087ccac3595c94e9d70e9.tar.gz | |
notes: user-facing functions write to a userbuf
| -rw-r--r-- | include/git2/notes.h | 2 | ||||
| -rw-r--r-- | src/notes.c | 7 | ||||
| -rw-r--r-- | tests/notes/notes.c | 6 | ||||
| -rw-r--r-- | tests/notes/notesref.c | 6 |
4 files changed, 11 insertions, 10 deletions
diff --git a/include/git2/notes.h b/include/git2/notes.h index c36149e5b..4418e81d5 100644 --- a/include/git2/notes.h +++ b/include/git2/notes.h @@ -277,7 +277,7 @@ GIT_EXTERN(void) git_note_free(git_note *note); * * @return 0 or an error code */ -GIT_EXTERN(int) git_note_default_ref(git_buf *out, git_repository *repo); +GIT_EXTERN(int) git_note_default_ref(git_userbuf *out, git_repository *repo); /** * Loop over all the notes within a specified namespace diff --git a/src/notes.c b/src/notes.c index 68d2ae9ec..30b37281b 100644 --- a/src/notes.c +++ b/src/notes.c @@ -13,6 +13,7 @@ #include "iterator.h" #include "signature.h" #include "blob.h" +#include "userbuf.h" static int note_error_notfound(void) { @@ -622,19 +623,19 @@ cleanup: return error; } -int git_note_default_ref(git_buf *out, git_repository *repo) +int git_note_default_ref(git_userbuf *out, git_repository *repo) { char *default_ref; int error; assert(out && repo); - git_buf_sanitize(out); + git_userbuf_sanitize(out); if ((error = note_get_default_ref(&default_ref, repo)) < 0) return error; - git_buf_attach(out, default_ref, strlen(default_ref)); + git_buf_attach((git_buf *)out, default_ref, strlen(default_ref)); return 0; } diff --git a/tests/notes/notes.c b/tests/notes/notes.c index af9686790..653069c2a 100644 --- a/tests/notes/notes.c +++ b/tests/notes/notes.c @@ -274,7 +274,7 @@ void test_notes_notes__inserting_a_note_without_passing_a_namespace_uses_the_def { git_oid note_oid, target_oid; git_note *note, *default_namespace_note; - git_buf default_ref = GIT_BUF_INIT; + git_userbuf default_ref = GIT_USERBUF_INIT; cl_git_pass(git_oid_fromstr(&target_oid, "08b041783f40edfe12bb406c9c9a8a040177c125")); cl_git_pass(git_note_default_ref(&default_ref, _repo)); @@ -282,12 +282,12 @@ void test_notes_notes__inserting_a_note_without_passing_a_namespace_uses_the_def create_note(¬e_oid, NULL, "08b041783f40edfe12bb406c9c9a8a040177c125", "hello world\n"); cl_git_pass(git_note_read(¬e, _repo, NULL, &target_oid)); - cl_git_pass(git_note_read(&default_namespace_note, _repo, git_buf_cstr(&default_ref), &target_oid)); + cl_git_pass(git_note_read(&default_namespace_note, _repo, default_ref.ptr, &target_oid)); assert_note_equal(note, "hello world\n", ¬e_oid); assert_note_equal(default_namespace_note, "hello world\n", ¬e_oid); - git_buf_dispose(&default_ref); + git_userbuf_dispose(&default_ref); git_note_free(note); git_note_free(default_namespace_note); } diff --git a/tests/notes/notesref.c b/tests/notes/notesref.c index 3bcb05f20..88e24824c 100644 --- a/tests/notes/notesref.c +++ b/tests/notes/notesref.c @@ -34,7 +34,7 @@ void test_notes_notesref__cleanup(void) void test_notes_notesref__config_corenotesref(void) { git_oid oid, note_oid; - git_buf default_ref = GIT_BUF_INIT; + git_userbuf default_ref = GIT_USERBUF_INIT; cl_git_pass(git_signature_now(&_sig, "alice", "alice@example.com")); cl_git_pass(git_oid_fromstr(&oid, "8496071c1b46c854b31185ea97743be6a8774479")); @@ -57,12 +57,12 @@ void test_notes_notesref__config_corenotesref(void) cl_git_pass(git_note_default_ref(&default_ref, _repo)); cl_assert_equal_s("refs/notes/mydefaultnotesref", default_ref.ptr); - git_buf_clear(&default_ref); + git_userbuf_dispose(&default_ref); cl_git_pass(git_config_delete_entry(_cfg, "core.notesRef")); cl_git_pass(git_note_default_ref(&default_ref, _repo)); cl_assert_equal_s(GIT_NOTES_DEFAULT_REF, default_ref.ptr); - git_buf_dispose(&default_ref); + git_userbuf_dispose(&default_ref); } |
