static int notes_ref_lookup(git_buf *out, git_rebase *rebase) { git_config *config = NULL; int do_rewrite, error; if (rebase->options.rewrite_notes_ref) { git_buf_attach_notowned(out, rebase->options.rewrite_notes_ref, strlen(rebase->options.rewrite_notes_ref)); return 0; } if ((error = git_repository_config(&config, rebase->repo)) < 0 || (error = git_config_get_bool(&do_rewrite, config, "notes.rewrite.rebase")) < 0) { if (error != GIT_ENOTFOUND) goto done; giterr_clear(); do_rewrite = 1; } error = do_rewrite ? git_config_get_string_buf(out, config, "notes.rewriteref") : GIT_ENOTFOUND; done: git_config_free(config); return error; }
int git_blob_is_binary(const git_blob *blob) { git_buf content = GIT_BUF_INIT; assert(blob); git_buf_attach_notowned(&content, git_blob_rawcontent(blob), min(git_blob_rawsize(blob), GIT_FILTER_BYTES_TO_CHECK_NUL)); return git_buf_text_is_binary(&content); }
int git_blob_is_binary(const git_blob *blob) { git_buf content = GIT_BUF_INIT; assert(blob); git_buf_attach_notowned(&content, blob->odb_object->buffer, min(blob->odb_object->cached.size, GIT_FILTER_BYTES_TO_CHECK_NUL)); return git_buf_text_is_binary(&content); }
void test_core_buffer__dont_grow_borrowed(void) { const char *somestring = "blah blah"; git_buf buf = GIT_BUF_INIT; git_buf_attach_notowned(&buf, somestring, strlen(somestring) + 1); cl_assert_equal_p(somestring, buf.ptr); cl_assert_equal_i(0, buf.asize); cl_assert_equal_i(strlen(somestring) + 1, buf.size); cl_git_fail_with(GIT_EINVALID, git_buf_grow(&buf, 1024)); }