🍯 Glaze

package git2_bindings

import "core:c"

foreign import git2 "system:git2"
@(default_calling_convention = "c", link_prefix = "git_")
foreign git2 {
	libgit2_init :: proc() -> c.int ---
	libgit2_shutdown :: proc() -> c.int ---

	error_last :: proc() -> ^Error ---
	error_clear :: proc() ---

	repository_open :: proc(out: ^Repository, path: cstring) -> Result ---
	repository_open_bare :: proc(out: ^Repository, bare_path: cstring) -> Result ---
	repository_open_ext :: proc(out: ^Repository, path: cstring, flags: c.uint, ceiling_dirs: cstring) -> Result ---
	repository_init :: proc(out: ^Repository, path: cstring, is_bare: c.uint) -> Result ---
	repository_free :: proc(repo: Repository) ---
	repository_head :: proc(out: ^Reference, repo: Repository) -> Result ---
	repository_head_detached :: proc(repo: Repository) -> c.int ---
	repository_head_unborn :: proc(repo: Repository) -> c.int ---
	repository_is_empty :: proc(repo: Repository) -> c.int ---
	repository_is_bare :: proc(repo: Repository) -> c.int ---
	repository_is_worktree :: proc(repo: Repository) -> c.int ---
	repository_is_shallow :: proc(repo: Repository) -> c.int ---
	repository_path :: proc(repo: Repository) -> cstring ---
	repository_workdir :: proc(repo: Repository) -> cstring ---
	repository_commondir :: proc(repo: Repository) -> cstring ---
	repository_set_workdir :: proc(repo: Repository, workdir: cstring, update_gitlink: c.int) -> Result ---
	repository_config :: proc(out: ^Config, repo: Repository) -> Result ---
	repository_config_snapshot :: proc(out: ^Config, repo: Repository) -> Result ---
	repository_odb :: proc(out: ^Odb, repo: Repository) -> Result ---
	repository_index :: proc(out: ^Index, repo: Repository) -> Result ---
	repository_message :: proc(out: ^Buf, repo: Repository) -> Result ---
	repository_message_remove :: proc(repo: Repository) -> Result ---
	repository_state :: proc(repo: Repository) -> c.int ---
	repository_state_cleanup :: proc(repo: Repository) -> Result ---
	repository_set_head :: proc(repo: Repository, refname: cstring) -> Result ---
	repository_set_head_detached :: proc(repo: Repository, commitish: ^Oid) -> Result ---
	repository_detach_head :: proc(repo: Repository) -> Result ---
	repository_set_namespace :: proc(repo: Repository, nmspace: cstring) -> Result ---
	repository_get_namespace :: proc(repo: Repository) -> cstring ---
	repository_set_ident :: proc(repo: Repository, name: cstring, email: cstring) -> Result ---
	repository_discover :: proc(out: ^Buf, start_path: cstring, across_fs: c.int, ceiling_dirs: cstring) -> Result ---
	repository_fetchhead_foreach :: proc(repo: Repository, callback: Fetchhead_Foreach_Cb, payload: rawptr) -> Result ---
	repository_mergehead_foreach :: proc(repo: Repository, callback: Mergehead_Foreach_Cb, payload: rawptr) -> Result ---
	repository_hashfile :: proc(out: ^Oid, repo: Repository, path: cstring, type: Object_Type, as_path: cstring) -> Result ---

	reference_lookup :: proc(out: ^Reference, repo: Repository, name: cstring) -> Result ---
	reference_name_to_id :: proc(out: ^Oid, repo: Repository, name: cstring) -> Result ---
	reference_dwim :: proc(out: ^Reference, repo: Repository, shorthand: cstring) -> Result ---
	reference_create :: proc(out: ^Reference, repo: Repository, name: cstring, id: ^Oid, force: c.int, log_message: cstring) -> Result ---
	reference_symbolic_create :: proc(out: ^Reference, repo: Repository, name: cstring, target: cstring, force: c.int, log_message: cstring) -> Result ---
	reference_target :: proc(ref: Reference) -> ^Oid ---
	reference_target_peel :: proc(ref: Reference) -> ^Oid ---
	reference_symbolic_target :: proc(ref: Reference) -> cstring ---
	reference_type :: proc(ref: Reference) -> Reference_Type ---
	reference_name :: proc(ref: Reference) -> cstring ---
	reference_resolve :: proc(out: ^Reference, ref: Reference) -> Result ---
	reference_owner :: proc(ref: Reference) -> Repository ---
	reference_set_target :: proc(out: ^Reference, ref: Reference, id: ^Oid, log_message: cstring) -> Result ---
	reference_symbolic_set_target :: proc(out: ^Reference, ref: Reference, target: cstring, log_message: cstring) -> Result ---
	reference_rename :: proc(new_ref: ^Reference, ref: Reference, new_name: cstring, force: c.int, log_message: cstring) -> Result ---
	reference_delete :: proc(ref: Reference) -> Result ---
	reference_remove :: proc(repo: Repository, name: cstring) -> Result ---
	reference_list :: proc(array: ^Strarray, repo: Repository) -> Result ---
	reference_foreach_name :: proc(repo: Repository, callback: Reference_Foreach_Name_Cb, payload: rawptr) -> Result ---
	reference_dup :: proc(dest: ^Reference, source: Reference) -> Result ---
	reference_free :: proc(ref: Reference) ---
	reference_cmp :: proc(ref1: Reference, ref2: Reference) -> c.int ---
	reference_iterator_new :: proc(out: ^Reference_Iterator, repo: Repository) -> Result ---
	reference_iterator_glob_new :: proc(out: ^Reference_Iterator, repo: Repository, glob: cstring) -> Result ---
	reference_next :: proc(out: ^Reference, iter: Reference_Iterator) -> Result ---
	reference_next_name :: proc(out: ^cstring, iter: Reference_Iterator) -> Result ---
	reference_iterator_free :: proc(iter: Reference_Iterator) ---
	reference_has_log :: proc(repo: Repository, refname: cstring) -> c.int ---
	reference_ensure_log :: proc(repo: Repository, refname: cstring) -> Result ---
	reference_is_branch :: proc(ref: Reference) -> c.int ---
	reference_is_remote :: proc(ref: Reference) -> c.int ---
	reference_is_tag :: proc(ref: Reference) -> c.int ---
	reference_is_note :: proc(ref: Reference) -> c.int ---
	reference_peel :: proc(out: ^Object, ref: Reference, type: Object_Type) -> Result ---
	reference_name_is_valid :: proc(valid: ^c.int, refname: cstring) -> Result ---
	reference_shorthand :: proc(ref: Reference) -> cstring ---

	object_lookup :: proc(object: ^Object, repo: Repository, id: ^Oid, type: Object_Type) -> Result ---
	object_lookup_prefix :: proc(object_out: ^Object, repo: Repository, id: ^Oid, len: c.size_t, type: Object_Type) -> Result ---
	object_lookup_bypath :: proc(out: ^Object, treeish: Object, path: cstring, type: Object_Type) -> Result ---
	object_id :: proc(obj: Object) -> ^Oid ---
	object_short_id :: proc(out: ^Buf, obj: Object) -> Result ---
	object_type :: proc(obj: Object) -> Object_Type ---
	object_owner :: proc(obj: Object) -> Repository ---
	object_free :: proc(object: Object) ---
	object_type2string :: proc(type: Object_Type) -> cstring ---
	object_string2type :: proc(str: cstring) -> Object_Type ---
	object_typeisloose :: proc(type: Object_Type) -> c.int ---
	object_peel :: proc(peeled: ^Object, object: Object, target_type: Object_Type) -> Result ---
	object_dup :: proc(dest: ^Object, source: Object) -> Result ---

	revparse_single :: proc(object: ^Object, repo: Repository, spec: cstring) -> Result ---

	commit_lookup :: proc(commit: ^Commit, repo: Repository, id: ^Oid) -> Result ---
	commit_lookup_prefix :: proc(commit: ^Commit, repo: Repository, id: ^Oid, len: c.size_t) -> Result ---
	commit_free :: proc(commit: Commit) ---
	commit_id :: proc(commit: Commit) -> ^Oid ---
	commit_owner :: proc(commit: Commit) -> Repository ---
	commit_message_encoding :: proc(commit: Commit) -> cstring ---
	commit_message :: proc(commit: Commit) -> cstring ---
	commit_message_raw :: proc(commit: Commit) -> cstring ---
	commit_summary :: proc(commit: Commit) -> cstring ---
	commit_body :: proc(commit: Commit) -> cstring ---
	commit_time :: proc(commit: Commit) -> Time ---
	commit_time_offset :: proc(commit: Commit) -> c.int ---
	commit_committer :: proc(commit: Commit) -> ^Signature ---
	commit_author :: proc(commit: Commit) -> ^Signature ---
	commit_raw_header :: proc(commit: Commit) -> cstring ---
	commit_tree :: proc(out: ^Tree, commit: Commit) -> Result ---
	commit_tree_id :: proc(commit: Commit) -> ^Oid ---
	commit_parentcount :: proc(commit: Commit) -> c.uint ---
	commit_parent :: proc(out: ^Commit, commit: Commit, n: c.uint) -> Result ---
	commit_parent_id :: proc(commit: Commit, n: c.uint) -> ^Oid ---
	commit_nth_gen_ancestor :: proc(ancestor: ^Commit, commit: Commit, n: c.uint) -> Result ---
	commit_header_field :: proc(out: ^Buf, commit: Commit, field: cstring) -> Result ---
	commit_create :: proc(id: ^Oid, repo: Repository, update_ref: cstring, author: ^Signature, committer: ^Signature, message_encoding: cstring, message: cstring, tree: Tree, parent_count: c.size_t, parents: [^]Commit) -> Result ---
	commit_create_buffer :: proc(out: ^Buf, repo: Repository, author: ^Signature, committer: ^Signature, message_encoding: cstring, message: cstring, tree: Tree, parent_count: c.size_t, parents: [^]Commit) -> Result ---
	commit_create_with_signature :: proc(out: ^Oid, repo: Repository, commit_content: cstring, signature: cstring, signature_field: cstring) -> Result ---
	commit_amend :: proc(id: ^Oid, commit_to_amend: Commit, update_ref: cstring, author: ^Signature, committer: ^Signature, message_encoding: cstring, message: cstring, tree: Tree) -> Result ---
	commit_dup :: proc(out: ^Commit, source: Commit) -> Result ---

	tree_lookup :: proc(out: ^Tree, repo: Repository, id: ^Oid) -> Result ---
	tree_free :: proc(tree: Tree) ---
	tree_id :: proc(tree: Tree) -> ^Oid ---
	tree_owner :: proc(tree: Tree) -> Repository ---
	tree_entrycount :: proc(tree: Tree) -> c.size_t ---
	tree_entry_byname :: proc(tree: Tree, filename: cstring) -> Tree_Entry ---
	tree_entry_byindex :: proc(tree: Tree, idx: c.size_t) -> Tree_Entry ---
	tree_entry_byid :: proc(tree: Tree, id: ^Oid) -> Tree_Entry ---
	tree_entry_bypath :: proc(out: ^Tree_Entry, root: Tree, path: cstring) -> Result ---
	tree_entry_free :: proc(entry: Tree_Entry) ---
	tree_entry_name :: proc(entry: Tree_Entry) -> cstring ---
	tree_entry_id :: proc(entry: Tree_Entry) -> ^Oid ---
	tree_entry_type :: proc(entry: Tree_Entry) -> Object_Type ---
	tree_entry_filemode :: proc(entry: Tree_Entry) -> Filemode ---
	tree_entry_dup :: proc(dest: ^Tree_Entry, source: Tree_Entry) -> Result ---
	tree_entry_cmp :: proc(e1: Tree_Entry, e2: Tree_Entry) -> c.int ---
	treebuilder_new :: proc(out: ^Tree_Builder, repo: Repository, source: Tree) -> Result ---
	treebuilder_free :: proc(bld: Tree_Builder) ---
	treebuilder_clear :: proc(bld: Tree_Builder) -> Result ---
	treebuilder_entrycount :: proc(bld: Tree_Builder) -> c.size_t ---
	treebuilder_get :: proc(bld: Tree_Builder, filename: cstring) -> Tree_Entry ---
	treebuilder_insert :: proc(out: ^Tree_Entry, bld: Tree_Builder, filename: cstring, id: ^Oid, filemode: Filemode) -> Result ---
	treebuilder_remove :: proc(bld: Tree_Builder, filename: cstring) -> Result ---
	treebuilder_write :: proc(id: ^Oid, bld: Tree_Builder) -> Result ---

	blob_lookup :: proc(out: ^Blob, repo: Repository, id: ^Oid) -> Result ---
	blob_free :: proc(blob: Blob) ---
	blob_id :: proc(blob: Blob) -> ^Oid ---
	blob_owner :: proc(blob: Blob) -> Repository ---
	blob_rawcontent :: proc(blob: Blob) -> rawptr ---
	blob_rawsize :: proc(blob: Blob) -> c.size_t ---
	blob_create_from_workdir :: proc(id: ^Oid, repo: Repository, relative_path: cstring) -> Result ---
	blob_create_from_disk :: proc(id: ^Oid, repo: Repository, path: cstring) -> Result ---
	blob_create_from_buffer :: proc(id: ^Oid, repo: Repository, buffer: rawptr, len: c.size_t) -> Result ---
	blob_is_binary :: proc(blob: Blob) -> c.int ---
	blob_dup :: proc(out: ^Blob, source: Blob) -> Result ---

	tag_lookup :: proc(out: ^Tag, repo: Repository, id: ^Oid) -> Result ---
	tag_lookup_prefix :: proc(out: ^Tag, repo: Repository, id: ^Oid, len: c.size_t) -> Result ---
	tag_free :: proc(tag: Tag) ---
	tag_id :: proc(tag: Tag) -> ^Oid ---
	tag_owner :: proc(tag: Tag) -> Repository ---
	tag_target :: proc(target_out: ^Object, tag: Tag) -> Result ---
	tag_target_id :: proc(tag: Tag) -> ^Oid ---
	tag_target_type :: proc(tag: Tag) -> Object_Type ---
	tag_name :: proc(tag: Tag) -> cstring ---
	tag_tagger :: proc(tag: Tag) -> ^Signature ---
	tag_message :: proc(tag: Tag) -> cstring ---
	tag_create :: proc(oid: ^Oid, repo: Repository, tag_name: cstring, target: Object, tagger: ^Signature, message: cstring, force: c.int) -> Result ---
	tag_create_lightweight :: proc(oid: ^Oid, repo: Repository, tag_name: cstring, target: Object, force: c.int) -> Result ---
	tag_create_from_buffer :: proc(oid: ^Oid, repo: Repository, buffer: cstring, force: c.int) -> Result ---
	tag_delete :: proc(repo: Repository, tag_name: cstring) -> Result ---
	tag_list :: proc(tag_names: ^Strarray, repo: Repository) -> Result ---
	tag_list_match :: proc(tag_names: ^Strarray, pattern: cstring, repo: Repository) -> Result ---
	tag_foreach :: proc(repo: Repository, callback: Tag_Foreach_Cb, payload: rawptr) -> Result ---
	tag_peel :: proc(tag_target_out: ^Object, tag: Tag) -> Result ---
	tag_dup :: proc(out: ^Tag, source: Tag) -> Result ---
	tag_name_is_valid :: proc(valid: ^c.int, name: cstring) -> Result ---

	branch_create :: proc(out: ^Reference, repo: Repository, branch_name: cstring, target: Commit, force: c.int) -> Result ---
	branch_create_from_annotated :: proc(ref_out: ^Reference, repo: Repository, branch_name: cstring, commit: Annotated_Commit, force: c.int) -> Result ---
	branch_delete :: proc(branch: Reference) -> Result ---
	branch_iterator_new :: proc(out: ^Branch_Iterator, repo: Repository, list_flags: Branch_Type) -> Result ---
	branch_next :: proc(out: ^Reference, out_type: ^Branch_Type, iter: Branch_Iterator) -> Result ---
	branch_iterator_free :: proc(iter: Branch_Iterator) ---
	branch_move :: proc(out: ^Reference, branch: Reference, new_branch_name: cstring, force: c.int) -> Result ---
	branch_lookup :: proc(out: ^Reference, repo: Repository, branch_name: cstring, branch_type: Branch_Type) -> Result ---
	branch_name :: proc(out: ^cstring, ref: Reference) -> Result ---
	branch_upstream :: proc(out: ^Reference, branch: Reference) -> Result ---
	branch_set_upstream :: proc(branch: Reference, branch_name: cstring) -> Result ---
	branch_upstream_name :: proc(out: ^Buf, repo: Repository, refname: cstring) -> Result ---
	branch_is_head :: proc(branch: Reference) -> c.int ---
	branch_is_checked_out :: proc(branch: Reference) -> c.int ---
	branch_remote_name :: proc(out: ^Buf, repo: Repository, refname: cstring) -> Result ---
	branch_name_is_valid :: proc(valid: ^c.int, name: cstring) -> Result ---

	index_open :: proc(out: ^Index, index_path: cstring) -> Result ---
	index_new :: proc(out: ^Index) -> Result ---
	index_free :: proc(index: Index) ---
	index_owner :: proc(index: Index) -> Repository ---
	index_caps :: proc(index: Index) -> c.int ---
	index_set_caps :: proc(index: Index, caps: c.int) -> Result ---
	index_version :: proc(index: Index) -> c.uint ---
	index_set_version :: proc(index: Index, version: c.uint) -> Result ---
	index_read :: proc(index: Index, force: c.int) -> Result ---
	index_write :: proc(index: Index) -> Result ---
	index_path :: proc(index: Index) -> cstring ---
	index_checksum :: proc(index: Index) -> ^Oid ---
	index_read_tree :: proc(index: Index, tree: Tree) -> Result ---
	index_write_tree :: proc(out: ^Oid, index: Index) -> Result ---
	index_write_tree_to :: proc(out: ^Oid, index: Index, repo: Repository) -> Result ---
	index_entrycount :: proc(index: Index) -> c.size_t ---
	index_clear :: proc(index: Index) -> Result ---
	index_get_byindex :: proc(index: Index, n: c.size_t) -> ^Index_Entry ---
	index_get_bypath :: proc(index: Index, path: cstring, stage: c.int) -> ^Index_Entry ---
	index_remove :: proc(index: Index, path: cstring, stage: c.int) -> Result ---
	index_remove_directory :: proc(index: Index, dir: cstring, stage: c.int) -> Result ---
	index_add :: proc(index: Index, source_entry: ^Index_Entry) -> Result ---
	index_entry_stage :: proc(entry: ^Index_Entry) -> c.int ---
	index_entry_is_conflict :: proc(entry: ^Index_Entry) -> c.int ---
	index_add_bypath :: proc(index: Index, path: cstring) -> Result ---
	index_add_from_buffer :: proc(index: Index, entry: ^Index_Entry, buffer: rawptr, len: c.size_t) -> Result ---
	index_remove_bypath :: proc(index: Index, path: cstring) -> Result ---
	index_find :: proc(at_pos: ^c.size_t, index: Index, path: cstring) -> Result ---
	index_conflict_add :: proc(index: Index, ancestor_entry: ^Index_Entry, our_entry: ^Index_Entry, their_entry: ^Index_Entry) -> Result ---
	index_conflict_get :: proc(ancestor_out: ^^Index_Entry, our_out: ^^Index_Entry, their_out: ^^Index_Entry, index: Index, path: cstring) -> Result ---
	index_conflict_remove :: proc(index: Index, path: cstring) -> Result ---
	index_conflict_cleanup :: proc(index: Index) -> Result ---
	index_has_conflicts :: proc(index: Index) -> c.int ---
	index_conflict_iterator_new :: proc(iterator_out: ^Index_Conflict_Iterator, index: Index) -> Result ---
	index_conflict_next :: proc(ancestor_out: ^^Index_Entry, our_out: ^^Index_Entry, their_out: ^^Index_Entry, iterator: Index_Conflict_Iterator) -> Result ---
	index_conflict_iterator_free :: proc(iterator: Index_Conflict_Iterator) ---

	revwalk_new :: proc(out: ^Revwalk, repo: Repository) -> Result ---
	revwalk_reset :: proc(walker: Revwalk) -> Result ---
	revwalk_push :: proc(walk: Revwalk, id: ^Oid) -> Result ---
	revwalk_push_glob :: proc(walk: Revwalk, glob: cstring) -> Result ---
	revwalk_push_head :: proc(walk: Revwalk) -> Result ---
	revwalk_push_ref :: proc(walk: Revwalk, refname: cstring) -> Result ---
	revwalk_push_range :: proc(walk: Revwalk, range: cstring) -> Result ---
	revwalk_hide :: proc(walk: Revwalk, commit_id: ^Oid) -> Result ---
	revwalk_hide_glob :: proc(walk: Revwalk, glob: cstring) -> Result ---
	revwalk_hide_head :: proc(walk: Revwalk) -> Result ---
	revwalk_hide_ref :: proc(walk: Revwalk, refname: cstring) -> Result ---
	revwalk_next :: proc(out: ^Oid, walk: Revwalk) -> Result ---
	revwalk_sorting :: proc(walk: Revwalk, sort_mode: Sort_Flags) -> Result ---
	revwalk_simplify_first_parent :: proc(walk: Revwalk) -> Result ---
	revwalk_free :: proc(walk: Revwalk) ---
	revwalk_repository :: proc(walk: Revwalk) -> Repository ---
	revwalk_add_hide_cb :: proc(walk: Revwalk, hide_cb: Revwalk_Hide_Cb, payload: rawptr) -> Result ---

	diff_free :: proc(diff: Diff) ---
	diff_tree_to_tree :: proc(diff: ^Diff, repo: Repository, old_tree: Tree, new_tree: Tree, opts: rawptr) -> Result ---
	diff_tree_to_index :: proc(diff: ^Diff, repo: Repository, old_tree: Tree, index: Index, opts: rawptr) -> Result ---
	diff_index_to_workdir :: proc(diff: ^Diff, repo: Repository, index: Index, opts: rawptr) -> Result ---
	diff_tree_to_workdir :: proc(diff: ^Diff, repo: Repository, old_tree: Tree, opts: rawptr) -> Result ---
	diff_tree_to_workdir_with_index :: proc(diff: ^Diff, repo: Repository, old_tree: Tree, opts: rawptr) -> Result ---
	diff_merge :: proc(onto: Diff, from: Diff) -> Result ---
	diff_find_similar :: proc(diff: Diff, options: rawptr) -> Result ---
	diff_num_deltas :: proc(diff: Diff) -> c.size_t ---
	diff_get_delta :: proc(diff: Diff, idx: c.size_t) -> ^Diff_Delta ---
	diff_is_sorted_icase :: proc(diff: Diff) -> c.int ---
	diff_foreach :: proc(diff: Diff, file_cb: Diff_File_Cb, binary_cb: Diff_Binary_Cb, hunk_cb: Diff_Hunk_Cb, line_cb: Diff_Line_Cb, payload: rawptr) -> Result ---
	diff_status_char :: proc(status: Delta_Type) -> u8 ---
	diff_print :: proc(diff: Diff, format: Diff_Format, print_cb: Diff_Line_Cb, payload: rawptr) -> Result ---
	diff_to_buf :: proc(out: ^Buf, diff: Diff, format: Diff_Format) -> Result ---
	diff_get_stats :: proc(out: ^Diff_Stats, diff: Diff) -> Result ---
	diff_stats_files_changed :: proc(stats: Diff_Stats) -> c.size_t ---
	diff_stats_insertions :: proc(stats: Diff_Stats) -> c.size_t ---
	diff_stats_deletions :: proc(stats: Diff_Stats) -> c.size_t ---
	diff_stats_to_buf :: proc(out: ^Buf, stats: Diff_Stats, format: Diff_Stats_Format, width: c.size_t) -> Result ---
	diff_stats_free :: proc(stats: Diff_Stats) ---
	diff_patchid :: proc(out: ^Oid, diff: Diff, opts: rawptr) -> Result ---

	patch_from_diff :: proc(out: ^Patch, diff: Diff, idx: c.size_t) -> Result ---
	patch_free :: proc(patch: Patch) ---
	patch_get_delta :: proc(patch: Patch) -> ^Diff_Delta ---
	patch_num_hunks :: proc(patch: Patch) -> c.size_t ---
	patch_line_stats :: proc(total_context: ^c.size_t, total_additions: ^c.size_t, total_deletions: ^c.size_t, patch: Patch) -> Result ---
	patch_get_hunk :: proc(out: ^^Diff_Hunk, lines_in_hunk: ^c.size_t, patch: Patch, hunk_idx: c.size_t) -> Result ---
	patch_num_lines_in_hunk :: proc(patch: Patch, hunk_idx: c.size_t) -> c.int ---
	patch_get_line_in_hunk :: proc(out: ^^Diff_Line, patch: Patch, hunk_idx: c.size_t, line_of_hunk: c.size_t) -> Result ---
	patch_size :: proc(patch: Patch, include_context: c.int, include_hunk_headers: c.int, include_file_headers: c.int) -> c.size_t ---
	patch_to_buf :: proc(out: ^Buf, patch: Patch) -> Result ---
	patch_owner :: proc(patch: Patch) -> Repository ---

	status_list_new :: proc(out: ^Status_List, repo: Repository, opts: ^Status_Options) -> Result ---
	status_list_entrycount :: proc(statuslist: Status_List) -> c.size_t ---
	status_byindex :: proc(statuslist: Status_List, idx: c.size_t) -> ^Status_Entry ---
	status_list_free :: proc(statuslist: Status_List) ---
	status_foreach :: proc(repo: Repository, callback: Status_Cb, payload: rawptr) -> Result ---
	status_foreach_ext :: proc(repo: Repository, opts: ^Status_Options, callback: Status_Cb, payload: rawptr) -> Result ---
	status_file :: proc(status_flags: ^Status_Flags, repo: Repository, path: cstring) -> Result ---
	status_should_ignore :: proc(ignored: ^c.int, repo: Repository, path: cstring) -> Result ---

	config_open_ondisk :: proc(out: ^Config, path: cstring) -> Result ---
	config_open_default :: proc(out: ^Config) -> Result ---
	config_new :: proc(out: ^Config) -> Result ---
	config_snapshot :: proc(out: ^Config, config: Config) -> Result ---
	config_free :: proc(cfg: Config) ---
	config_get_int32 :: proc(out: ^c.int32_t, cfg: Config, name: cstring) -> Result ---
	config_get_int64 :: proc(out: ^c.int64_t, cfg: Config, name: cstring) -> Result ---
	config_get_bool :: proc(out: ^c.int, cfg: Config, name: cstring) -> Result ---
	config_get_string :: proc(out: ^cstring, cfg: Config, name: cstring) -> Result ---
	config_get_string_buf :: proc(out: ^Buf, cfg: Config, name: cstring) -> Result ---
	config_get_path :: proc(out: ^Buf, cfg: Config, name: cstring) -> Result ---
	config_set_int32 :: proc(cfg: Config, name: cstring, value: c.int32_t) -> Result ---
	config_set_int64 :: proc(cfg: Config, name: cstring, value: c.int64_t) -> Result ---
	config_set_bool :: proc(cfg: Config, name: cstring, value: c.int) -> Result ---
	config_set_string :: proc(cfg: Config, name: cstring, value: cstring) -> Result ---
	config_set_multivar :: proc(cfg: Config, name: cstring, regexp: cstring, value: cstring) -> Result ---
	config_delete_entry :: proc(cfg: Config, name: cstring) -> Result ---
	config_delete_multivar :: proc(cfg: Config, name: cstring, regexp: cstring) -> Result ---
	config_iterator_new :: proc(out: ^Config_Iterator, cfg: Config) -> Result ---
	config_iterator_glob_new :: proc(out: ^Config_Iterator, cfg: Config, regexp: cstring) -> Result ---
	config_iterator_free :: proc(iter: Config_Iterator) ---
	config_find_global :: proc(out: ^Buf) -> Result ---
	config_find_xdg :: proc(out: ^Buf) -> Result ---
	config_find_system :: proc(out: ^Buf) -> Result ---
	config_find_programdata :: proc(out: ^Buf) -> Result ---
	config_lock :: proc(tx: ^Transaction, cfg: Config) -> Result ---

	remote_create :: proc(out: ^Remote, repo: Repository, name: cstring, url: cstring) -> Result ---
	remote_create_anonymous :: proc(out: ^Remote, repo: Repository, url: cstring) -> Result ---
	remote_create_detached :: proc(out: ^Remote, url: cstring) -> Result ---
	remote_create_with_fetchspec :: proc(out: ^Remote, repo: Repository, name: cstring, url: cstring, fetch: cstring) -> Result ---
	remote_lookup :: proc(out: ^Remote, repo: Repository, name: cstring) -> Result ---
	remote_dup :: proc(dest: ^Remote, source: Remote) -> Result ---
	remote_owner :: proc(remote: Remote) -> Repository ---
	remote_name :: proc(remote: Remote) -> cstring ---
	remote_url :: proc(remote: Remote) -> cstring ---
	remote_pushurl :: proc(remote: Remote) -> cstring ---
	remote_set_url :: proc(repo: Repository, remote: cstring, url: cstring) -> Result ---
	remote_set_pushurl :: proc(repo: Repository, remote: cstring, url: cstring) -> Result ---
	remote_set_instance_url :: proc(remote: Remote, url: cstring) -> Result ---
	remote_set_instance_pushurl :: proc(remote: Remote, url: cstring) -> Result ---
	remote_add_fetch :: proc(repo: Repository, remote: cstring, refspec: cstring) -> Result ---
	remote_get_fetch_refspecs :: proc(array: ^Strarray, remote: Remote) -> Result ---
	remote_add_push :: proc(repo: Repository, remote: cstring, refspec: cstring) -> Result ---
	remote_get_push_refspecs :: proc(array: ^Strarray, remote: Remote) -> Result ---
	remote_refspec_count :: proc(remote: Remote) -> c.size_t ---
	remote_connected :: proc(remote: Remote) -> c.int ---
	remote_stop :: proc(remote: Remote) -> Result ---
	remote_disconnect :: proc(remote: Remote) -> Result ---
	remote_free :: proc(remote: Remote) ---
	remote_list :: proc(out: ^Strarray, repo: Repository) -> Result ---
	remote_prune :: proc(remote: Remote, callbacks: rawptr) -> Result ---

	clone :: proc(out: ^Repository, url: cstring, local_path: cstring, options: rawptr) -> Result ---

	checkout_head :: proc(repo: Repository, opts: ^Checkout_Options) -> Result ---
	checkout_index :: proc(repo: Repository, index: Index, opts: ^Checkout_Options) -> Result ---
	checkout_tree :: proc(repo: Repository, treeish: Object, opts: ^Checkout_Options) -> Result ---

	merge_base :: proc(out: ^Oid, repo: Repository, one: ^Oid, two: ^Oid) -> Result ---
	merge_bases :: proc(out: ^Oidarray, repo: Repository, one: ^Oid, two: ^Oid) -> Result ---
	merge_analysis :: proc(analysis_out: ^Merge_Analysis, preference_out: ^Merge_Preference, repo: Repository, their_heads: [^]Annotated_Commit, their_heads_len: c.size_t) -> Result ---
	merge_trees :: proc(out: ^Index, repo: Repository, ancestor_tree: Tree, our_tree: Tree, their_tree: Tree, opts: rawptr) -> Result ---
	merge_commits :: proc(out: ^Index, repo: Repository, our_commit: Commit, their_commit: Commit, opts: rawptr) -> Result ---
	merge :: proc(repo: Repository, their_heads: [^]Annotated_Commit, their_heads_len: c.size_t, merge_opts: rawptr, checkout_opts: ^Checkout_Options) -> Result ---

	annotated_commit_from_ref :: proc(out: ^Annotated_Commit, repo: Repository, ref: Reference) -> Result ---
	annotated_commit_from_fetchhead :: proc(out: ^Annotated_Commit, repo: Repository, branch_name: cstring, remote_url: cstring, id: ^Oid) -> Result ---
	annotated_commit_lookup :: proc(out: ^Annotated_Commit, repo: Repository, id: ^Oid) -> Result ---
	annotated_commit_from_revspec :: proc(out: ^Annotated_Commit, repo: Repository, revspec: cstring) -> Result ---
	annotated_commit_id :: proc(commit: Annotated_Commit) -> ^Oid ---
	annotated_commit_ref :: proc(commit: Annotated_Commit) -> cstring ---
	annotated_commit_free :: proc(commit: Annotated_Commit) ---

	reset :: proc(repo: Repository, target: Object, reset_type: Reset_Type, checkout_opts: ^Checkout_Options) -> Result ---
	reset_default :: proc(repo: Repository, target: Object, pathspecs: ^Strarray) -> Result ---

	revert_commit :: proc(out: ^Index, repo: Repository, revert_commit: Commit, our_commit: Commit, mainline: c.uint, merge_options: rawptr) -> Result ---
	revert :: proc(repo: Repository, commit: Commit, given_opts: rawptr) -> Result ---

	cherrypick_commit :: proc(out: ^Index, repo: Repository, cherrypick_commit: Commit, our_commit: Commit, mainline: c.uint, merge_options: rawptr) -> Result ---
	cherrypick :: proc(repo: Repository, commit: Commit, cherrypick_options: rawptr) -> Result ---

	stash_save :: proc(out: ^Oid, repo: Repository, stasher: ^Signature, message: cstring, flags: Stash_Flags) -> Result ---
	stash_apply :: proc(repo: Repository, index: c.size_t, options: rawptr) -> Result ---
	stash_foreach :: proc(repo: Repository, callback: Stash_Cb, payload: rawptr) -> Result ---
	stash_drop :: proc(repo: Repository, index: c.size_t) -> Result ---
	stash_pop :: proc(repo: Repository, index: c.size_t, options: rawptr) -> Result ---

	signature_new :: proc(out: ^^Signature, name: cstring, email: cstring, time: Time, offset: c.int) -> Result ---
	signature_now :: proc(out: ^^Signature, name: cstring, email: cstring) -> Result ---
	signature_default :: proc(out: ^^Signature, repo: Repository) -> Result ---
	signature_from_buffer :: proc(out: ^^Signature, buf: cstring) -> Result ---
	signature_dup :: proc(dest: ^^Signature, sig: ^Signature) -> Result ---
	signature_free :: proc(sig: ^Signature) ---

	oid_fromstr :: proc(out: ^Oid, str: cstring) -> Result ---
	oid_fromstrp :: proc(out: ^Oid, str: cstring) -> Result ---
	oid_fromstrn :: proc(out: ^Oid, str: cstring, length: c.size_t) -> Result ---
	oid_fromraw :: proc(out: ^Oid, raw: [^]u8) -> Result ---
	oid_fmt :: proc(out: [^]u8, id: ^Oid) -> Result ---
	oid_nfmt :: proc(out: [^]u8, n: c.size_t, id: ^Oid) -> Result ---
	oid_pathfmt :: proc(out: [^]u8, id: ^Oid) -> Result ---
	oid_tostr_s :: proc(oid: ^Oid) -> cstring ---
	oid_tostr :: proc(out: [^]u8, n: c.size_t, id: ^Oid) -> cstring ---
	oid_cpy :: proc(out: ^Oid, src: ^Oid) -> Result ---
	oid_cmp :: proc(a: ^Oid, b: ^Oid) -> c.int ---
	oid_equal :: proc(a: ^Oid, b: ^Oid) -> c.int ---
	oid_ncmp :: proc(a: ^Oid, b: ^Oid, len: c.size_t) -> c.int ---
	oid_streq :: proc(id: ^Oid, str: cstring) -> c.int ---
	oid_strcmp :: proc(id: ^Oid, str: cstring) -> c.int ---
	oid_is_zero :: proc(id: ^Oid) -> c.int ---
	oid_shorten_new :: proc(min_length: c.size_t) -> Oid_Shorten ---
	oid_shorten_add :: proc(os: Oid_Shorten, text_id: cstring) -> c.int ---
	oid_shorten_free :: proc(os: Oid_Shorten) ---

	buf_dispose :: proc(buffer: ^Buf) ---

	strarray_dispose :: proc(array: ^Strarray) ---

	blame_file :: proc(out: ^Blame, repo: Repository, path: cstring, options: rawptr) -> Result ---
	blame_free :: proc(blame: Blame) ---
	blame_hunkcount :: proc(blame: Blame) -> c.size_t ---
	blame_hunk_byindex :: proc(blame: Blame, index: c.size_t) -> ^Blame_Hunk ---
	blame_hunk_byline :: proc(blame: Blame, lineno: c.size_t) -> ^Blame_Hunk ---
	blame_buffer :: proc(out: ^Blame, reference: Blame, buffer: cstring, buffer_len: c.size_t) -> Result ---

	reflog_read :: proc(out: ^Reflog, repo: Repository, name: cstring) -> Result ---
	reflog_write :: proc(reflog: Reflog) -> Result ---
	reflog_append :: proc(reflog: Reflog, id: ^Oid, committer: ^Signature, msg: cstring) -> Result ---
	reflog_rename :: proc(repo: Repository, old_name: cstring, name: cstring) -> Result ---
	reflog_delete :: proc(repo: Repository, name: cstring) -> Result ---
	reflog_entrycount :: proc(reflog: Reflog) -> c.size_t ---
	reflog_entry_byindex :: proc(reflog: Reflog, idx: c.size_t) -> Reflog_Entry ---
	reflog_drop :: proc(reflog: Reflog, idx: c.size_t, rewrite_previous_entry: c.int) -> Result ---
	reflog_entry_id_old :: proc(entry: Reflog_Entry) -> ^Oid ---
	reflog_entry_id_new :: proc(entry: Reflog_Entry) -> ^Oid ---
	reflog_entry_committer :: proc(entry: Reflog_Entry) -> ^Signature ---
	reflog_entry_message :: proc(entry: Reflog_Entry) -> cstring ---
	reflog_free :: proc(reflog: Reflog) ---

	graph_ahead_behind :: proc(ahead: ^c.size_t, behind: ^c.size_t, repo: Repository, local: ^Oid, upstream: ^Oid) -> Result ---
	graph_descendant_of :: proc(repo: Repository, commit: ^Oid, ancestor: ^Oid) -> c.int ---
	graph_reachable_from_any :: proc(repo: Repository, commit: ^Oid, descendant_array: [^]Oid, length: c.size_t) -> c.int ---

	note_read :: proc(out: ^Note, repo: Repository, notes_ref: cstring, oid: ^Oid) -> Result ---
	note_commit_read :: proc(out: ^Note, repo: Repository, notes_commit: Commit, oid: ^Oid) -> Result ---
	note_message :: proc(note: Note) -> cstring ---
	note_id :: proc(note: Note) -> ^Oid ---
	note_author :: proc(note: Note) -> ^Signature ---
	note_committer :: proc(note: Note) -> ^Signature ---
	note_create :: proc(out: ^Oid, repo: Repository, notes_ref: cstring, author: ^Signature, committer: ^Signature, oid: ^Oid, note: cstring, force: c.int) -> Result ---
	note_remove :: proc(repo: Repository, notes_ref: cstring, author: ^Signature, committer: ^Signature, oid: ^Oid) -> Result ---
	note_free :: proc(note: Note) ---
	note_iterator_new :: proc(out: ^Note_Iterator, repo: Repository, notes_ref: cstring) -> Result ---
	note_next :: proc(note_id: ^Oid, annotated_id: ^Oid, it: Note_Iterator) -> Result ---
	note_iterator_free :: proc(it: Note_Iterator) ---
	note_foreach :: proc(repo: Repository, notes_ref: cstring, note_cb: Note_Foreach_Cb, payload: rawptr) -> Result ---

	submodule_lookup :: proc(out: ^Submodule, repo: Repository, name: cstring) -> Result ---
	submodule_free :: proc(submodule: Submodule) ---
	submodule_name :: proc(submodule: Submodule) -> cstring ---
	submodule_path :: proc(submodule: Submodule) -> cstring ---
	submodule_url :: proc(submodule: Submodule) -> cstring ---
	submodule_branch :: proc(submodule: Submodule) -> cstring ---
	submodule_head_id :: proc(submodule: Submodule) -> ^Oid ---
	submodule_index_id :: proc(submodule: Submodule) -> ^Oid ---
	submodule_wd_id :: proc(submodule: Submodule) -> ^Oid ---
	submodule_ignore :: proc(submodule: Submodule) -> Submodule_Ignore ---
	submodule_update_strategy :: proc(submodule: Submodule) -> Submodule_Update ---
	submodule_init :: proc(submodule: Submodule, overwrite: c.int) -> Result ---
	submodule_sync :: proc(submodule: Submodule) -> Result ---
	submodule_open :: proc(repo: ^Repository, submodule: Submodule) -> Result ---
	submodule_reload :: proc(submodule: Submodule, force: c.int) -> Result ---

	worktree_list :: proc(out: ^Strarray, repo: Repository) -> Result ---
	worktree_lookup :: proc(out: ^Worktree, repo: Repository, name: cstring) -> Result ---
	worktree_open_from_repository :: proc(out: ^Worktree, repo: Repository) -> Result ---
	worktree_free :: proc(wt: Worktree) ---
	worktree_validate :: proc(wt: Worktree) -> Result ---
	worktree_name :: proc(wt: Worktree) -> cstring ---
	worktree_path :: proc(wt: Worktree) -> cstring ---
	worktree_is_locked :: proc(reason: ^Buf, wt: Worktree) -> c.int ---
	worktree_lock :: proc(wt: Worktree, reason: cstring) -> Result ---
	worktree_unlock :: proc(wt: Worktree) -> Result ---
	worktree_is_prunable :: proc(wt: Worktree, opts: rawptr) -> c.int ---
	worktree_prune :: proc(wt: Worktree, opts: rawptr) -> Result ---

	mailmap_from_repository :: proc(out: ^Mailmap, repo: Repository) -> Result ---
	mailmap_from_buffer :: proc(out: ^Mailmap, buf: cstring, len: c.size_t) -> Result ---
	mailmap_free :: proc(mm: Mailmap) ---
	mailmap_resolve :: proc(real_name: ^cstring, real_email: ^cstring, mm: Mailmap, name: cstring, email: cstring) -> Result ---
	mailmap_resolve_signature :: proc(out: ^^Signature, mm: Mailmap, sig: ^Signature) -> Result ---
	mailmap_add_entry :: proc(mm: Mailmap, real_name: cstring, real_email: cstring, replace_name: cstring, replace_email: cstring) -> Result ---

	odb_new :: proc(out: ^Odb) -> Result ---
	odb_open :: proc(out: ^Odb, objects_dir: cstring) -> Result ---
	odb_free :: proc(db: Odb) ---
	odb_read :: proc(out: ^Odb_Object, db: Odb, id: ^Oid) -> Result ---
	odb_read_prefix :: proc(out: ^Odb_Object, db: Odb, short_id: ^Oid, len: c.size_t) -> Result ---
	odb_read_header :: proc(len_out: ^c.size_t, type_out: ^Object_Type, db: Odb, id: ^Oid) -> Result ---
	odb_exists :: proc(db: Odb, id: ^Oid) -> c.int ---
	odb_exists_prefix :: proc(out: ^Oid, db: Odb, short_id: ^Oid, len: c.size_t) -> Result ---
	odb_write :: proc(out: ^Oid, odb: Odb, data: rawptr, len: c.size_t, type: Object_Type) -> Result ---
	odb_object_free :: proc(object: Odb_Object) ---
	odb_object_id :: proc(object: Odb_Object) -> ^Oid ---
	odb_object_data :: proc(object: Odb_Object) -> rawptr ---
	odb_object_size :: proc(object: Odb_Object) -> c.size_t ---
	odb_object_type :: proc(object: Odb_Object) -> Object_Type ---
	odb_object_dup :: proc(dest: ^Odb_Object, source: Odb_Object) -> Result ---
}