Skip to main content

libgit2_sys/
lib.rs

1#![doc(html_root_url = "https://docs.rs/libgit2-sys/0.18")]
2#![allow(non_camel_case_types, unused_extern_crates)]
3
4// This is required to link libz when libssh2-sys is not included.
5extern crate libz_sys as libz;
6
7use libc::{c_char, c_int, c_uchar, c_uint, c_ushort, c_void, size_t};
8#[cfg(feature = "ssh")]
9use libssh2_sys as libssh2;
10use std::ffi::CStr;
11
12#[cfg(not(feature = "unstable-sha256"))]
13#[deprecated(note = "use `GIT_OID_SHA1_SIZE` instead")]
14pub const GIT_OID_RAWSZ: usize = GIT_OID_SHA1_SIZE;
15#[cfg(not(feature = "unstable-sha256"))]
16#[deprecated(note = "use `GIT_OID_SHA1_HEXSIZE` instead")]
17pub const GIT_OID_HEXSZ: usize = GIT_OID_SHA1_HEXSIZE;
18pub const GIT_OID_SHA1_SIZE: usize = 20;
19pub const GIT_OID_SHA1_HEXSIZE: usize = GIT_OID_SHA1_SIZE * 2;
20#[cfg(feature = "unstable-sha256")]
21pub const GIT_OID_SHA256_SIZE: usize = 32;
22#[cfg(feature = "unstable-sha256")]
23pub const GIT_OID_SHA256_HEXSIZE: usize = GIT_OID_SHA256_SIZE * 2;
24#[cfg(not(feature = "unstable-sha256"))]
25pub const GIT_OID_MAX_SIZE: usize = GIT_OID_SHA1_SIZE;
26#[cfg(feature = "unstable-sha256")]
27pub const GIT_OID_MAX_SIZE: usize = GIT_OID_SHA256_SIZE;
28#[cfg(not(feature = "unstable-sha256"))]
29pub const GIT_OID_MAX_HEXSIZE: usize = GIT_OID_SHA1_HEXSIZE;
30#[cfg(feature = "unstable-sha256")]
31pub const GIT_OID_MAX_HEXSIZE: usize = GIT_OID_SHA256_HEXSIZE;
32
33pub const GIT_CLONE_OPTIONS_VERSION: c_uint = 1;
34pub const GIT_STASH_APPLY_OPTIONS_VERSION: c_uint = 1;
35pub const GIT_CHECKOUT_OPTIONS_VERSION: c_uint = 1;
36pub const GIT_MERGE_OPTIONS_VERSION: c_uint = 1;
37pub const GIT_REMOTE_CALLBACKS_VERSION: c_uint = 1;
38pub const GIT_STATUS_OPTIONS_VERSION: c_uint = 1;
39pub const GIT_BLAME_OPTIONS_VERSION: c_uint = 1;
40pub const GIT_PROXY_OPTIONS_VERSION: c_uint = 1;
41pub const GIT_SUBMODULE_UPDATE_OPTIONS_VERSION: c_uint = 1;
42pub const GIT_ODB_BACKEND_VERSION: c_uint = 1;
43pub const GIT_REFDB_BACKEND_VERSION: c_uint = 1;
44pub const GIT_CHERRYPICK_OPTIONS_VERSION: c_uint = 1;
45pub const GIT_APPLY_OPTIONS_VERSION: c_uint = 1;
46pub const GIT_REVERT_OPTIONS_VERSION: c_uint = 1;
47pub const GIT_INDEXER_OPTIONS_VERSION: c_uint = 1;
48
49macro_rules! git_enum {
50    (pub enum $name:ident { $($variants:tt)* }) => {
51        #[cfg(target_env = "msvc")]
52        pub type $name = i32;
53        #[cfg(not(target_env = "msvc"))]
54        pub type $name = u32;
55        git_enum!(gen, $name, 0, $($variants)*);
56    };
57    (pub enum $name:ident: $t:ty { $($variants:tt)* }) => {
58        pub type $name = $t;
59        git_enum!(gen, $name, 0, $($variants)*);
60    };
61    (gen, $name:ident, $val:expr, #[$attr:meta] $variant:ident, $($rest:tt)*) => {
62        #[$attr]
63        pub const $variant: $name = $val;
64        git_enum!(gen, $name, $val+1, $($rest)*);
65    };
66    (gen, $name:ident, $val:expr, #[$attr:meta] $variant:ident = $e:expr, $($rest:tt)*) => {
67        #[$attr]
68        pub const $variant: $name = $e;
69        git_enum!(gen, $name, $e+1, $($rest)*);
70    };
71    (gen, $name:ident, $val:expr, $variant:ident, $($rest:tt)*) => {
72        pub const $variant: $name = $val;
73        git_enum!(gen, $name, $val+1, $($rest)*);
74    };
75    (gen, $name:ident, $val:expr, $variant:ident = $e:expr, $($rest:tt)*) => {
76        pub const $variant: $name = $e;
77        git_enum!(gen, $name, $e+1, $($rest)*);
78    };
79    (gen, $name:ident, $val:expr, ) => {}
80}
81
82pub enum git_blob {}
83pub enum git_branch_iterator {}
84pub enum git_blame {}
85pub enum git_commit {}
86pub enum git_config {}
87
88#[repr(C)]
89pub struct git_config_backend_entry {
90    pub entry: git_config_entry,
91    pub free: Option<extern "C" fn(*mut git_config_backend_entry)>,
92}
93
94#[repr(C)]
95pub struct git_config_iterator {
96    pub backend: *mut git_config_backend,
97    pub flags: c_uint,
98    pub next: Option<
99        extern "C" fn(*mut *mut git_config_backend_entry, *mut git_config_iterator) -> c_int,
100    >,
101    pub free: Option<extern "C" fn(*mut git_config_iterator)>,
102}
103
104#[repr(C)]
105pub struct git_config_backend {
106    pub version: c_uint,
107    pub readonly: c_int,
108    pub cfg: *mut git_config,
109    pub open: Option<
110        extern "C" fn(*mut git_config_backend, git_config_level_t, *const git_repository) -> c_int,
111    >,
112    pub get: Option<
113        extern "C" fn(
114            *mut git_config_backend,
115            *const c_char,
116            *mut *mut git_config_backend_entry,
117        ) -> c_int,
118    >,
119    pub set: Option<extern "C" fn(*mut git_config_backend, *const c_char, *const c_char) -> c_int>,
120    pub set_multivar: Option<
121        extern "C" fn(
122            *mut git_config_backend,
123            *const c_char,
124            *const c_char,
125            *const c_char,
126        ) -> c_int,
127    >,
128    pub del: Option<extern "C" fn(*mut git_config_backend, *const c_char) -> c_int>,
129    pub del_multivar:
130        Option<extern "C" fn(*mut git_config_backend, *const c_char, *const c_char) -> c_int>,
131    pub iterator:
132        Option<extern "C" fn(*mut *mut git_config_iterator, *mut git_config_backend) -> c_int>,
133    pub snapshot:
134        Option<extern "C" fn(*mut *mut git_config_backend, *mut git_config_backend) -> c_int>,
135    pub lock: Option<extern "C" fn(*mut git_config_backend) -> c_int>,
136    pub unlock: Option<extern "C" fn(*mut git_config_backend, c_int) -> c_int>,
137    pub free: Option<extern "C" fn(*mut git_config_backend)>,
138}
139
140pub const GIT_CONFIG_BACKEND_VERSION: c_uint = 1;
141
142pub enum git_index {}
143pub enum git_index_conflict_iterator {}
144pub enum git_object {}
145pub enum git_reference {}
146
147#[repr(C)]
148pub struct git_reference_iterator {
149    pub db: *mut git_refdb,
150    pub next: Option<extern "C" fn(*mut *mut git_reference, *mut git_reference_iterator) -> c_int>,
151    pub next_name: Option<extern "C" fn(*mut *const c_char, *mut git_reference_iterator) -> c_int>,
152    pub free: Option<extern "C" fn(*mut git_reference_iterator)>,
153}
154
155pub enum git_annotated_commit {}
156pub enum git_refdb {}
157pub enum git_refspec {}
158pub enum git_remote {}
159pub enum git_repository {}
160pub enum git_revwalk {}
161pub enum git_submodule {}
162pub enum git_tag {}
163pub enum git_tree {}
164pub enum git_tree_entry {}
165pub enum git_treebuilder {}
166pub enum git_push {}
167pub enum git_note {}
168pub enum git_note_iterator {}
169pub enum git_status_list {}
170pub enum git_pathspec {}
171pub enum git_pathspec_match_list {}
172pub enum git_diff {}
173pub enum git_diff_stats {}
174pub enum git_patch {}
175pub enum git_rebase {}
176pub enum git_reflog {}
177pub enum git_reflog_entry {}
178pub enum git_describe_result {}
179pub enum git_packbuilder {}
180pub enum git_odb {}
181
182#[repr(C)]
183pub struct git_odb_stream {
184    pub backend: *mut git_odb_backend,
185    pub mode: c_uint,
186    pub hash_ctx: *mut c_void,
187    #[cfg(feature = "unstable-sha256")]
188    pub oid_type: git_oid_t,
189    pub declared_size: git_object_size_t,
190    pub received_bytes: git_object_size_t,
191    pub read: Option<extern "C" fn(*mut git_odb_stream, *mut c_char, size_t) -> c_int>,
192    pub write: Option<extern "C" fn(*mut git_odb_stream, *const c_char, size_t) -> c_int>,
193    pub finalize_write: Option<extern "C" fn(*mut git_odb_stream, *const git_oid) -> c_int>,
194    pub free: Option<extern "C" fn(*mut git_odb_stream)>,
195}
196
197git_enum! {
198    pub enum git_odb_stream_t {
199        GIT_STREAM_RDONLY = 2,
200        GIT_STREAM_WRONLY = 4,
201        GIT_STREAM_RW = 6,
202    }
203}
204
205pub enum git_odb_object {}
206pub enum git_worktree {}
207pub enum git_transaction {}
208pub enum git_mailmap {}
209pub enum git_indexer {}
210
211#[repr(C)]
212pub struct git_revspec {
213    pub from: *mut git_object,
214    pub to: *mut git_object,
215    pub flags: c_uint,
216}
217
218#[repr(C)]
219pub struct git_error {
220    pub message: *mut c_char,
221    pub klass: c_int,
222}
223
224#[repr(C)]
225#[derive(Copy, Clone)]
226pub struct git_oid {
227    #[cfg(feature = "unstable-sha256")]
228    pub kind: c_uchar,
229    pub id: [u8; GIT_OID_MAX_SIZE],
230}
231
232#[repr(C)]
233#[derive(Copy)]
234pub struct git_strarray {
235    pub strings: *mut *mut c_char,
236    pub count: size_t,
237}
238impl Clone for git_strarray {
239    fn clone(&self) -> git_strarray {
240        *self
241    }
242}
243
244#[repr(C)]
245#[derive(Copy)]
246pub struct git_oidarray {
247    pub ids: *mut git_oid,
248    pub count: size_t,
249}
250impl Clone for git_oidarray {
251    fn clone(&self) -> git_oidarray {
252        *self
253    }
254}
255
256#[repr(C)]
257pub struct git_signature {
258    pub name: *mut c_char,
259    pub email: *mut c_char,
260    pub when: git_time,
261}
262
263#[repr(C)]
264#[derive(Copy, Clone, Debug, Eq, PartialEq)]
265pub struct git_time {
266    pub time: git_time_t,
267    pub offset: c_int,
268    pub sign: c_char,
269}
270
271pub type git_off_t = i64;
272pub type git_time_t = i64;
273pub type git_object_size_t = u64;
274
275git_enum! {
276    pub enum git_revparse_mode_t {
277        GIT_REVPARSE_SINGLE = 1 << 0,
278        GIT_REVPARSE_RANGE = 1 << 1,
279        GIT_REVPARSE_MERGE_BASE = 1 << 2,
280    }
281}
282
283git_enum! {
284    pub enum git_error_code: c_int {
285        GIT_OK = 0,
286
287        GIT_ERROR = -1,
288        GIT_ENOTFOUND = -3,
289        GIT_EEXISTS = -4,
290        GIT_EAMBIGUOUS = -5,
291        GIT_EBUFS = -6,
292        GIT_EUSER = -7,
293        GIT_EBAREREPO = -8,
294        GIT_EUNBORNBRANCH = -9,
295        GIT_EUNMERGED = -10,
296        GIT_ENONFASTFORWARD = -11,
297        GIT_EINVALIDSPEC = -12,
298        GIT_ECONFLICT = -13,
299        GIT_ELOCKED = -14,
300        GIT_EMODIFIED = -15,
301        GIT_EAUTH = -16,
302        GIT_ECERTIFICATE = -17,
303        GIT_EAPPLIED = -18,
304        GIT_EPEEL = -19,
305        GIT_EEOF = -20,
306        GIT_EINVALID = -21,
307        GIT_EUNCOMMITTED = -22,
308        GIT_EDIRECTORY = -23,
309        GIT_EMERGECONFLICT = -24,
310        GIT_PASSTHROUGH = -30,
311        GIT_ITEROVER = -31,
312        GIT_RETRY = -32,
313        GIT_EMISMATCH = -33,
314        GIT_EINDEXDIRTY = -34,
315        GIT_EAPPLYFAIL = -35,
316        GIT_EOWNER = -36,
317        GIT_TIMEOUT = -37,
318        GIT_EUNCHANGED = -38,
319        GIT_ENOTSUPPORTED = -39,
320        GIT_EREADONLY = -40,
321    }
322}
323
324git_enum! {
325    pub enum git_error_t {
326        GIT_ERROR_NONE = 0,
327        GIT_ERROR_NOMEMORY,
328        GIT_ERROR_OS,
329        GIT_ERROR_INVALID,
330        GIT_ERROR_REFERENCE,
331        GIT_ERROR_ZLIB,
332        GIT_ERROR_REPOSITORY,
333        GIT_ERROR_CONFIG,
334        GIT_ERROR_REGEX,
335        GIT_ERROR_ODB,
336        GIT_ERROR_INDEX,
337        GIT_ERROR_OBJECT,
338        GIT_ERROR_NET,
339        GIT_ERROR_TAG,
340        GIT_ERROR_TREE,
341        GIT_ERROR_INDEXER,
342        GIT_ERROR_SSL,
343        GIT_ERROR_SUBMODULE,
344        GIT_ERROR_THREAD,
345        GIT_ERROR_STASH,
346        GIT_ERROR_CHECKOUT,
347        GIT_ERROR_FETCHHEAD,
348        GIT_ERROR_MERGE,
349        GIT_ERROR_SSH,
350        GIT_ERROR_FILTER,
351        GIT_ERROR_REVERT,
352        GIT_ERROR_CALLBACK,
353        GIT_ERROR_CHERRYPICK,
354        GIT_ERROR_DESCRIBE,
355        GIT_ERROR_REBASE,
356        GIT_ERROR_FILESYSTEM,
357        GIT_ERROR_PATCH,
358        GIT_ERROR_WORKTREE,
359        GIT_ERROR_SHA1,
360        GIT_ERROR_HTTP,
361    }
362}
363
364git_enum! {
365    pub enum git_repository_state_t {
366        GIT_REPOSITORY_STATE_NONE,
367        GIT_REPOSITORY_STATE_MERGE,
368        GIT_REPOSITORY_STATE_REVERT,
369        GIT_REPOSITORY_STATE_REVERT_SEQUENCE,
370        GIT_REPOSITORY_STATE_CHERRYPICK,
371        GIT_REPOSITORY_STATE_CHERRYPICK_SEQUENCE,
372        GIT_REPOSITORY_STATE_BISECT,
373        GIT_REPOSITORY_STATE_REBASE,
374        GIT_REPOSITORY_STATE_REBASE_INTERACTIVE,
375        GIT_REPOSITORY_STATE_REBASE_MERGE,
376        GIT_REPOSITORY_STATE_APPLY_MAILBOX,
377        GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE,
378    }
379}
380
381git_enum! {
382    pub enum git_direction {
383        GIT_DIRECTION_FETCH,
384        GIT_DIRECTION_PUSH,
385    }
386}
387
388#[repr(C)]
389pub struct git_clone_options {
390    pub version: c_uint,
391    pub checkout_opts: git_checkout_options,
392    pub fetch_opts: git_fetch_options,
393    pub bare: c_int,
394    pub local: git_clone_local_t,
395    pub checkout_branch: *const c_char,
396    pub repository_cb: git_repository_create_cb,
397    pub repository_cb_payload: *mut c_void,
398    pub remote_cb: git_remote_create_cb,
399    pub remote_cb_payload: *mut c_void,
400}
401
402git_enum! {
403    pub enum git_clone_local_t {
404        GIT_CLONE_LOCAL_AUTO,
405        GIT_CLONE_LOCAL,
406        GIT_CLONE_NO_LOCAL,
407        GIT_CLONE_LOCAL_NO_LINKS,
408    }
409}
410
411#[repr(C)]
412pub struct git_checkout_options {
413    pub version: c_uint,
414    pub checkout_strategy: c_uint,
415    pub disable_filters: c_int,
416    pub dir_mode: c_uint,
417    pub file_mode: c_uint,
418    pub file_open_flags: c_int,
419    pub notify_flags: c_uint,
420    pub notify_cb: git_checkout_notify_cb,
421    pub notify_payload: *mut c_void,
422    pub progress_cb: git_checkout_progress_cb,
423    pub progress_payload: *mut c_void,
424    pub paths: git_strarray,
425    pub baseline: *mut git_tree,
426    pub baseline_index: *mut git_index,
427    pub target_directory: *const c_char,
428    pub ancestor_label: *const c_char,
429    pub our_label: *const c_char,
430    pub their_label: *const c_char,
431    pub perfdata_cb: git_checkout_perfdata_cb,
432    pub perfdata_payload: *mut c_void,
433}
434
435pub type git_checkout_notify_cb = Option<
436    extern "C" fn(
437        git_checkout_notify_t,
438        *const c_char,
439        *const git_diff_file,
440        *const git_diff_file,
441        *const git_diff_file,
442        *mut c_void,
443    ) -> c_int,
444>;
445pub type git_checkout_progress_cb =
446    Option<extern "C" fn(*const c_char, size_t, size_t, *mut c_void)>;
447
448pub type git_checkout_perfdata_cb =
449    Option<extern "C" fn(*const git_checkout_perfdata, *mut c_void)>;
450
451#[repr(C)]
452pub struct git_checkout_perfdata {
453    pub mkdir_calls: size_t,
454    pub stat_calls: size_t,
455    pub chmod_calls: size_t,
456}
457
458#[repr(C)]
459#[derive(Copy, Clone, Default)]
460pub struct git_indexer_progress {
461    pub total_objects: c_uint,
462    pub indexed_objects: c_uint,
463    pub received_objects: c_uint,
464    pub local_objects: c_uint,
465    pub total_deltas: c_uint,
466    pub indexed_deltas: c_uint,
467    pub received_bytes: size_t,
468}
469
470pub type git_indexer_progress_cb =
471    Option<extern "C" fn(*const git_indexer_progress, *mut c_void) -> c_int>;
472
473#[deprecated(
474    since = "0.10.0",
475    note = "renamed to `git_indexer_progress` to match upstream"
476)]
477pub type git_transfer_progress = git_indexer_progress;
478
479#[repr(C)]
480pub struct git_indexer_options {
481    pub version: c_uint,
482    #[cfg(feature = "unstable-sha256")]
483    pub mode: c_uint,
484    #[cfg(feature = "unstable-sha256")]
485    pub oid_type: git_oid_t,
486    #[cfg(feature = "unstable-sha256")]
487    pub odb: *mut git_odb,
488    pub progress_cb: git_indexer_progress_cb,
489    pub progress_cb_payload: *mut c_void,
490    pub verify: c_uchar,
491}
492
493pub type git_remote_ready_cb = Option<extern "C" fn(*mut git_remote, c_int, *mut c_void) -> c_int>;
494
495git_enum! {
496    pub enum git_remote_update_flags {
497        GIT_REMOTE_UPDATE_FETCHHEAD = 1 << 0,
498        GIT_REMOTE_UPDATE_REPORT_UNCHANGED = 1 << 1,
499    }
500}
501
502#[repr(C)]
503pub struct git_remote_callbacks {
504    pub version: c_uint,
505    pub sideband_progress: git_transport_message_cb,
506    pub completion: Option<extern "C" fn(git_remote_completion_type, *mut c_void) -> c_int>,
507    pub credentials: git_cred_acquire_cb,
508    pub certificate_check: git_transport_certificate_check_cb,
509    pub transfer_progress: git_indexer_progress_cb,
510    pub update_tips:
511        Option<extern "C" fn(*const c_char, *const git_oid, *const git_oid, *mut c_void) -> c_int>,
512    pub pack_progress: git_packbuilder_progress,
513    pub push_transfer_progress: git_push_transfer_progress,
514    pub push_update_reference: git_push_update_reference_cb,
515    pub push_negotiation: git_push_negotiation,
516    pub transport: git_transport_cb,
517    pub remote_ready: git_remote_ready_cb,
518    pub payload: *mut c_void,
519    pub resolve_url: git_url_resolve_cb,
520    pub update_refs: Option<
521        extern "C" fn(
522            *const c_char,
523            *const git_oid,
524            *const git_oid,
525            *mut git_refspec,
526            *mut c_void,
527        ) -> c_int,
528    >,
529}
530
531#[repr(C)]
532pub struct git_fetch_options {
533    pub version: c_int,
534    pub callbacks: git_remote_callbacks,
535    pub prune: git_fetch_prune_t,
536    pub update_fetchhead: c_uint,
537    pub download_tags: git_remote_autotag_option_t,
538    pub proxy_opts: git_proxy_options,
539    pub depth: c_int,
540    pub follow_redirects: git_remote_redirect_t,
541    pub custom_headers: git_strarray,
542}
543
544#[repr(C)]
545pub struct git_fetch_negotiation {
546    refs: *const *const git_remote_head,
547    refs_len: size_t,
548    shallow_roots: *mut git_oid,
549    shallow_roots_len: size_t,
550    depth: c_int,
551}
552
553git_enum! {
554    pub enum git_remote_autotag_option_t {
555        GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED,
556        GIT_REMOTE_DOWNLOAD_TAGS_AUTO,
557        GIT_REMOTE_DOWNLOAD_TAGS_NONE,
558        GIT_REMOTE_DOWNLOAD_TAGS_ALL,
559    }
560}
561
562git_enum! {
563    pub enum git_fetch_prune_t {
564        GIT_FETCH_PRUNE_UNSPECIFIED,
565        GIT_FETCH_PRUNE,
566        GIT_FETCH_NO_PRUNE,
567    }
568}
569
570git_enum! {
571    pub enum git_remote_completion_type {
572        GIT_REMOTE_COMPLETION_DOWNLOAD,
573        GIT_REMOTE_COMPLETION_INDEXING,
574        GIT_REMOTE_COMPLETION_ERROR,
575    }
576}
577
578pub type git_transport_message_cb =
579    Option<extern "C" fn(*const c_char, c_int, *mut c_void) -> c_int>;
580pub type git_cred_acquire_cb = Option<
581    extern "C" fn(*mut *mut git_cred, *const c_char, *const c_char, c_uint, *mut c_void) -> c_int,
582>;
583pub type git_transfer_progress_cb =
584    Option<extern "C" fn(*const git_indexer_progress, *mut c_void) -> c_int>;
585pub type git_packbuilder_progress =
586    Option<extern "C" fn(git_packbuilder_stage_t, c_uint, c_uint, *mut c_void) -> c_int>;
587pub type git_push_transfer_progress =
588    Option<extern "C" fn(c_uint, c_uint, size_t, *mut c_void) -> c_int>;
589pub type git_transport_certificate_check_cb =
590    Option<extern "C" fn(*mut git_cert, c_int, *const c_char, *mut c_void) -> c_int>;
591pub type git_push_negotiation =
592    Option<extern "C" fn(*mut *const git_push_update, size_t, *mut c_void) -> c_int>;
593
594pub type git_push_update_reference_cb =
595    Option<extern "C" fn(*const c_char, *const c_char, *mut c_void) -> c_int>;
596pub type git_url_resolve_cb =
597    Option<extern "C" fn(*mut git_buf, *const c_char, c_int, *mut c_void) -> c_int>;
598
599#[repr(C)]
600pub struct git_push_update {
601    pub src_refname: *mut c_char,
602    pub dst_refname: *mut c_char,
603    pub src: git_oid,
604    pub dst: git_oid,
605}
606
607git_enum! {
608    pub enum git_cert_t {
609        GIT_CERT_NONE,
610        GIT_CERT_X509,
611        GIT_CERT_HOSTKEY_LIBSSH2,
612        GIT_CERT_STRARRAY,
613    }
614}
615
616#[repr(C)]
617pub struct git_cert {
618    pub cert_type: git_cert_t,
619}
620
621#[repr(C)]
622pub struct git_cert_hostkey {
623    pub parent: git_cert,
624    pub kind: git_cert_ssh_t,
625    pub hash_md5: [u8; 16],
626    pub hash_sha1: [u8; 20],
627    pub hash_sha256: [u8; 32],
628    pub raw_type: git_cert_ssh_raw_type_t,
629    pub hostkey: *const c_char,
630    pub hostkey_len: size_t,
631}
632
633#[repr(C)]
634pub struct git_cert_x509 {
635    pub parent: git_cert,
636    pub data: *mut c_void,
637    pub len: size_t,
638}
639
640git_enum! {
641    pub enum git_cert_ssh_t {
642        GIT_CERT_SSH_MD5 = 1 << 0,
643        GIT_CERT_SSH_SHA1 = 1 << 1,
644        GIT_CERT_SSH_SHA256 = 1 << 2,
645        GIT_CERT_SSH_RAW = 1 << 3,
646    }
647}
648
649git_enum! {
650    pub enum git_cert_ssh_raw_type_t {
651        GIT_CERT_SSH_RAW_TYPE_UNKNOWN = 0,
652        GIT_CERT_SSH_RAW_TYPE_RSA = 1,
653        GIT_CERT_SSH_RAW_TYPE_DSS = 2,
654        GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_256 = 3,
655        GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_384 = 4,
656        GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_521 = 5,
657        GIT_CERT_SSH_RAW_TYPE_KEY_ED25519 = 6,
658    }
659}
660
661git_enum! {
662    pub enum git_diff_flag_t {
663        GIT_DIFF_FLAG_BINARY     = 1 << 0,
664        GIT_DIFF_FLAG_NOT_BINARY = 1 << 1,
665        GIT_DIFF_FLAG_VALID_ID   = 1 << 2,
666        GIT_DIFF_FLAG_EXISTS     = 1 << 3,
667    }
668}
669
670#[repr(C)]
671pub struct git_diff_file {
672    pub id: git_oid,
673    pub path: *const c_char,
674    pub size: git_object_size_t,
675    pub flags: u32,
676    pub mode: u16,
677    pub id_abbrev: u16,
678}
679
680pub type git_repository_create_cb =
681    Option<extern "C" fn(*mut *mut git_repository, *const c_char, c_int, *mut c_void) -> c_int>;
682pub type git_remote_create_cb = Option<
683    extern "C" fn(
684        *mut *mut git_remote,
685        *mut git_repository,
686        *const c_char,
687        *const c_char,
688        *mut c_void,
689    ) -> c_int,
690>;
691
692git_enum! {
693    pub enum git_checkout_notify_t {
694        GIT_CHECKOUT_NOTIFY_NONE = 0,
695        GIT_CHECKOUT_NOTIFY_CONFLICT = 1 << 0,
696        GIT_CHECKOUT_NOTIFY_DIRTY = 1 << 1,
697        GIT_CHECKOUT_NOTIFY_UPDATED = 1 << 2,
698        GIT_CHECKOUT_NOTIFY_UNTRACKED = 1 << 3,
699        GIT_CHECKOUT_NOTIFY_IGNORED = 1 << 4,
700
701        GIT_CHECKOUT_NOTIFY_ALL = 0x0FFFF,
702    }
703}
704
705git_enum! {
706    pub enum git_status_t {
707        GIT_STATUS_CURRENT = 0,
708
709        GIT_STATUS_INDEX_NEW = 1 << 0,
710        GIT_STATUS_INDEX_MODIFIED = 1 << 1,
711        GIT_STATUS_INDEX_DELETED = 1 << 2,
712        GIT_STATUS_INDEX_RENAMED = 1 << 3,
713        GIT_STATUS_INDEX_TYPECHANGE = 1 << 4,
714
715        GIT_STATUS_WT_NEW = 1 << 7,
716        GIT_STATUS_WT_MODIFIED = 1 << 8,
717        GIT_STATUS_WT_DELETED = 1 << 9,
718        GIT_STATUS_WT_TYPECHANGE = 1 << 10,
719        GIT_STATUS_WT_RENAMED = 1 << 11,
720        GIT_STATUS_WT_UNREADABLE = 1 << 12,
721
722        GIT_STATUS_IGNORED = 1 << 14,
723        GIT_STATUS_CONFLICTED = 1 << 15,
724    }
725}
726
727git_enum! {
728    pub enum git_status_opt_t {
729        GIT_STATUS_OPT_INCLUDE_UNTRACKED                = 1 << 0,
730        GIT_STATUS_OPT_INCLUDE_IGNORED                  = 1 << 1,
731        GIT_STATUS_OPT_INCLUDE_UNMODIFIED               = 1 << 2,
732        GIT_STATUS_OPT_EXCLUDE_SUBMODULES               = 1 << 3,
733        GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS           = 1 << 4,
734        GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH           = 1 << 5,
735        GIT_STATUS_OPT_RECURSE_IGNORED_DIRS             = 1 << 6,
736        GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX            = 1 << 7,
737        GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR         = 1 << 8,
738        GIT_STATUS_OPT_SORT_CASE_SENSITIVELY            = 1 << 9,
739        GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY          = 1 << 10,
740
741        GIT_STATUS_OPT_RENAMES_FROM_REWRITES            = 1 << 11,
742        GIT_STATUS_OPT_NO_REFRESH                       = 1 << 12,
743        GIT_STATUS_OPT_UPDATE_INDEX                     = 1 << 13,
744        GIT_STATUS_OPT_INCLUDE_UNREADABLE               = 1 << 14,
745        GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED  = 1 << 15,
746    }
747}
748
749git_enum! {
750    pub enum git_status_show_t {
751        GIT_STATUS_SHOW_INDEX_AND_WORKDIR = 0,
752        GIT_STATUS_SHOW_INDEX_ONLY = 1,
753        GIT_STATUS_SHOW_WORKDIR_ONLY = 2,
754    }
755}
756
757git_enum! {
758    pub enum git_delta_t {
759        GIT_DELTA_UNMODIFIED,
760        GIT_DELTA_ADDED,
761        GIT_DELTA_DELETED,
762        GIT_DELTA_MODIFIED,
763        GIT_DELTA_RENAMED,
764        GIT_DELTA_COPIED,
765        GIT_DELTA_IGNORED,
766        GIT_DELTA_UNTRACKED,
767        GIT_DELTA_TYPECHANGE,
768        GIT_DELTA_UNREADABLE,
769        GIT_DELTA_CONFLICTED,
770    }
771}
772
773#[repr(C)]
774pub struct git_status_options {
775    pub version: c_uint,
776    pub show: git_status_show_t,
777    pub flags: c_uint,
778    pub pathspec: git_strarray,
779    pub baseline: *mut git_tree,
780    pub rename_threshold: u16,
781}
782
783#[repr(C)]
784pub struct git_diff_delta {
785    pub status: git_delta_t,
786    pub flags: u32,
787    pub similarity: u16,
788    pub nfiles: u16,
789    pub old_file: git_diff_file,
790    pub new_file: git_diff_file,
791}
792
793#[repr(C)]
794pub struct git_status_entry {
795    pub status: git_status_t,
796    pub head_to_index: *mut git_diff_delta,
797    pub index_to_workdir: *mut git_diff_delta,
798}
799
800git_enum! {
801    pub enum git_checkout_strategy_t {
802        GIT_CHECKOUT_SAFE = 0,
803        GIT_CHECKOUT_FORCE = 1 << 1,
804        GIT_CHECKOUT_RECREATE_MISSING = 1 << 2,
805        GIT_CHECKOUT_ALLOW_CONFLICTS = 1 << 4,
806        GIT_CHECKOUT_REMOVE_UNTRACKED = 1 << 5,
807        GIT_CHECKOUT_REMOVE_IGNORED = 1 << 6,
808        GIT_CHECKOUT_UPDATE_ONLY = 1 << 7,
809        GIT_CHECKOUT_DONT_UPDATE_INDEX = 1 << 8,
810        GIT_CHECKOUT_NO_REFRESH = 1 << 9,
811        GIT_CHECKOUT_SKIP_UNMERGED = 1 << 10,
812        GIT_CHECKOUT_USE_OURS = 1 << 11,
813        GIT_CHECKOUT_USE_THEIRS = 1 << 12,
814        GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH = 1 << 13,
815        GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES = 1 << 18,
816        GIT_CHECKOUT_DONT_OVERWRITE_IGNORED = 1 << 19,
817        GIT_CHECKOUT_CONFLICT_STYLE_MERGE = 1 << 20,
818        GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 = 1 << 21,
819        GIT_CHECKOUT_NONE = 1 << 30,
820
821        GIT_CHECKOUT_UPDATE_SUBMODULES = 1 << 16,
822        GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = 1 << 17,
823    }
824}
825
826git_enum! {
827    pub enum git_reset_t {
828        GIT_RESET_SOFT = 1,
829        GIT_RESET_MIXED = 2,
830        GIT_RESET_HARD = 3,
831    }
832}
833
834git_enum! {
835    pub enum git_object_t: c_int {
836        GIT_OBJECT_ANY = -2,
837        GIT_OBJECT_INVALID = -1,
838        GIT_OBJECT_COMMIT = 1,
839        GIT_OBJECT_TREE = 2,
840        GIT_OBJECT_BLOB = 3,
841        GIT_OBJECT_TAG = 4,
842        GIT_OBJECT_OFS_DELTA = 6,
843        GIT_OBJECT_REF_DELTA = 7,
844    }
845}
846
847git_enum! {
848    pub enum git_reference_t {
849        GIT_REFERENCE_INVALID = 0,
850        GIT_REFERENCE_DIRECT = 1,
851        GIT_REFERENCE_SYMBOLIC = 2,
852        GIT_REFERENCE_ALL = GIT_REFERENCE_DIRECT | GIT_REFERENCE_SYMBOLIC,
853    }
854}
855
856git_enum! {
857    pub enum git_filemode_t {
858        GIT_FILEMODE_UNREADABLE = 0o000000,
859        GIT_FILEMODE_TREE = 0o040000,
860        GIT_FILEMODE_BLOB = 0o100644,
861        GIT_FILEMODE_BLOB_GROUP_WRITABLE = 0o100664,
862        GIT_FILEMODE_BLOB_EXECUTABLE = 0o100755,
863        GIT_FILEMODE_LINK = 0o120000,
864        GIT_FILEMODE_COMMIT = 0o160000,
865    }
866}
867
868git_enum! {
869    pub enum git_treewalk_mode {
870        GIT_TREEWALK_PRE = 0,
871        GIT_TREEWALK_POST = 1,
872    }
873}
874
875pub type git_treewalk_cb =
876    extern "C" fn(*const c_char, *const git_tree_entry, *mut c_void) -> c_int;
877pub type git_treebuilder_filter_cb =
878    Option<extern "C" fn(*const git_tree_entry, *mut c_void) -> c_int>;
879
880pub type git_revwalk_hide_cb = Option<extern "C" fn(*const git_oid, *mut c_void) -> c_int>;
881
882git_enum! {
883    pub enum git_tree_update_t {
884        GIT_TREE_UPDATE_UPSERT = 0,
885        GIT_TREE_UPDATE_REMOVE = 1,
886    }
887}
888
889#[repr(C)]
890pub struct git_tree_update {
891    pub action: git_tree_update_t,
892    pub id: git_oid,
893    pub filemode: git_filemode_t,
894    pub path: *const c_char,
895}
896
897#[repr(C)]
898#[derive(Copy, Clone)]
899pub struct git_buf {
900    pub ptr: *mut c_char,
901    pub reserved: size_t,
902    pub size: size_t,
903}
904
905git_enum! {
906    pub enum git_branch_t {
907        GIT_BRANCH_LOCAL = 1,
908        GIT_BRANCH_REMOTE = 2,
909        GIT_BRANCH_ALL = GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE,
910    }
911}
912
913pub const GIT_BLAME_NORMAL: u32 = 0;
914pub const GIT_BLAME_TRACK_COPIES_SAME_FILE: u32 = 1 << 0;
915pub const GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES: u32 = 1 << 1;
916pub const GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES: u32 = 1 << 2;
917pub const GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES: u32 = 1 << 3;
918pub const GIT_BLAME_FIRST_PARENT: u32 = 1 << 4;
919pub const GIT_BLAME_USE_MAILMAP: u32 = 1 << 5;
920pub const GIT_BLAME_IGNORE_WHITESPACE: u32 = 1 << 6;
921
922#[repr(C)]
923#[derive(Copy, Clone)]
924pub struct git_blame_options {
925    pub version: c_uint,
926
927    pub flags: u32,
928    pub min_match_characters: u16,
929    pub newest_commit: git_oid,
930    pub oldest_commit: git_oid,
931    pub min_line: usize,
932    pub max_line: usize,
933}
934
935#[repr(C)]
936#[derive(Copy, Clone)]
937pub struct git_blame_hunk {
938    pub lines_in_hunk: usize,
939    pub final_commit_id: git_oid,
940    pub final_start_line_number: usize,
941    pub final_signature: *mut git_signature,
942    pub final_committer: *mut git_signature,
943    pub orig_commit_id: git_oid,
944    pub orig_path: *const c_char,
945    pub orig_start_line_number: usize,
946    pub orig_signature: *mut git_signature,
947    pub orig_committer: *mut git_signature,
948    pub summary: *const c_char,
949    pub boundary: c_char,
950}
951
952pub type git_index_matched_path_cb =
953    Option<extern "C" fn(*const c_char, *const c_char, *mut c_void) -> c_int>;
954
955git_enum! {
956    pub enum git_index_entry_extended_flag_t {
957        GIT_INDEX_ENTRY_INTENT_TO_ADD     = 1 << 13,
958        GIT_INDEX_ENTRY_SKIP_WORKTREE     = 1 << 14,
959
960        GIT_INDEX_ENTRY_UPTODATE          = 1 << 2,
961    }
962}
963
964git_enum! {
965    pub enum git_index_entry_flag_t {
966        GIT_INDEX_ENTRY_EXTENDED = 0x4000,
967        GIT_INDEX_ENTRY_VALID    = 0x8000,
968    }
969}
970
971#[repr(C)]
972#[derive(Copy, Clone)]
973pub struct git_index_entry {
974    pub ctime: git_index_time,
975    pub mtime: git_index_time,
976    pub dev: u32,
977    pub ino: u32,
978    pub mode: u32,
979    pub uid: u32,
980    pub gid: u32,
981    pub file_size: u32,
982    pub id: git_oid,
983    pub flags: u16,
984    pub flags_extended: u16,
985    pub path: *const c_char,
986}
987
988pub const GIT_INDEX_ENTRY_NAMEMASK: u16 = 0xfff;
989pub const GIT_INDEX_ENTRY_STAGEMASK: u16 = 0x3000;
990pub const GIT_INDEX_ENTRY_STAGESHIFT: u16 = 12;
991
992#[repr(C)]
993#[derive(Copy, Clone, Debug, Eq, PartialEq)]
994pub struct git_index_time {
995    pub seconds: i32,
996    pub nanoseconds: u32,
997}
998
999#[repr(C)]
1000pub struct git_config_entry {
1001    pub name: *const c_char,
1002    pub value: *const c_char,
1003    pub backend_type: *const c_char,
1004    pub origin_path: *const c_char,
1005    pub include_depth: c_uint,
1006    pub level: git_config_level_t,
1007}
1008
1009git_enum! {
1010    pub enum git_config_level_t: c_int {
1011        GIT_CONFIG_LEVEL_PROGRAMDATA = 1,
1012        GIT_CONFIG_LEVEL_SYSTEM = 2,
1013        GIT_CONFIG_LEVEL_XDG = 3,
1014        GIT_CONFIG_LEVEL_GLOBAL = 4,
1015        GIT_CONFIG_LEVEL_LOCAL = 5,
1016        GIT_CONFIG_LEVEL_WORKTREE = 6,
1017        GIT_CONFIG_LEVEL_APP = 7,
1018        GIT_CONFIG_HIGHEST_LEVEL = -1,
1019    }
1020}
1021
1022git_enum! {
1023    pub enum git_submodule_update_t {
1024        GIT_SUBMODULE_UPDATE_CHECKOUT = 1,
1025        GIT_SUBMODULE_UPDATE_REBASE   = 2,
1026        GIT_SUBMODULE_UPDATE_MERGE    = 3,
1027        GIT_SUBMODULE_UPDATE_NONE     = 4,
1028        GIT_SUBMODULE_UPDATE_DEFAULT  = 0,
1029    }
1030}
1031
1032git_enum! {
1033    pub enum git_submodule_ignore_t: c_int {
1034        GIT_SUBMODULE_IGNORE_UNSPECIFIED = -1,
1035
1036        GIT_SUBMODULE_IGNORE_NONE      = 1,
1037        GIT_SUBMODULE_IGNORE_UNTRACKED = 2,
1038        GIT_SUBMODULE_IGNORE_DIRTY     = 3,
1039        GIT_SUBMODULE_IGNORE_ALL       = 4,
1040    }
1041}
1042
1043pub type git_submodule_cb =
1044    Option<extern "C" fn(*mut git_submodule, *const c_char, *mut c_void) -> c_int>;
1045
1046#[repr(C)]
1047pub struct git_submodule_update_options {
1048    pub version: c_uint,
1049    pub checkout_opts: git_checkout_options,
1050    pub fetch_opts: git_fetch_options,
1051    pub allow_fetch: c_int,
1052}
1053
1054#[repr(C)]
1055pub struct git_writestream {
1056    pub write: Option<extern "C" fn(*mut git_writestream, *const c_char, size_t) -> c_int>,
1057    pub close: Option<extern "C" fn(*mut git_writestream) -> c_int>,
1058    pub free: Option<extern "C" fn(*mut git_writestream)>,
1059}
1060
1061git_enum! {
1062    pub enum git_attr_value_t {
1063        GIT_ATTR_VALUE_UNSPECIFIED = 0,
1064        GIT_ATTR_VALUE_TRUE,
1065        GIT_ATTR_VALUE_FALSE,
1066        GIT_ATTR_VALUE_STRING,
1067    }
1068}
1069
1070pub const GIT_ATTR_CHECK_FILE_THEN_INDEX: u32 = 0;
1071pub const GIT_ATTR_CHECK_INDEX_THEN_FILE: u32 = 1;
1072pub const GIT_ATTR_CHECK_INDEX_ONLY: u32 = 2;
1073pub const GIT_ATTR_CHECK_NO_SYSTEM: u32 = 1 << 2;
1074pub const GIT_ATTR_CHECK_INCLUDE_HEAD: u32 = 1 << 3;
1075
1076#[repr(C)]
1077pub struct git_cred {
1078    pub credtype: git_credtype_t,
1079    pub free: Option<extern "C" fn(*mut git_cred)>,
1080}
1081
1082git_enum! {
1083    pub enum git_credtype_t {
1084        GIT_CREDTYPE_USERPASS_PLAINTEXT = 1 << 0,
1085        GIT_CREDTYPE_SSH_KEY = 1 << 1,
1086        GIT_CREDTYPE_SSH_CUSTOM = 1 << 2,
1087        GIT_CREDTYPE_DEFAULT = 1 << 3,
1088        GIT_CREDTYPE_SSH_INTERACTIVE = 1 << 4,
1089        GIT_CREDTYPE_USERNAME = 1 << 5,
1090        GIT_CREDTYPE_SSH_MEMORY = 1 << 6,
1091    }
1092}
1093
1094pub type git_cred_ssh_interactive_callback = Option<
1095    extern "C" fn(
1096        name: *const c_char,
1097        name_len: c_int,
1098        instruction: *const c_char,
1099        instruction_len: c_int,
1100        num_prompts: c_int,
1101        prompts: *const LIBSSH2_USERAUTH_KBDINT_PROMPT,
1102        responses: *mut LIBSSH2_USERAUTH_KBDINT_RESPONSE,
1103        abstrakt: *mut *mut c_void,
1104    ),
1105>;
1106
1107pub type git_cred_sign_callback = Option<
1108    extern "C" fn(
1109        session: *mut LIBSSH2_SESSION,
1110        sig: *mut *mut c_uchar,
1111        sig_len: *mut size_t,
1112        data: *const c_uchar,
1113        data_len: size_t,
1114        abstrakt: *mut *mut c_void,
1115    ),
1116>;
1117
1118pub enum LIBSSH2_SESSION {}
1119pub enum LIBSSH2_USERAUTH_KBDINT_PROMPT {}
1120pub enum LIBSSH2_USERAUTH_KBDINT_RESPONSE {}
1121
1122#[repr(C)]
1123pub struct git_push_options {
1124    pub version: c_uint,
1125    pub pb_parallelism: c_uint,
1126    pub callbacks: git_remote_callbacks,
1127    pub proxy_opts: git_proxy_options,
1128    pub follow_redirects: git_remote_redirect_t,
1129    pub custom_headers: git_strarray,
1130    pub remote_push_options: git_strarray,
1131}
1132
1133pub type git_tag_foreach_cb =
1134    Option<extern "C" fn(name: *const c_char, oid: *mut git_oid, payload: *mut c_void) -> c_int>;
1135
1136git_enum! {
1137    pub enum git_index_add_option_t {
1138        GIT_INDEX_ADD_DEFAULT = 0,
1139        GIT_INDEX_ADD_FORCE = 1 << 0,
1140        GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH = 1 << 1,
1141        GIT_INDEX_ADD_CHECK_PATHSPEC = 1 << 2,
1142    }
1143}
1144
1145git_enum! {
1146    pub enum git_repository_open_flag_t {
1147        GIT_REPOSITORY_OPEN_NO_SEARCH = 1 << 0,
1148        GIT_REPOSITORY_OPEN_CROSS_FS = 1 << 1,
1149        GIT_REPOSITORY_OPEN_BARE = 1 << 2,
1150        GIT_REPOSITORY_OPEN_NO_DOTGIT = 1 << 3,
1151        GIT_REPOSITORY_OPEN_FROM_ENV = 1 << 4,
1152    }
1153}
1154
1155#[repr(C)]
1156pub struct git_repository_init_options {
1157    pub version: c_uint,
1158    pub flags: u32,
1159    pub mode: u32,
1160    pub workdir_path: *const c_char,
1161    pub description: *const c_char,
1162    pub template_path: *const c_char,
1163    pub initial_head: *const c_char,
1164    pub origin_url: *const c_char,
1165    #[cfg(feature = "unstable-sha256")]
1166    pub oid_type: git_oid_t,
1167}
1168
1169pub const GIT_REPOSITORY_INIT_OPTIONS_VERSION: c_uint = 1;
1170
1171#[cfg(feature = "unstable-sha256")]
1172#[repr(C)]
1173pub struct git_repository_new_options {
1174    pub version: c_uint,
1175    pub oid_type: git_oid_t,
1176}
1177
1178#[cfg(feature = "unstable-sha256")]
1179pub const GIT_REPOSITORY_NEW_OPTIONS_VERSION: c_uint = 1;
1180
1181#[cfg(feature = "unstable-sha256")]
1182#[repr(C)]
1183pub struct git_index_options {
1184    pub version: c_uint,
1185    pub oid_type: git_oid_t,
1186}
1187
1188#[cfg(feature = "unstable-sha256")]
1189pub const GIT_INDEX_OPTIONS_VERSION: c_uint = 1;
1190
1191#[cfg(feature = "unstable-sha256")]
1192#[repr(C)]
1193pub struct git_odb_options {
1194    pub version: c_uint,
1195    pub oid_type: git_oid_t,
1196}
1197
1198#[cfg(feature = "unstable-sha256")]
1199pub const GIT_ODB_OPTIONS_VERSION: c_uint = 1;
1200
1201#[cfg(feature = "unstable-sha256")]
1202#[repr(C)]
1203pub struct git_odb_backend_pack_options {
1204    pub version: c_uint,
1205    pub oid_type: git_oid_t,
1206}
1207
1208#[cfg(feature = "unstable-sha256")]
1209pub const GIT_ODB_BACKEND_PACK_OPTIONS_VERSION: c_uint = 1;
1210
1211#[cfg(feature = "unstable-sha256")]
1212#[repr(C)]
1213pub struct git_odb_backend_loose_options {
1214    pub version: c_uint,
1215    pub flags: u32,
1216    pub compression_level: c_int,
1217    pub dir_mode: c_uint,
1218    pub file_mode: c_uint,
1219    pub oid_type: git_oid_t,
1220}
1221
1222#[cfg(feature = "unstable-sha256")]
1223pub const GIT_ODB_BACKEND_LOOSE_OPTIONS_VERSION: c_uint = 1;
1224
1225#[cfg(feature = "unstable-sha256")]
1226#[repr(C)]
1227pub struct git_diff_parse_options {
1228    pub version: c_uint,
1229    pub oid_type: git_oid_t,
1230}
1231
1232#[cfg(feature = "unstable-sha256")]
1233pub const GIT_DIFF_PARSE_OPTIONS_VERSION: c_uint = 1;
1234
1235git_enum! {
1236    pub enum git_repository_init_flag_t {
1237        GIT_REPOSITORY_INIT_BARE              = 1 << 0,
1238        GIT_REPOSITORY_INIT_NO_REINIT         = 1 << 1,
1239        GIT_REPOSITORY_INIT_NO_DOTGIT_DIR     = 1 << 2,
1240        GIT_REPOSITORY_INIT_MKDIR             = 1 << 3,
1241        GIT_REPOSITORY_INIT_MKPATH            = 1 << 4,
1242        GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = 1 << 5,
1243        GIT_REPOSITORY_INIT_RELATIVE_GITLINK  = 1 << 6,
1244    }
1245}
1246
1247git_enum! {
1248    pub enum git_repository_init_mode_t {
1249        GIT_REPOSITORY_INIT_SHARED_UMASK = 0,
1250        GIT_REPOSITORY_INIT_SHARED_GROUP = 0o002775,
1251        GIT_REPOSITORY_INIT_SHARED_ALL   = 0o002777,
1252    }
1253}
1254
1255git_enum! {
1256    pub enum git_sort_t {
1257        GIT_SORT_NONE        = 0,
1258        GIT_SORT_TOPOLOGICAL = 1 << 0,
1259        GIT_SORT_TIME        = 1 << 1,
1260        GIT_SORT_REVERSE     = 1 << 2,
1261    }
1262}
1263
1264git_enum! {
1265    pub enum git_submodule_status_t {
1266        GIT_SUBMODULE_STATUS_IN_HEAD = 1 << 0,
1267        GIT_SUBMODULE_STATUS_IN_INDEX = 1 << 1,
1268        GIT_SUBMODULE_STATUS_IN_CONFIG = 1 << 2,
1269        GIT_SUBMODULE_STATUS_IN_WD = 1 << 3,
1270        GIT_SUBMODULE_STATUS_INDEX_ADDED = 1 << 4,
1271        GIT_SUBMODULE_STATUS_INDEX_DELETED = 1 << 5,
1272        GIT_SUBMODULE_STATUS_INDEX_MODIFIED = 1 << 6,
1273        GIT_SUBMODULE_STATUS_WD_UNINITIALIZED = 1 << 7,
1274        GIT_SUBMODULE_STATUS_WD_ADDED = 1 << 8,
1275        GIT_SUBMODULE_STATUS_WD_DELETED = 1 << 9,
1276        GIT_SUBMODULE_STATUS_WD_MODIFIED = 1 << 10,
1277        GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED = 1 << 11,
1278        GIT_SUBMODULE_STATUS_WD_WD_MODIFIED = 1 << 12,
1279        GIT_SUBMODULE_STATUS_WD_UNTRACKED = 1 << 13,
1280    }
1281}
1282
1283#[repr(C)]
1284pub struct git_remote_head {
1285    pub local: c_int,
1286    pub oid: git_oid,
1287    pub loid: git_oid,
1288    pub name: *mut c_char,
1289    pub symref_target: *mut c_char,
1290}
1291
1292git_enum! {
1293    pub enum git_pathspec_flag_t {
1294        GIT_PATHSPEC_DEFAULT = 0,
1295        GIT_PATHSPEC_IGNORE_CASE = 1 << 0,
1296        GIT_PATHSPEC_USE_CASE = 1 << 1,
1297        GIT_PATHSPEC_NO_GLOB = 1 << 2,
1298        GIT_PATHSPEC_NO_MATCH_ERROR = 1 << 3,
1299        GIT_PATHSPEC_FIND_FAILURES = 1 << 4,
1300        GIT_PATHSPEC_FAILURES_ONLY = 1 << 5,
1301    }
1302}
1303
1304pub type git_diff_file_cb = Option<extern "C" fn(*const git_diff_delta, f32, *mut c_void) -> c_int>;
1305pub type git_diff_hunk_cb =
1306    Option<extern "C" fn(*const git_diff_delta, *const git_diff_hunk, *mut c_void) -> c_int>;
1307pub type git_diff_line_cb = Option<
1308    extern "C" fn(
1309        *const git_diff_delta,
1310        *const git_diff_hunk,
1311        *const git_diff_line,
1312        *mut c_void,
1313    ) -> c_int,
1314>;
1315pub type git_diff_binary_cb =
1316    Option<extern "C" fn(*const git_diff_delta, *const git_diff_binary, *mut c_void) -> c_int>;
1317
1318#[repr(C)]
1319pub struct git_diff_hunk {
1320    pub old_start: c_int,
1321    pub old_lines: c_int,
1322    pub new_start: c_int,
1323    pub new_lines: c_int,
1324    pub header_len: size_t,
1325    pub header: [c_char; 128],
1326}
1327
1328git_enum! {
1329    pub enum git_diff_line_t {
1330        GIT_DIFF_LINE_CONTEXT = b' ' as git_diff_line_t,
1331        GIT_DIFF_LINE_ADDITION = b'+' as git_diff_line_t,
1332        GIT_DIFF_LINE_DELETION = b'-' as git_diff_line_t,
1333        GIT_DIFF_LINE_CONTEXT_EOFNL = b'=' as git_diff_line_t,
1334        GIT_DIFF_LINE_ADD_EOFNL = b'>' as git_diff_line_t,
1335        GIT_DIFF_LINE_DEL_EOFNL = b'<' as git_diff_line_t,
1336        GIT_DIFF_LINE_FILE_HDR = b'F' as git_diff_line_t,
1337        GIT_DIFF_LINE_HUNK_HDR = b'H' as git_diff_line_t,
1338        GIT_DIFF_LINE_BINARY = b'B' as git_diff_line_t,
1339    }
1340}
1341
1342#[repr(C)]
1343pub struct git_diff_line {
1344    pub origin: c_char,
1345    pub old_lineno: c_int,
1346    pub new_lineno: c_int,
1347    pub num_lines: c_int,
1348    pub content_len: size_t,
1349    pub content_offset: git_off_t,
1350    pub content: *const c_char,
1351}
1352
1353#[repr(C)]
1354pub struct git_diff_options {
1355    pub version: c_uint,
1356    pub flags: u32,
1357    pub ignore_submodules: git_submodule_ignore_t,
1358    pub pathspec: git_strarray,
1359    pub notify_cb: git_diff_notify_cb,
1360    pub progress_cb: git_diff_progress_cb,
1361    pub payload: *mut c_void,
1362    pub context_lines: u32,
1363    pub interhunk_lines: u32,
1364    pub oid_type: git_oid_t,
1365    pub id_abbrev: u16,
1366    pub max_size: git_off_t,
1367    pub old_prefix: *const c_char,
1368    pub new_prefix: *const c_char,
1369}
1370
1371git_enum! {
1372    pub enum git_oid_t {
1373        GIT_OID_SHA1 = 1,
1374        #[cfg(feature = "unstable-sha256")]
1375        GIT_OID_SHA256 = 2,
1376    }
1377}
1378
1379git_enum! {
1380    pub enum git_diff_format_t {
1381        GIT_DIFF_FORMAT_PATCH = 1,
1382        GIT_DIFF_FORMAT_PATCH_HEADER = 2,
1383        GIT_DIFF_FORMAT_RAW = 3,
1384        GIT_DIFF_FORMAT_NAME_ONLY = 4,
1385        GIT_DIFF_FORMAT_NAME_STATUS = 5,
1386        GIT_DIFF_FORMAT_PATCH_ID = 6,
1387    }
1388}
1389
1390git_enum! {
1391    pub enum git_diff_stats_format_t {
1392        GIT_DIFF_STATS_NONE = 0,
1393        GIT_DIFF_STATS_FULL = 1 << 0,
1394        GIT_DIFF_STATS_SHORT = 1 << 1,
1395        GIT_DIFF_STATS_NUMBER = 1 << 2,
1396        GIT_DIFF_STATS_INCLUDE_SUMMARY = 1 << 3,
1397    }
1398}
1399
1400pub type git_diff_notify_cb = Option<
1401    extern "C" fn(*const git_diff, *const git_diff_delta, *const c_char, *mut c_void) -> c_int,
1402>;
1403
1404pub type git_diff_progress_cb =
1405    Option<extern "C" fn(*const git_diff, *const c_char, *const c_char, *mut c_void) -> c_int>;
1406
1407git_enum! {
1408    pub enum git_diff_option_t {
1409        GIT_DIFF_NORMAL = 0,
1410        GIT_DIFF_REVERSE = 1 << 0,
1411        GIT_DIFF_INCLUDE_IGNORED = 1 << 1,
1412        GIT_DIFF_RECURSE_IGNORED_DIRS = 1 << 2,
1413        GIT_DIFF_INCLUDE_UNTRACKED = 1 << 3,
1414        GIT_DIFF_RECURSE_UNTRACKED_DIRS = 1 << 4,
1415        GIT_DIFF_INCLUDE_UNMODIFIED = 1 << 5,
1416        GIT_DIFF_INCLUDE_TYPECHANGE = 1 << 6,
1417        GIT_DIFF_INCLUDE_TYPECHANGE_TREES = 1 << 7,
1418        GIT_DIFF_IGNORE_FILEMODE = 1 << 8,
1419        GIT_DIFF_IGNORE_SUBMODULES = 1 << 9,
1420        GIT_DIFF_IGNORE_CASE = 1 << 10,
1421        GIT_DIFF_DISABLE_PATHSPEC_MATCH = 1 << 12,
1422        GIT_DIFF_SKIP_BINARY_CHECK = 1 << 13,
1423        GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS = 1 << 14,
1424        GIT_DIFF_UPDATE_INDEX = 1 << 15,
1425        GIT_DIFF_INCLUDE_UNREADABLE = 1 << 16,
1426        GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED = 1 << 17,
1427        GIT_DIFF_INDENT_HEURISTIC = 1 << 18,
1428        GIT_DIFF_IGNORE_BLANK_LINES = 1 << 19,
1429        GIT_DIFF_FORCE_TEXT = 1 << 20,
1430        GIT_DIFF_FORCE_BINARY = 1 << 21,
1431        GIT_DIFF_IGNORE_WHITESPACE = 1 << 22,
1432        GIT_DIFF_IGNORE_WHITESPACE_CHANGE = 1 << 23,
1433        GIT_DIFF_IGNORE_WHITESPACE_EOL = 1 << 24,
1434        GIT_DIFF_SHOW_UNTRACKED_CONTENT = 1 << 25,
1435        GIT_DIFF_SHOW_UNMODIFIED = 1 << 26,
1436        GIT_DIFF_PATIENCE = 1 << 28,
1437        GIT_DIFF_MINIMAL = 1 << 29,
1438        GIT_DIFF_SHOW_BINARY = 1 << 30,
1439    }
1440}
1441
1442#[repr(C)]
1443pub struct git_diff_find_options {
1444    pub version: c_uint,
1445    pub flags: u32,
1446    pub rename_threshold: u16,
1447    pub rename_from_rewrite_threshold: u16,
1448    pub copy_threshold: u16,
1449    pub break_rewrite_threshold: u16,
1450    pub rename_limit: size_t,
1451    pub metric: *mut git_diff_similarity_metric,
1452}
1453
1454#[repr(C)]
1455pub struct git_diff_similarity_metric {
1456    pub file_signature: Option<
1457        extern "C" fn(*mut *mut c_void, *const git_diff_file, *const c_char, *mut c_void) -> c_int,
1458    >,
1459    pub buffer_signature: Option<
1460        extern "C" fn(
1461            *mut *mut c_void,
1462            *const git_diff_file,
1463            *const c_char,
1464            size_t,
1465            *mut c_void,
1466        ) -> c_int,
1467    >,
1468    pub free_signature: Option<extern "C" fn(*mut c_void, *mut c_void)>,
1469    pub similarity:
1470        Option<extern "C" fn(*mut c_int, *mut c_void, *mut c_void, *mut c_void) -> c_int>,
1471    pub payload: *mut c_void,
1472}
1473
1474pub const GIT_DIFF_FIND_OPTIONS_VERSION: c_uint = 1;
1475
1476pub const GIT_DIFF_FIND_BY_CONFIG: u32 = 0;
1477pub const GIT_DIFF_FIND_RENAMES: u32 = 1 << 0;
1478pub const GIT_DIFF_FIND_RENAMES_FROM_REWRITES: u32 = 1 << 1;
1479pub const GIT_DIFF_FIND_COPIES: u32 = 1 << 2;
1480pub const GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED: u32 = 1 << 3;
1481pub const GIT_DIFF_FIND_REWRITES: u32 = 1 << 4;
1482pub const GIT_DIFF_BREAK_REWRITES: u32 = 1 << 5;
1483pub const GIT_DIFF_FIND_AND_BREAK_REWRITES: u32 = GIT_DIFF_FIND_REWRITES | GIT_DIFF_BREAK_REWRITES;
1484pub const GIT_DIFF_FIND_FOR_UNTRACKED: u32 = 1 << 6;
1485pub const GIT_DIFF_FIND_ALL: u32 = 0x0ff;
1486pub const GIT_DIFF_FIND_IGNORE_LEADING_WHITESPACE: u32 = 0;
1487pub const GIT_DIFF_FIND_IGNORE_WHITESPACE: u32 = 1 << 12;
1488pub const GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE: u32 = 1 << 13;
1489pub const GIT_DIFF_FIND_EXACT_MATCH_ONLY: u32 = 1 << 14;
1490pub const GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY: u32 = 1 << 15;
1491pub const GIT_DIFF_FIND_REMOVE_UNMODIFIED: u32 = 1 << 16;
1492
1493#[repr(C)]
1494pub struct git_diff_format_email_options {
1495    pub version: c_uint,
1496    pub flags: u32,
1497    pub patch_no: usize,
1498    pub total_patches: usize,
1499    pub id: *const git_oid,
1500    pub summary: *const c_char,
1501    pub body: *const c_char,
1502    pub author: *const git_signature,
1503}
1504
1505pub const GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION: c_uint = 1;
1506
1507pub const GIT_DIFF_FORMAT_EMAIL_NONE: u32 = 0;
1508pub const GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER: u32 = 1 << 0;
1509
1510#[repr(C)]
1511pub struct git_diff_patchid_options {
1512    pub version: c_uint,
1513}
1514
1515pub const GIT_DIFF_PATCHID_OPTIONS_VERSION: c_uint = 1;
1516
1517#[repr(C)]
1518pub struct git_diff_binary {
1519    pub contains_data: c_uint,
1520    pub old_file: git_diff_binary_file,
1521    pub new_file: git_diff_binary_file,
1522}
1523
1524#[repr(C)]
1525pub struct git_diff_binary_file {
1526    pub kind: git_diff_binary_t,
1527    pub data: *const c_char,
1528    pub datalen: size_t,
1529    pub inflatedlen: size_t,
1530}
1531
1532git_enum! {
1533    pub enum git_diff_binary_t {
1534        GIT_DIFF_BINARY_NONE,
1535        GIT_DIFF_BINARY_LITERAL,
1536        GIT_DIFF_BINARY_DELTA,
1537    }
1538}
1539
1540#[repr(C)]
1541pub struct git_merge_options {
1542    pub version: c_uint,
1543    pub flags: u32,
1544    pub rename_threshold: c_uint,
1545    pub target_limit: c_uint,
1546    pub metric: *mut git_diff_similarity_metric,
1547    pub recursion_limit: c_uint,
1548    pub default_driver: *const c_char,
1549    pub file_favor: git_merge_file_favor_t,
1550    pub file_flags: u32,
1551}
1552
1553#[repr(C)]
1554pub struct git_merge_file_options {
1555    pub version: c_uint,
1556    pub ancestor_label: *const c_char,
1557    pub our_label: *const c_char,
1558    pub their_label: *const c_char,
1559    pub favor: git_merge_file_favor_t,
1560    pub flags: u32,
1561    pub marker_size: c_ushort,
1562}
1563
1564#[repr(C)]
1565pub struct git_merge_file_input {
1566    pub version: c_uint,
1567    pub ptr: *const c_char,
1568    pub size: size_t,
1569    pub path: *const c_char,
1570    pub mode: c_uint,
1571}
1572
1573#[repr(C)]
1574pub struct git_merge_file_result {
1575    pub automergeable: c_uint,
1576    pub path: *const c_char,
1577    pub mode: c_uint,
1578    pub ptr: *const c_char,
1579    pub len: size_t,
1580}
1581
1582git_enum! {
1583    pub enum git_merge_flag_t {
1584        GIT_MERGE_FIND_RENAMES = 1 << 0,
1585        GIT_MERGE_FAIL_ON_CONFLICT = 1 << 1,
1586        GIT_MERGE_SKIP_REUC = 1 << 2,
1587        GIT_MERGE_NO_RECURSIVE = 1 << 3,
1588    }
1589}
1590
1591git_enum! {
1592    pub enum git_merge_file_favor_t {
1593        GIT_MERGE_FILE_FAVOR_NORMAL = 0,
1594        GIT_MERGE_FILE_FAVOR_OURS = 1,
1595        GIT_MERGE_FILE_FAVOR_THEIRS = 2,
1596        GIT_MERGE_FILE_FAVOR_UNION = 3,
1597    }
1598}
1599
1600git_enum! {
1601    pub enum git_merge_file_flag_t {
1602        GIT_MERGE_FILE_DEFAULT = 0,
1603        GIT_MERGE_FILE_STYLE_MERGE = 1 << 0,
1604        GIT_MERGE_FILE_STYLE_DIFF3 = 1 << 1,
1605        GIT_MERGE_FILE_SIMPLIFY_ALNUM = 1 << 2,
1606        GIT_MERGE_FILE_IGNORE_WHITESPACE = 1 << 3,
1607        GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = 1 << 4,
1608        GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = 1 << 5,
1609        GIT_MERGE_FILE_DIFF_PATIENCE = 1 << 6,
1610        GIT_MERGE_FILE_DIFF_MINIMAL = 1 << 7,
1611        GIT_MERGE_FILE_STYLE_ZDIFF3 = 1 << 8,
1612        GIT_MERGE_FILE_ACCEPT_CONFLICTS = 1 << 9,
1613    }
1614}
1615
1616git_enum! {
1617    pub enum git_merge_analysis_t {
1618        GIT_MERGE_ANALYSIS_NONE = 0,
1619        GIT_MERGE_ANALYSIS_NORMAL = 1 << 0,
1620        GIT_MERGE_ANALYSIS_UP_TO_DATE = 1 << 1,
1621        GIT_MERGE_ANALYSIS_FASTFORWARD = 1 << 2,
1622        GIT_MERGE_ANALYSIS_UNBORN = 1 << 3,
1623    }
1624}
1625
1626git_enum! {
1627    pub enum git_merge_preference_t {
1628        GIT_MERGE_PREFERENCE_NONE = 0,
1629        GIT_MERGE_PREFERENCE_NO_FASTFORWARD = 1 << 0,
1630        GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = 1 << 1,
1631    }
1632}
1633
1634pub type git_transport_cb = Option<
1635    extern "C" fn(
1636        out: *mut *mut git_transport,
1637        owner: *mut git_remote,
1638        param: *mut c_void,
1639    ) -> c_int,
1640>;
1641
1642#[repr(C)]
1643pub struct git_transport {
1644    pub version: c_uint,
1645    pub connect: Option<
1646        extern "C" fn(
1647            transport: *mut git_transport,
1648            url: *const c_char,
1649            direction: c_int,
1650            connect_opts: *const git_remote_connect_options,
1651        ) -> c_int,
1652    >,
1653    pub set_connect_opts: Option<
1654        extern "C" fn(
1655            transport: *mut git_transport,
1656            connect_opts: *const git_remote_connect_options,
1657        ) -> c_int,
1658    >,
1659    pub capabilities:
1660        Option<extern "C" fn(capabilities: *mut c_uint, transport: *mut git_transport) -> c_int>,
1661    #[cfg(feature = "unstable-sha256")]
1662    pub oid_type:
1663        Option<extern "C" fn(object_type: *mut git_oid_t, transport: *mut git_transport) -> c_int>,
1664    pub ls: Option<
1665        extern "C" fn(
1666            out: *mut *mut *const git_remote_head,
1667            size: *mut size_t,
1668            transport: *mut git_transport,
1669        ) -> c_int,
1670    >,
1671    pub push: Option<extern "C" fn(transport: *mut git_transport, push: *mut git_push) -> c_int>,
1672    pub negotiate_fetch: Option<
1673        extern "C" fn(
1674            transport: *mut git_transport,
1675            repo: *mut git_repository,
1676            fetch_data: *const git_fetch_negotiation,
1677        ) -> c_int,
1678    >,
1679    pub shallow_roots:
1680        Option<extern "C" fn(out: *mut git_oidarray, transport: *mut git_transport) -> c_int>,
1681    pub download_pack: Option<
1682        extern "C" fn(
1683            transport: *mut git_transport,
1684            repo: *mut git_repository,
1685            stats: *mut git_indexer_progress,
1686        ) -> c_int,
1687    >,
1688    pub is_connected: Option<extern "C" fn(transport: *mut git_transport) -> c_int>,
1689    pub cancel: Option<extern "C" fn(transport: *mut git_transport)>,
1690    pub close: Option<extern "C" fn(transport: *mut git_transport) -> c_int>,
1691    pub free: Option<extern "C" fn(transport: *mut git_transport)>,
1692}
1693
1694#[repr(C)]
1695pub struct git_remote_connect_options {
1696    pub version: c_uint,
1697    pub callbacks: git_remote_callbacks,
1698    pub proxy_opts: git_proxy_options,
1699    pub follow_redirects: git_remote_redirect_t,
1700    pub custom_headers: git_strarray,
1701}
1702
1703git_enum! {
1704    pub enum git_remote_redirect_t {
1705        GIT_REMOTE_REDIRECT_NONE = 1 << 0,
1706        GIT_REMOTE_REDIRECT_INITIAL = 1 << 1,
1707        GIT_REMOTE_REDIRECT_ALL = 1 << 2,
1708    }
1709}
1710
1711#[repr(C)]
1712pub struct git_odb_backend {
1713    pub version: c_uint,
1714    pub odb: *mut git_odb,
1715    pub read: Option<
1716        extern "C" fn(
1717            *mut *mut c_void,
1718            *mut size_t,
1719            *mut git_object_t,
1720            *mut git_odb_backend,
1721            *const git_oid,
1722        ) -> c_int,
1723    >,
1724
1725    pub read_prefix: Option<
1726        extern "C" fn(
1727            *mut git_oid,
1728            *mut *mut c_void,
1729            *mut size_t,
1730            *mut git_object_t,
1731            *mut git_odb_backend,
1732            *const git_oid,
1733            size_t,
1734        ) -> c_int,
1735    >,
1736    pub read_header: Option<
1737        extern "C" fn(
1738            *mut size_t,
1739            *mut git_object_t,
1740            *mut git_odb_backend,
1741            *const git_oid,
1742        ) -> c_int,
1743    >,
1744
1745    pub write: Option<
1746        extern "C" fn(
1747            *mut git_odb_backend,
1748            *const git_oid,
1749            *const c_void,
1750            size_t,
1751            git_object_t,
1752        ) -> c_int,
1753    >,
1754
1755    pub writestream: Option<
1756        extern "C" fn(
1757            *mut *mut git_odb_stream,
1758            *mut git_odb_backend,
1759            git_object_size_t,
1760            git_object_t,
1761        ) -> c_int,
1762    >,
1763
1764    pub readstream: Option<
1765        extern "C" fn(
1766            *mut *mut git_odb_stream,
1767            *mut size_t,
1768            *mut git_object_t,
1769            *mut git_odb_backend,
1770            *const git_oid,
1771        ) -> c_int,
1772    >,
1773
1774    pub exists: Option<extern "C" fn(*mut git_odb_backend, *const git_oid) -> c_int>,
1775
1776    pub exists_prefix:
1777        Option<extern "C" fn(*mut git_oid, *mut git_odb_backend, *const git_oid, size_t) -> c_int>,
1778
1779    pub refresh: Option<extern "C" fn(*mut git_odb_backend) -> c_int>,
1780
1781    pub foreach:
1782        Option<extern "C" fn(*mut git_odb_backend, git_odb_foreach_cb, *mut c_void) -> c_int>,
1783
1784    pub writepack: Option<
1785        extern "C" fn(
1786            *mut *mut git_odb_writepack,
1787            *mut git_odb_backend,
1788            *mut git_odb,
1789            git_indexer_progress_cb,
1790            *mut c_void,
1791        ) -> c_int,
1792    >,
1793
1794    pub writemidx: Option<extern "C" fn(*mut git_odb_backend) -> c_int>,
1795
1796    pub freshen: Option<extern "C" fn(*mut git_odb_backend, *const git_oid) -> c_int>,
1797
1798    pub free: Option<extern "C" fn(*mut git_odb_backend)>,
1799}
1800
1801git_enum! {
1802    pub enum git_odb_lookup_flags_t {
1803        GIT_ODB_LOOKUP_NO_REFRESH = 1 << 0,
1804    }
1805}
1806
1807#[repr(C)]
1808pub struct git_odb_writepack {
1809    pub backend: *mut git_odb_backend,
1810
1811    pub append: Option<
1812        extern "C" fn(
1813            *mut git_odb_writepack,
1814            *const c_void,
1815            size_t,
1816            *mut git_indexer_progress,
1817        ) -> c_int,
1818    >,
1819
1820    pub commit:
1821        Option<unsafe extern "C" fn(*mut git_odb_writepack, *mut git_indexer_progress) -> c_int>,
1822
1823    pub free: Option<unsafe extern "C" fn(*mut git_odb_writepack)>,
1824}
1825
1826#[repr(C)]
1827pub struct git_refdb_backend {
1828    pub version: c_uint,
1829    pub exists: Option<extern "C" fn(*mut c_int, *mut git_refdb_backend, *const c_char) -> c_int>,
1830    pub lookup: Option<
1831        extern "C" fn(*mut *mut git_reference, *mut git_refdb_backend, *const c_char) -> c_int,
1832    >,
1833    pub iterator: Option<
1834        extern "C" fn(
1835            *mut *mut git_reference_iterator,
1836            *mut git_refdb_backend,
1837            *const c_char,
1838        ) -> c_int,
1839    >,
1840    pub write: Option<
1841        extern "C" fn(
1842            *mut git_refdb_backend,
1843            *const git_reference,
1844            c_int,
1845            *const git_signature,
1846            *const c_char,
1847            *const git_oid,
1848            *const c_char,
1849        ) -> c_int,
1850    >,
1851    pub rename: Option<
1852        extern "C" fn(
1853            *mut *mut git_reference,
1854            *mut git_refdb_backend,
1855            *const c_char,
1856            *const c_char,
1857            c_int,
1858            *const git_signature,
1859            *const c_char,
1860        ) -> c_int,
1861    >,
1862    pub del: Option<
1863        extern "C" fn(
1864            *mut git_refdb_backend,
1865            *const c_char,
1866            *const git_oid,
1867            *const c_char,
1868        ) -> c_int,
1869    >,
1870    pub compress: Option<extern "C" fn(*mut git_refdb_backend) -> c_int>,
1871    pub has_log: Option<extern "C" fn(*mut git_refdb_backend, *const c_char) -> c_int>,
1872    pub ensure_log: Option<extern "C" fn(*mut git_refdb_backend, *const c_char) -> c_int>,
1873    pub free: Option<extern "C" fn(*mut git_refdb_backend)>,
1874    pub reflog_read:
1875        Option<extern "C" fn(*mut *mut git_reflog, *mut git_refdb_backend, *const c_char) -> c_int>,
1876    pub reflog_write: Option<extern "C" fn(*mut git_refdb_backend, *mut git_reflog) -> c_int>,
1877    pub reflog_rename:
1878        Option<extern "C" fn(*mut git_refdb_backend, *const c_char, *const c_char) -> c_int>,
1879    pub reflog_delete: Option<extern "C" fn(*mut git_refdb_backend, *const c_char) -> c_int>,
1880    pub lock:
1881        Option<extern "C" fn(*mut *mut c_void, *mut git_refdb_backend, *const c_char) -> c_int>,
1882    pub unlock: Option<
1883        extern "C" fn(
1884            *mut git_refdb_backend,
1885            *mut c_void,
1886            c_int,
1887            c_int,
1888            *const git_reference,
1889            *const git_signature,
1890            *const c_char,
1891        ) -> c_int,
1892    >,
1893}
1894
1895#[repr(C)]
1896pub struct git_proxy_options {
1897    pub version: c_uint,
1898    pub kind: git_proxy_t,
1899    pub url: *const c_char,
1900    pub credentials: git_cred_acquire_cb,
1901    pub certificate_check: git_transport_certificate_check_cb,
1902    pub payload: *mut c_void,
1903}
1904
1905git_enum! {
1906    pub enum git_proxy_t {
1907        GIT_PROXY_NONE = 0,
1908        GIT_PROXY_AUTO = 1,
1909        GIT_PROXY_SPECIFIED = 2,
1910    }
1911}
1912
1913git_enum! {
1914    pub enum git_smart_service_t {
1915        GIT_SERVICE_UPLOADPACK_LS = 1,
1916        GIT_SERVICE_UPLOADPACK = 2,
1917        GIT_SERVICE_RECEIVEPACK_LS = 3,
1918        GIT_SERVICE_RECEIVEPACK = 4,
1919    }
1920}
1921
1922#[repr(C)]
1923pub struct git_smart_subtransport_stream {
1924    pub subtransport: *mut git_smart_subtransport,
1925    pub read: Option<
1926        extern "C" fn(
1927            *mut git_smart_subtransport_stream,
1928            *mut c_char,
1929            size_t,
1930            *mut size_t,
1931        ) -> c_int,
1932    >,
1933    pub write:
1934        Option<extern "C" fn(*mut git_smart_subtransport_stream, *const c_char, size_t) -> c_int>,
1935    pub free: Option<extern "C" fn(*mut git_smart_subtransport_stream)>,
1936}
1937
1938#[repr(C)]
1939pub struct git_smart_subtransport {
1940    pub action: Option<
1941        extern "C" fn(
1942            *mut *mut git_smart_subtransport_stream,
1943            *mut git_smart_subtransport,
1944            *const c_char,
1945            git_smart_service_t,
1946        ) -> c_int,
1947    >,
1948    pub close: Option<extern "C" fn(*mut git_smart_subtransport) -> c_int>,
1949    pub free: Option<extern "C" fn(*mut git_smart_subtransport)>,
1950}
1951
1952pub type git_smart_subtransport_cb = Option<
1953    extern "C" fn(*mut *mut git_smart_subtransport, *mut git_transport, *mut c_void) -> c_int,
1954>;
1955
1956#[repr(C)]
1957pub struct git_smart_subtransport_definition {
1958    pub callback: git_smart_subtransport_cb,
1959    pub rpc: c_uint,
1960    pub param: *mut c_void,
1961}
1962
1963#[repr(C)]
1964pub struct git_describe_options {
1965    pub version: c_uint,
1966    pub max_candidates_tags: c_uint,
1967    pub describe_strategy: c_uint,
1968    pub pattern: *const c_char,
1969    pub only_follow_first_parent: c_int,
1970    pub show_commit_oid_as_fallback: c_int,
1971}
1972
1973git_enum! {
1974    pub enum git_describe_strategy_t {
1975        GIT_DESCRIBE_DEFAULT,
1976        GIT_DESCRIBE_TAGS,
1977        GIT_DESCRIBE_ALL,
1978    }
1979}
1980
1981#[repr(C)]
1982pub struct git_describe_format_options {
1983    pub version: c_uint,
1984    pub abbreviated_size: c_uint,
1985    pub always_use_long_format: c_int,
1986    pub dirty_suffix: *const c_char,
1987}
1988
1989git_enum! {
1990    pub enum git_packbuilder_stage_t {
1991        GIT_PACKBUILDER_ADDING_OBJECTS,
1992        GIT_PACKBUILDER_DELTAFICATION,
1993    }
1994}
1995
1996git_enum! {
1997    pub enum git_stash_flags {
1998        GIT_STASH_DEFAULT = 0,
1999        GIT_STASH_KEEP_INDEX = 1 << 0,
2000        GIT_STASH_INCLUDE_UNTRACKED = 1 << 1,
2001        GIT_STASH_INCLUDE_IGNORED = 1 << 2,
2002        GIT_STASH_KEEP_ALL = 1 << 3,
2003    }
2004}
2005
2006git_enum! {
2007    pub enum git_stash_apply_flags {
2008        GIT_STASH_APPLY_DEFAULT = 0,
2009        GIT_STASH_APPLY_REINSTATE_INDEX = 1 << 0,
2010    }
2011}
2012
2013git_enum! {
2014    pub enum git_stash_apply_progress_t {
2015        GIT_STASH_APPLY_PROGRESS_NONE = 0,
2016        GIT_STASH_APPLY_PROGRESS_LOADING_STASH,
2017        GIT_STASH_APPLY_PROGRESS_ANALYZE_INDEX,
2018        GIT_STASH_APPLY_PROGRESS_ANALYZE_MODIFIED,
2019        GIT_STASH_APPLY_PROGRESS_ANALYZE_UNTRACKED,
2020        GIT_STASH_APPLY_PROGRESS_CHECKOUT_UNTRACKED,
2021        GIT_STASH_APPLY_PROGRESS_CHECKOUT_MODIFIED,
2022        GIT_STASH_APPLY_PROGRESS_DONE,
2023    }
2024}
2025
2026#[repr(C)]
2027pub struct git_stash_save_options {
2028    pub version: c_uint,
2029    pub flags: u32,
2030    pub stasher: *const git_signature,
2031    pub message: *const c_char,
2032    pub paths: git_strarray,
2033}
2034
2035pub const GIT_STASH_SAVE_OPTIONS_VERSION: c_uint = 1;
2036
2037#[repr(C)]
2038pub struct git_stash_apply_options {
2039    pub version: c_uint,
2040    pub flags: u32,
2041    pub checkout_options: git_checkout_options,
2042    pub progress_cb: git_stash_apply_progress_cb,
2043    pub progress_payload: *mut c_void,
2044}
2045
2046pub type git_stash_apply_progress_cb =
2047    Option<extern "C" fn(progress: git_stash_apply_progress_t, payload: *mut c_void) -> c_int>;
2048
2049pub type git_stash_cb = Option<
2050    extern "C" fn(
2051        index: size_t,
2052        message: *const c_char,
2053        stash_id: *const git_oid,
2054        payload: *mut c_void,
2055    ) -> c_int,
2056>;
2057
2058pub type git_packbuilder_foreach_cb =
2059    Option<extern "C" fn(*const c_void, size_t, *mut c_void) -> c_int>;
2060
2061pub type git_odb_foreach_cb =
2062    Option<extern "C" fn(id: *const git_oid, payload: *mut c_void) -> c_int>;
2063
2064pub type git_commit_signing_cb = Option<
2065    extern "C" fn(
2066        signature: *mut git_buf,
2067        signature_field: *mut git_buf,
2068        commit_content: *const c_char,
2069        payload: *mut c_void,
2070    ) -> c_int,
2071>;
2072
2073pub type git_commit_create_cb = Option<
2074    extern "C" fn(
2075        *mut git_oid,
2076        *const git_signature,
2077        *const git_signature,
2078        *const c_char,
2079        *const c_char,
2080        *const git_tree,
2081        usize,
2082        *const git_commit,
2083        *mut c_void,
2084    ) -> c_int,
2085>;
2086
2087pub const GIT_REBASE_NO_OPERATION: usize = usize::max_value();
2088
2089#[repr(C)]
2090pub struct git_rebase_options {
2091    pub version: c_uint,
2092    pub quiet: c_int,
2093    pub inmemory: c_int,
2094    pub rewrite_notes_ref: *const c_char,
2095    pub merge_options: git_merge_options,
2096    pub checkout_options: git_checkout_options,
2097    pub commit_create_cb: git_commit_create_cb,
2098    pub signing_cb: git_commit_signing_cb,
2099    pub payload: *mut c_void,
2100}
2101
2102git_enum! {
2103    pub enum git_rebase_operation_t {
2104        GIT_REBASE_OPERATION_PICK = 0,
2105        GIT_REBASE_OPERATION_REWORD,
2106        GIT_REBASE_OPERATION_EDIT,
2107        GIT_REBASE_OPERATION_SQUASH,
2108        GIT_REBASE_OPERATION_FIXUP,
2109        GIT_REBASE_OPERATION_EXEC,
2110    }
2111}
2112
2113#[repr(C)]
2114pub struct git_rebase_operation {
2115    pub kind: git_rebase_operation_t,
2116    pub id: git_oid,
2117    pub exec: *const c_char,
2118}
2119
2120#[repr(C)]
2121pub struct git_cherrypick_options {
2122    pub version: c_uint,
2123    pub mainline: c_uint,
2124    pub merge_opts: git_merge_options,
2125    pub checkout_opts: git_checkout_options,
2126}
2127
2128pub type git_revert_options = git_cherrypick_options;
2129
2130pub type git_apply_delta_cb =
2131    Option<extern "C" fn(delta: *const git_diff_delta, payload: *mut c_void) -> c_int>;
2132
2133pub type git_apply_hunk_cb =
2134    Option<extern "C" fn(hunk: *const git_diff_hunk, payload: *mut c_void) -> c_int>;
2135
2136git_enum! {
2137    pub enum git_apply_flags_t {
2138        GIT_APPLY_CHECK = 1<<0,
2139    }
2140}
2141
2142#[repr(C)]
2143pub struct git_apply_options {
2144    pub version: c_uint,
2145    pub delta_cb: git_apply_delta_cb,
2146    pub hunk_cb: git_apply_hunk_cb,
2147    pub payload: *mut c_void,
2148    pub flags: u32,
2149}
2150
2151git_enum! {
2152    pub enum git_apply_location_t {
2153        GIT_APPLY_LOCATION_WORKDIR = 0,
2154        GIT_APPLY_LOCATION_INDEX = 1,
2155        GIT_APPLY_LOCATION_BOTH = 2,
2156    }
2157}
2158
2159git_enum! {
2160    pub enum git_libgit2_opt_t {
2161        GIT_OPT_GET_MWINDOW_SIZE = 0,
2162        GIT_OPT_SET_MWINDOW_SIZE,
2163        GIT_OPT_GET_MWINDOW_MAPPED_LIMIT,
2164        GIT_OPT_SET_MWINDOW_MAPPED_LIMIT,
2165        GIT_OPT_GET_SEARCH_PATH,
2166        GIT_OPT_SET_SEARCH_PATH,
2167        GIT_OPT_SET_CACHE_OBJECT_LIMIT,
2168        GIT_OPT_SET_CACHE_MAX_SIZE,
2169        GIT_OPT_ENABLE_CACHING,
2170        GIT_OPT_GET_CACHED_MEMORY,
2171        GIT_OPT_GET_TEMPLATE_PATH,
2172        GIT_OPT_SET_TEMPLATE_PATH,
2173        GIT_OPT_SET_SSL_CERT_LOCATIONS,
2174        GIT_OPT_SET_USER_AGENT,
2175        GIT_OPT_ENABLE_STRICT_OBJECT_CREATION,
2176        GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION,
2177        GIT_OPT_SET_SSL_CIPHERS,
2178        GIT_OPT_GET_USER_AGENT,
2179        GIT_OPT_ENABLE_OFS_DELTA,
2180        GIT_OPT_ENABLE_FSYNC_GITDIR,
2181        GIT_OPT_GET_WINDOWS_SHAREMODE,
2182        GIT_OPT_SET_WINDOWS_SHAREMODE,
2183        GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION,
2184        GIT_OPT_SET_ALLOCATOR,
2185        GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY,
2186        GIT_OPT_GET_PACK_MAX_OBJECTS,
2187        GIT_OPT_SET_PACK_MAX_OBJECTS,
2188        GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS,
2189        GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE,
2190        GIT_OPT_GET_MWINDOW_FILE_LIMIT,
2191        GIT_OPT_SET_MWINDOW_FILE_LIMIT,
2192        GIT_OPT_SET_ODB_PACKED_PRIORITY,
2193        GIT_OPT_SET_ODB_LOOSE_PRIORITY,
2194        GIT_OPT_GET_EXTENSIONS,
2195        GIT_OPT_SET_EXTENSIONS,
2196        GIT_OPT_GET_OWNER_VALIDATION,
2197        GIT_OPT_SET_OWNER_VALIDATION,
2198        GIT_OPT_GET_HOMEDIR,
2199        GIT_OPT_SET_HOMEDIR,
2200        GIT_OPT_SET_SERVER_CONNECT_TIMEOUT,
2201        GIT_OPT_GET_SERVER_CONNECT_TIMEOUT,
2202        GIT_OPT_SET_SERVER_TIMEOUT,
2203        GIT_OPT_GET_SERVER_TIMEOUT,
2204        GIT_OPT_SET_USER_AGENT_PRODUCT,
2205        GIT_OPT_GET_USER_AGENT_PRODUCT,
2206    }
2207}
2208
2209git_enum! {
2210    pub enum git_reference_format_t {
2211        GIT_REFERENCE_FORMAT_NORMAL = 0,
2212        GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL = 1 << 0,
2213        GIT_REFERENCE_FORMAT_REFSPEC_PATTERN = 1 << 1,
2214        GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND = 1 << 2,
2215    }
2216}
2217
2218#[repr(C)]
2219pub struct git_worktree_add_options {
2220    pub version: c_uint,
2221    pub lock: c_int,
2222    pub checkout_existing: c_int,
2223    pub reference: *mut git_reference,
2224    pub checkout_options: git_checkout_options,
2225}
2226
2227pub const GIT_WORKTREE_ADD_OPTIONS_VERSION: c_uint = 1;
2228
2229git_enum! {
2230    pub enum git_worktree_prune_t {
2231        /* Prune working tree even if working tree is valid */
2232        GIT_WORKTREE_PRUNE_VALID = 1 << 0,
2233        /* Prune working tree even if it is locked */
2234        GIT_WORKTREE_PRUNE_LOCKED = 1 << 1,
2235        /* Prune checked out working tree */
2236        GIT_WORKTREE_PRUNE_WORKING_TREE = 1 << 2,
2237    }
2238}
2239
2240#[repr(C)]
2241pub struct git_worktree_prune_options {
2242    pub version: c_uint,
2243    pub flags: u32,
2244}
2245
2246pub const GIT_WORKTREE_PRUNE_OPTIONS_VERSION: c_uint = 1;
2247
2248pub type git_repository_mergehead_foreach_cb =
2249    Option<extern "C" fn(oid: *const git_oid, payload: *mut c_void) -> c_int>;
2250
2251pub type git_repository_fetchhead_foreach_cb = Option<
2252    extern "C" fn(*const c_char, *const c_char, *const git_oid, c_uint, *mut c_void) -> c_int,
2253>;
2254
2255git_enum! {
2256    pub enum git_trace_level_t {
2257        /* No tracing will be performed. */
2258        GIT_TRACE_NONE = 0,
2259
2260        /* Severe errors that may impact the program's execution */
2261        GIT_TRACE_FATAL = 1,
2262
2263        /* Errors that do not impact the program's execution */
2264        GIT_TRACE_ERROR = 2,
2265
2266        /* Warnings that suggest abnormal data */
2267        GIT_TRACE_WARN = 3,
2268
2269        /* Informational messages about program execution */
2270        GIT_TRACE_INFO = 4,
2271
2272        /* Detailed data that allows for debugging */
2273        GIT_TRACE_DEBUG = 5,
2274
2275        /* Exceptionally detailed debugging data */
2276        GIT_TRACE_TRACE = 6,
2277    }
2278}
2279
2280pub type git_trace_cb = Option<extern "C" fn(level: git_trace_level_t, msg: *const c_char)>;
2281
2282git_enum! {
2283    pub enum git_feature_t {
2284        GIT_FEATURE_THREADS = 1 << 0,
2285        GIT_FEATURE_HTTPS   = 1 << 1,
2286        GIT_FEATURE_SSH     = 1 << 2,
2287        GIT_FEATURE_NSEC    = 1 << 3,
2288    }
2289}
2290
2291#[repr(C)]
2292pub struct git_message_trailer {
2293    pub key: *const c_char,
2294    pub value: *const c_char,
2295}
2296
2297#[repr(C)]
2298#[derive(Copy, Clone)]
2299pub struct git_message_trailer_array {
2300    pub trailers: *mut git_message_trailer,
2301    pub count: size_t,
2302    pub _trailer_block: *mut c_char,
2303}
2304
2305#[repr(C)]
2306pub struct git_email_create_options {
2307    pub version: c_uint,
2308    pub flags: u32,
2309    pub diff_opts: git_diff_options,
2310    pub diff_find_opts: git_diff_find_options,
2311    pub subject_prefix: *const c_char,
2312    pub start_number: usize,
2313    pub reroll_number: usize,
2314}
2315
2316pub const GIT_EMAIL_CREATE_OPTIONS_VERSION: c_uint = 1;
2317
2318git_enum! {
2319    pub enum git_email_create_flags_t {
2320        GIT_EMAIL_CREATE_DEFAULT = 0,
2321        GIT_EMAIL_CREATE_OMIT_NUMBERS = 1 << 0,
2322        GIT_EMAIL_CREATE_ALWAYS_NUMBER = 1 << 1,
2323        GIT_EMAIL_CREATE_NO_RENAMES = 1 << 2,
2324    }
2325}
2326
2327extern "C" {
2328    // threads
2329    pub fn git_libgit2_init() -> c_int;
2330    pub fn git_libgit2_shutdown() -> c_int;
2331
2332    // repository
2333    #[cfg(not(feature = "unstable-sha256"))]
2334    pub fn git_repository_new(out: *mut *mut git_repository) -> c_int;
2335    #[cfg(feature = "unstable-sha256")]
2336    pub fn git_repository_new(
2337        out: *mut *mut git_repository,
2338        opts: *mut git_repository_new_options,
2339    ) -> c_int;
2340    pub fn git_repository_free(repo: *mut git_repository);
2341    pub fn git_repository_open(repo: *mut *mut git_repository, path: *const c_char) -> c_int;
2342    pub fn git_repository_open_bare(repo: *mut *mut git_repository, path: *const c_char) -> c_int;
2343    pub fn git_repository_open_ext(
2344        repo: *mut *mut git_repository,
2345        path: *const c_char,
2346        flags: c_uint,
2347        ceiling_dirs: *const c_char,
2348    ) -> c_int;
2349    pub fn git_repository_open_from_worktree(
2350        repo: *mut *mut git_repository,
2351        worktree: *mut git_worktree,
2352    ) -> c_int;
2353    pub fn git_repository_wrap_odb(repo: *mut *mut git_repository, odb: *mut git_odb) -> c_int;
2354    pub fn git_repository_init(
2355        repo: *mut *mut git_repository,
2356        path: *const c_char,
2357        is_bare: c_uint,
2358    ) -> c_int;
2359    pub fn git_repository_init_ext(
2360        out: *mut *mut git_repository,
2361        repo_path: *const c_char,
2362        opts: *mut git_repository_init_options,
2363    ) -> c_int;
2364    pub fn git_repository_init_init_options(
2365        opts: *mut git_repository_init_options,
2366        version: c_uint,
2367    ) -> c_int;
2368    pub fn git_repository_get_namespace(repo: *mut git_repository) -> *const c_char;
2369    pub fn git_repository_set_namespace(
2370        repo: *mut git_repository,
2371        namespace: *const c_char,
2372    ) -> c_int;
2373    pub fn git_repository_head(out: *mut *mut git_reference, repo: *mut git_repository) -> c_int;
2374    pub fn git_repository_set_head(repo: *mut git_repository, refname: *const c_char) -> c_int;
2375
2376    pub fn git_repository_head_detached(repo: *mut git_repository) -> c_int;
2377    pub fn git_repository_set_head_detached(
2378        repo: *mut git_repository,
2379        commitish: *const git_oid,
2380    ) -> c_int;
2381    pub fn git_repository_set_head_detached_from_annotated(
2382        repo: *mut git_repository,
2383        commitish: *const git_annotated_commit,
2384    ) -> c_int;
2385    pub fn git_repository_set_bare(repo: *mut git_repository) -> c_int;
2386    pub fn git_repository_is_worktree(repo: *const git_repository) -> c_int;
2387    pub fn git_repository_is_bare(repo: *const git_repository) -> c_int;
2388    pub fn git_repository_is_empty(repo: *mut git_repository) -> c_int;
2389    pub fn git_repository_is_shallow(repo: *mut git_repository) -> c_int;
2390    pub fn git_repository_path(repo: *const git_repository) -> *const c_char;
2391    pub fn git_repository_commondir(repo: *const git_repository) -> *const c_char;
2392    pub fn git_repository_state(repo: *mut git_repository) -> c_int;
2393    pub fn git_repository_workdir(repo: *const git_repository) -> *const c_char;
2394    pub fn git_repository_set_workdir(
2395        repo: *mut git_repository,
2396        workdir: *const c_char,
2397        update_gitlink: c_int,
2398    ) -> c_int;
2399    pub fn git_repository_index(out: *mut *mut git_index, repo: *mut git_repository) -> c_int;
2400    pub fn git_repository_set_index(repo: *mut git_repository, index: *mut git_index) -> c_int;
2401
2402    pub fn git_repository_oid_type(repo: *mut git_repository) -> git_oid_t;
2403
2404    pub fn git_repository_message(buf: *mut git_buf, repo: *mut git_repository) -> c_int;
2405
2406    pub fn git_repository_message_remove(repo: *mut git_repository) -> c_int;
2407    pub fn git_repository_config(out: *mut *mut git_config, repo: *mut git_repository) -> c_int;
2408    pub fn git_repository_set_config(repo: *mut git_repository, config: *mut git_config) -> c_int;
2409    pub fn git_repository_config_snapshot(
2410        out: *mut *mut git_config,
2411        repo: *mut git_repository,
2412    ) -> c_int;
2413    pub fn git_repository_discover(
2414        out: *mut git_buf,
2415        start_path: *const c_char,
2416        across_fs: c_int,
2417        ceiling_dirs: *const c_char,
2418    ) -> c_int;
2419    pub fn git_repository_set_odb(repo: *mut git_repository, odb: *mut git_odb) -> c_int;
2420
2421    pub fn git_repository_refdb(out: *mut *mut git_refdb, repo: *mut git_repository) -> c_int;
2422    pub fn git_repository_set_refdb(repo: *mut git_repository, refdb: *mut git_refdb) -> c_int;
2423
2424    pub fn git_repository_reinit_filesystem(
2425        repo: *mut git_repository,
2426        recurse_submodules: c_int,
2427    ) -> c_int;
2428    pub fn git_repository_mergehead_foreach(
2429        repo: *mut git_repository,
2430        callback: git_repository_mergehead_foreach_cb,
2431        payload: *mut c_void,
2432    ) -> c_int;
2433    pub fn git_repository_fetchhead_foreach(
2434        repo: *mut git_repository,
2435        callback: git_repository_fetchhead_foreach_cb,
2436        payload: *mut c_void,
2437    ) -> c_int;
2438    pub fn git_ignore_add_rule(repo: *mut git_repository, rules: *const c_char) -> c_int;
2439    pub fn git_ignore_clear_internal_rules(repo: *mut git_repository) -> c_int;
2440    pub fn git_ignore_path_is_ignored(
2441        ignored: *mut c_int,
2442        repo: *mut git_repository,
2443        path: *const c_char,
2444    ) -> c_int;
2445
2446    // revparse
2447    pub fn git_revparse(
2448        revspec: *mut git_revspec,
2449        repo: *mut git_repository,
2450        spec: *const c_char,
2451    ) -> c_int;
2452    pub fn git_revparse_single(
2453        out: *mut *mut git_object,
2454        repo: *mut git_repository,
2455        spec: *const c_char,
2456    ) -> c_int;
2457    pub fn git_revparse_ext(
2458        object_out: *mut *mut git_object,
2459        reference_out: *mut *mut git_reference,
2460        repo: *mut git_repository,
2461        spec: *const c_char,
2462    ) -> c_int;
2463
2464    // object
2465    pub fn git_object_dup(dest: *mut *mut git_object, source: *mut git_object) -> c_int;
2466    #[cfg(not(feature = "unstable-sha256"))]
2467    pub fn git_object_rawcontent_is_valid(
2468        valid: *mut c_int,
2469        buf: *const c_char,
2470        len: size_t,
2471        object_type: git_object_t,
2472    ) -> c_int;
2473    #[cfg(feature = "unstable-sha256")]
2474    pub fn git_object_rawcontent_is_valid(
2475        valid: *mut c_int,
2476        buf: *const c_char,
2477        len: size_t,
2478        object_type: git_object_t,
2479        oid_type: git_oid_t,
2480    ) -> c_int;
2481    pub fn git_object_id(obj: *const git_object) -> *const git_oid;
2482    pub fn git_object_free(object: *mut git_object);
2483    pub fn git_object_lookup(
2484        dest: *mut *mut git_object,
2485        repo: *mut git_repository,
2486        id: *const git_oid,
2487        kind: git_object_t,
2488    ) -> c_int;
2489    pub fn git_object_lookup_prefix(
2490        dest: *mut *mut git_object,
2491        repo: *mut git_repository,
2492        id: *const git_oid,
2493        len: size_t,
2494        kind: git_object_t,
2495    ) -> c_int;
2496    pub fn git_object_type(obj: *const git_object) -> git_object_t;
2497    pub fn git_object_peel(
2498        peeled: *mut *mut git_object,
2499        object: *const git_object,
2500        target_type: git_object_t,
2501    ) -> c_int;
2502    pub fn git_object_short_id(out: *mut git_buf, obj: *const git_object) -> c_int;
2503    pub fn git_object_type2string(kind: git_object_t) -> *const c_char;
2504    pub fn git_object_string2type(s: *const c_char) -> git_object_t;
2505    pub fn git_object_typeisloose(kind: git_object_t) -> c_int;
2506
2507    // oid
2508    #[cfg(not(feature = "unstable-sha256"))]
2509    pub fn git_oid_fromraw(out: *mut git_oid, raw: *const c_uchar) -> c_int;
2510    #[cfg(not(feature = "unstable-sha256"))]
2511    pub fn git_oid_fromstrn(out: *mut git_oid, str: *const c_char, len: size_t) -> c_int;
2512    #[cfg(not(feature = "unstable-sha256"))]
2513    pub fn git_oid_fromstr(out: *mut git_oid, str: *const c_char) -> c_int;
2514    #[cfg(not(feature = "unstable-sha256"))]
2515    pub fn git_oid_fromstrp(out: *mut git_oid, str: *const c_char) -> c_int;
2516
2517    #[cfg(feature = "unstable-sha256")]
2518    pub fn git_oid_fromraw(out: *mut git_oid, raw: *const c_uchar, oid_type: git_oid_t) -> c_int;
2519    #[cfg(feature = "unstable-sha256")]
2520    pub fn git_oid_fromstrn(
2521        out: *mut git_oid,
2522        str: *const c_char,
2523        len: size_t,
2524        oid_type: git_oid_t,
2525    ) -> c_int;
2526    #[cfg(feature = "unstable-sha256")]
2527    pub fn git_oid_fromstr(out: *mut git_oid, str: *const c_char, oid_type: git_oid_t) -> c_int;
2528    #[cfg(feature = "unstable-sha256")]
2529    pub fn git_oid_fromstrp(out: *mut git_oid, str: *const c_char, oid_type: git_oid_t) -> c_int;
2530
2531    pub fn git_oid_tostr(out: *mut c_char, n: size_t, id: *const git_oid) -> *mut c_char;
2532    pub fn git_oid_cmp(a: *const git_oid, b: *const git_oid) -> c_int;
2533    pub fn git_oid_equal(a: *const git_oid, b: *const git_oid) -> c_int;
2534    pub fn git_oid_streq(id: *const git_oid, str: *const c_char) -> c_int;
2535    #[deprecated = "use `git_oid_is_zero`"]
2536    pub fn git_oid_iszero(id: *const git_oid) -> c_int;
2537    pub fn git_oid_is_zero(id: *const git_oid) -> c_int;
2538
2539    // error
2540    pub fn git_error_last() -> *const git_error;
2541    pub fn git_error_clear();
2542    pub fn git_error_set_str(error_class: c_int, string: *const c_char) -> c_int;
2543
2544    // remote
2545    pub fn git_remote_create(
2546        out: *mut *mut git_remote,
2547        repo: *mut git_repository,
2548        name: *const c_char,
2549        url: *const c_char,
2550    ) -> c_int;
2551    pub fn git_remote_create_with_fetchspec(
2552        out: *mut *mut git_remote,
2553        repo: *mut git_repository,
2554        name: *const c_char,
2555        url: *const c_char,
2556        fetch: *const c_char,
2557    ) -> c_int;
2558    pub fn git_remote_lookup(
2559        out: *mut *mut git_remote,
2560        repo: *mut git_repository,
2561        name: *const c_char,
2562    ) -> c_int;
2563    pub fn git_remote_create_anonymous(
2564        out: *mut *mut git_remote,
2565        repo: *mut git_repository,
2566        url: *const c_char,
2567    ) -> c_int;
2568    pub fn git_remote_create_detached(out: *mut *mut git_remote, url: *const c_char) -> c_int;
2569    pub fn git_remote_delete(repo: *mut git_repository, name: *const c_char) -> c_int;
2570    pub fn git_remote_free(remote: *mut git_remote);
2571    pub fn git_remote_name(remote: *const git_remote) -> *const c_char;
2572    pub fn git_remote_pushurl(remote: *const git_remote) -> *const c_char;
2573    pub fn git_remote_refspec_count(remote: *const git_remote) -> size_t;
2574    pub fn git_remote_url(remote: *const git_remote) -> *const c_char;
2575    pub fn git_remote_connect(
2576        remote: *mut git_remote,
2577        dir: git_direction,
2578        callbacks: *const git_remote_callbacks,
2579        proxy_opts: *const git_proxy_options,
2580        custom_headers: *const git_strarray,
2581    ) -> c_int;
2582    pub fn git_remote_connected(remote: *const git_remote) -> c_int;
2583    pub fn git_remote_disconnect(remote: *mut git_remote) -> c_int;
2584    pub fn git_remote_add_fetch(
2585        repo: *mut git_repository,
2586        remote: *const c_char,
2587        refspec: *const c_char,
2588    ) -> c_int;
2589    pub fn git_remote_add_push(
2590        repo: *mut git_repository,
2591        remote: *const c_char,
2592        refspec: *const c_char,
2593    ) -> c_int;
2594    pub fn git_remote_download(
2595        remote: *mut git_remote,
2596        refspecs: *const git_strarray,
2597        opts: *const git_fetch_options,
2598    ) -> c_int;
2599    pub fn git_remote_stop(remote: *mut git_remote) -> c_int;
2600    pub fn git_remote_dup(dest: *mut *mut git_remote, source: *mut git_remote) -> c_int;
2601    pub fn git_remote_get_fetch_refspecs(
2602        array: *mut git_strarray,
2603        remote: *const git_remote,
2604    ) -> c_int;
2605    pub fn git_remote_get_push_refspecs(
2606        array: *mut git_strarray,
2607        remote: *const git_remote,
2608    ) -> c_int;
2609    pub fn git_remote_get_refspec(remote: *const git_remote, n: size_t) -> *const git_refspec;
2610    pub fn git_remote_is_valid_name(remote_name: *const c_char) -> c_int;
2611    pub fn git_remote_name_is_valid(valid: *mut c_int, remote_name: *const c_char) -> c_int;
2612    pub fn git_remote_list(out: *mut git_strarray, repo: *mut git_repository) -> c_int;
2613    pub fn git_remote_rename(
2614        problems: *mut git_strarray,
2615        repo: *mut git_repository,
2616        name: *const c_char,
2617        new_name: *const c_char,
2618    ) -> c_int;
2619    pub fn git_remote_fetch(
2620        remote: *mut git_remote,
2621        refspecs: *const git_strarray,
2622        opts: *const git_fetch_options,
2623        reflog_message: *const c_char,
2624    ) -> c_int;
2625    pub fn git_remote_push(
2626        remote: *mut git_remote,
2627        refspecs: *const git_strarray,
2628        opts: *const git_push_options,
2629    ) -> c_int;
2630    pub fn git_remote_update_tips(
2631        remote: *mut git_remote,
2632        callbacks: *const git_remote_callbacks,
2633        update_flags: c_uint,
2634        download_tags: git_remote_autotag_option_t,
2635        reflog_message: *const c_char,
2636    ) -> c_int;
2637    pub fn git_remote_set_url(
2638        repo: *mut git_repository,
2639        remote: *const c_char,
2640        url: *const c_char,
2641    ) -> c_int;
2642    pub fn git_remote_set_pushurl(
2643        repo: *mut git_repository,
2644        remote: *const c_char,
2645        pushurl: *const c_char,
2646    ) -> c_int;
2647    pub fn git_remote_init_callbacks(opts: *mut git_remote_callbacks, version: c_uint) -> c_int;
2648    pub fn git_fetch_init_options(opts: *mut git_fetch_options, version: c_uint) -> c_int;
2649    pub fn git_remote_stats(remote: *mut git_remote) -> *const git_indexer_progress;
2650    pub fn git_remote_ls(
2651        out: *mut *mut *const git_remote_head,
2652        size: *mut size_t,
2653        remote: *mut git_remote,
2654    ) -> c_int;
2655    pub fn git_remote_oid_type(out: *mut git_oid_t, remote: *mut git_remote) -> c_int;
2656    pub fn git_remote_set_autotag(
2657        repo: *mut git_repository,
2658        remote: *const c_char,
2659        value: git_remote_autotag_option_t,
2660    ) -> c_int;
2661    pub fn git_remote_prune(
2662        remote: *mut git_remote,
2663        callbacks: *const git_remote_callbacks,
2664    ) -> c_int;
2665    pub fn git_remote_default_branch(out: *mut git_buf, remote: *mut git_remote) -> c_int;
2666
2667    // refspec
2668    pub fn git_refspec_direction(spec: *const git_refspec) -> git_direction;
2669    pub fn git_refspec_dst(spec: *const git_refspec) -> *const c_char;
2670    pub fn git_refspec_dst_matches(spec: *const git_refspec, refname: *const c_char) -> c_int;
2671    pub fn git_refspec_src(spec: *const git_refspec) -> *const c_char;
2672    pub fn git_refspec_src_matches(spec: *const git_refspec, refname: *const c_char) -> c_int;
2673    pub fn git_refspec_force(spec: *const git_refspec) -> c_int;
2674    pub fn git_refspec_string(spec: *const git_refspec) -> *const c_char;
2675    pub fn git_refspec_transform(
2676        out: *mut git_buf,
2677        spec: *const git_refspec,
2678        name: *const c_char,
2679    ) -> c_int;
2680    pub fn git_refspec_rtransform(
2681        out: *mut git_buf,
2682        spec: *const git_refspec,
2683        name: *const c_char,
2684    ) -> c_int;
2685
2686    // strarray
2687    pub fn git_strarray_free(array: *mut git_strarray);
2688
2689    // oidarray
2690    pub fn git_oidarray_free(array: *mut git_oidarray);
2691
2692    // signature
2693    pub fn git_signature_default(out: *mut *mut git_signature, repo: *mut git_repository) -> c_int;
2694    pub fn git_signature_free(sig: *mut git_signature);
2695    pub fn git_signature_new(
2696        out: *mut *mut git_signature,
2697        name: *const c_char,
2698        email: *const c_char,
2699        time: git_time_t,
2700        offset: c_int,
2701    ) -> c_int;
2702    pub fn git_signature_now(
2703        out: *mut *mut git_signature,
2704        name: *const c_char,
2705        email: *const c_char,
2706    ) -> c_int;
2707    pub fn git_signature_default_from_env(
2708        author_out: *mut *mut git_signature,
2709        committer_out: *mut *mut git_signature,
2710        repo: *mut git_repository,
2711    ) -> c_int;
2712    pub fn git_signature_dup(dest: *mut *mut git_signature, sig: *const git_signature) -> c_int;
2713
2714    // status
2715    pub fn git_status_list_new(
2716        out: *mut *mut git_status_list,
2717        repo: *mut git_repository,
2718        options: *const git_status_options,
2719    ) -> c_int;
2720    pub fn git_status_list_entrycount(list: *mut git_status_list) -> size_t;
2721    pub fn git_status_byindex(
2722        statuslist: *mut git_status_list,
2723        idx: size_t,
2724    ) -> *const git_status_entry;
2725    pub fn git_status_list_free(list: *mut git_status_list);
2726    pub fn git_status_init_options(opts: *mut git_status_options, version: c_uint) -> c_int;
2727    pub fn git_status_file(
2728        status_flags: *mut c_uint,
2729        repo: *mut git_repository,
2730        path: *const c_char,
2731    ) -> c_int;
2732    pub fn git_status_should_ignore(
2733        ignored: *mut c_int,
2734        repo: *mut git_repository,
2735        path: *const c_char,
2736    ) -> c_int;
2737
2738    // clone
2739    pub fn git_clone(
2740        out: *mut *mut git_repository,
2741        url: *const c_char,
2742        local_path: *const c_char,
2743        options: *const git_clone_options,
2744    ) -> c_int;
2745    pub fn git_clone_init_options(opts: *mut git_clone_options, version: c_uint) -> c_int;
2746
2747    // reset
2748    pub fn git_reset(
2749        repo: *mut git_repository,
2750        target: *const git_object,
2751        reset_type: git_reset_t,
2752        checkout_opts: *const git_checkout_options,
2753    ) -> c_int;
2754    pub fn git_reset_default(
2755        repo: *mut git_repository,
2756        target: *const git_object,
2757        pathspecs: *const git_strarray,
2758    ) -> c_int;
2759
2760    // reference
2761    pub fn git_reference_dup(dest: *mut *mut git_reference, src: *mut git_reference) -> c_int;
2762    pub fn git_reference_cmp(ref1: *const git_reference, ref2: *const git_reference) -> c_int;
2763    pub fn git_reference_delete(r: *mut git_reference) -> c_int;
2764    pub fn git_reference_free(r: *mut git_reference);
2765    pub fn git_reference_is_branch(r: *const git_reference) -> c_int;
2766    pub fn git_reference_is_note(r: *const git_reference) -> c_int;
2767    pub fn git_reference_is_remote(r: *const git_reference) -> c_int;
2768    pub fn git_reference_is_tag(r: *const git_reference) -> c_int;
2769    pub fn git_reference_is_valid_name(name: *const c_char) -> c_int;
2770    pub fn git_reference_name_is_valid(valid: *mut c_int, refname: *const c_char) -> c_int;
2771    pub fn git_reference_lookup(
2772        out: *mut *mut git_reference,
2773        repo: *mut git_repository,
2774        name: *const c_char,
2775    ) -> c_int;
2776    pub fn git_reference_dwim(
2777        out: *mut *mut git_reference,
2778        repo: *mut git_repository,
2779        refname: *const c_char,
2780    ) -> c_int;
2781    pub fn git_reference_name(r: *const git_reference) -> *const c_char;
2782    pub fn git_reference_name_to_id(
2783        out: *mut git_oid,
2784        repo: *mut git_repository,
2785        name: *const c_char,
2786    ) -> c_int;
2787    pub fn git_reference_peel(
2788        out: *mut *mut git_object,
2789        r: *const git_reference,
2790        otype: git_object_t,
2791    ) -> c_int;
2792    pub fn git_reference_rename(
2793        new_ref: *mut *mut git_reference,
2794        r: *mut git_reference,
2795        new_name: *const c_char,
2796        force: c_int,
2797        log_message: *const c_char,
2798    ) -> c_int;
2799    pub fn git_reference_resolve(out: *mut *mut git_reference, r: *const git_reference) -> c_int;
2800    pub fn git_reference_shorthand(r: *const git_reference) -> *const c_char;
2801    pub fn git_reference_symbolic_target(r: *const git_reference) -> *const c_char;
2802    pub fn git_reference_target(r: *const git_reference) -> *const git_oid;
2803    pub fn git_reference_target_peel(r: *const git_reference) -> *const git_oid;
2804    pub fn git_reference_set_target(
2805        out: *mut *mut git_reference,
2806        r: *mut git_reference,
2807        id: *const git_oid,
2808        log_message: *const c_char,
2809    ) -> c_int;
2810    pub fn git_reference_symbolic_set_target(
2811        out: *mut *mut git_reference,
2812        r: *mut git_reference,
2813        target: *const c_char,
2814        log_message: *const c_char,
2815    ) -> c_int;
2816    pub fn git_reference_type(r: *const git_reference) -> git_reference_t;
2817    pub fn git_reference_iterator_new(
2818        out: *mut *mut git_reference_iterator,
2819        repo: *mut git_repository,
2820    ) -> c_int;
2821    pub fn git_reference_iterator_glob_new(
2822        out: *mut *mut git_reference_iterator,
2823        repo: *mut git_repository,
2824        glob: *const c_char,
2825    ) -> c_int;
2826    pub fn git_reference_iterator_free(iter: *mut git_reference_iterator);
2827    pub fn git_reference_next(
2828        out: *mut *mut git_reference,
2829        iter: *mut git_reference_iterator,
2830    ) -> c_int;
2831    pub fn git_reference_next_name(
2832        out: *mut *const c_char,
2833        iter: *mut git_reference_iterator,
2834    ) -> c_int;
2835    pub fn git_reference_create(
2836        out: *mut *mut git_reference,
2837        repo: *mut git_repository,
2838        name: *const c_char,
2839        id: *const git_oid,
2840        force: c_int,
2841        log_message: *const c_char,
2842    ) -> c_int;
2843    pub fn git_reference_symbolic_create(
2844        out: *mut *mut git_reference,
2845        repo: *mut git_repository,
2846        name: *const c_char,
2847        target: *const c_char,
2848        force: c_int,
2849        log_message: *const c_char,
2850    ) -> c_int;
2851    pub fn git_reference_create_matching(
2852        out: *mut *mut git_reference,
2853        repo: *mut git_repository,
2854        name: *const c_char,
2855        id: *const git_oid,
2856        force: c_int,
2857        current_id: *const git_oid,
2858        log_message: *const c_char,
2859    ) -> c_int;
2860    pub fn git_reference_symbolic_create_matching(
2861        out: *mut *mut git_reference,
2862        repo: *mut git_repository,
2863        name: *const c_char,
2864        target: *const c_char,
2865        force: c_int,
2866        current_id: *const c_char,
2867        log_message: *const c_char,
2868    ) -> c_int;
2869    pub fn git_reference_has_log(repo: *mut git_repository, name: *const c_char) -> c_int;
2870    pub fn git_reference_ensure_log(repo: *mut git_repository, name: *const c_char) -> c_int;
2871    pub fn git_reference_normalize_name(
2872        buffer_out: *mut c_char,
2873        buffer_size: size_t,
2874        name: *const c_char,
2875        flags: u32,
2876    ) -> c_int;
2877
2878    // stash
2879    pub fn git_stash_save(
2880        out: *mut git_oid,
2881        repo: *mut git_repository,
2882        stasher: *const git_signature,
2883        message: *const c_char,
2884        flags: c_uint,
2885    ) -> c_int;
2886
2887    pub fn git_stash_save_options_init(opts: *mut git_stash_save_options, version: c_uint)
2888        -> c_int;
2889
2890    pub fn git_stash_save_with_opts(
2891        out: *mut git_oid,
2892        repo: *mut git_repository,
2893        options: *const git_stash_save_options,
2894    ) -> c_int;
2895
2896    pub fn git_stash_apply_init_options(
2897        opts: *mut git_stash_apply_options,
2898        version: c_uint,
2899    ) -> c_int;
2900
2901    pub fn git_stash_apply(
2902        repo: *mut git_repository,
2903        index: size_t,
2904        options: *const git_stash_apply_options,
2905    ) -> c_int;
2906
2907    pub fn git_stash_foreach(
2908        repo: *mut git_repository,
2909        callback: git_stash_cb,
2910        payload: *mut c_void,
2911    ) -> c_int;
2912
2913    pub fn git_stash_drop(repo: *mut git_repository, index: size_t) -> c_int;
2914
2915    pub fn git_stash_pop(
2916        repo: *mut git_repository,
2917        index: size_t,
2918        options: *const git_stash_apply_options,
2919    ) -> c_int;
2920
2921    // submodules
2922    pub fn git_submodule_add_finalize(submodule: *mut git_submodule) -> c_int;
2923    pub fn git_submodule_add_setup(
2924        submodule: *mut *mut git_submodule,
2925        repo: *mut git_repository,
2926        url: *const c_char,
2927        path: *const c_char,
2928        use_gitlink: c_int,
2929    ) -> c_int;
2930    pub fn git_submodule_add_to_index(submodule: *mut git_submodule, write_index: c_int) -> c_int;
2931    pub fn git_submodule_branch(submodule: *mut git_submodule) -> *const c_char;
2932    pub fn git_submodule_clone(
2933        repo: *mut *mut git_repository,
2934        submodule: *mut git_submodule,
2935        opts: *const git_submodule_update_options,
2936    ) -> c_int;
2937    pub fn git_submodule_foreach(
2938        repo: *mut git_repository,
2939        callback: git_submodule_cb,
2940        payload: *mut c_void,
2941    ) -> c_int;
2942    pub fn git_submodule_free(submodule: *mut git_submodule);
2943    pub fn git_submodule_head_id(submodule: *mut git_submodule) -> *const git_oid;
2944    pub fn git_submodule_ignore(submodule: *mut git_submodule) -> git_submodule_ignore_t;
2945    pub fn git_submodule_index_id(submodule: *mut git_submodule) -> *const git_oid;
2946    pub fn git_submodule_init(submodule: *mut git_submodule, overwrite: c_int) -> c_int;
2947    pub fn git_submodule_repo_init(
2948        repo: *mut *mut git_repository,
2949        submodule: *const git_submodule,
2950        use_gitlink: c_int,
2951    ) -> c_int;
2952    pub fn git_submodule_location(status: *mut c_uint, submodule: *mut git_submodule) -> c_int;
2953    pub fn git_submodule_lookup(
2954        out: *mut *mut git_submodule,
2955        repo: *mut git_repository,
2956        name: *const c_char,
2957    ) -> c_int;
2958    pub fn git_submodule_name(submodule: *mut git_submodule) -> *const c_char;
2959    pub fn git_submodule_open(
2960        repo: *mut *mut git_repository,
2961        submodule: *mut git_submodule,
2962    ) -> c_int;
2963    pub fn git_submodule_path(submodule: *mut git_submodule) -> *const c_char;
2964    pub fn git_submodule_reload(submodule: *mut git_submodule, force: c_int) -> c_int;
2965    pub fn git_submodule_set_ignore(
2966        repo: *mut git_repository,
2967        name: *const c_char,
2968        ignore: git_submodule_ignore_t,
2969    ) -> c_int;
2970    pub fn git_submodule_set_update(
2971        repo: *mut git_repository,
2972        name: *const c_char,
2973        update: git_submodule_update_t,
2974    ) -> c_int;
2975    pub fn git_submodule_set_url(
2976        repo: *mut git_repository,
2977        name: *const c_char,
2978        url: *const c_char,
2979    ) -> c_int;
2980    pub fn git_submodule_sync(submodule: *mut git_submodule) -> c_int;
2981    pub fn git_submodule_update_strategy(submodule: *mut git_submodule) -> git_submodule_update_t;
2982    pub fn git_submodule_update(
2983        submodule: *mut git_submodule,
2984        init: c_int,
2985        options: *mut git_submodule_update_options,
2986    ) -> c_int;
2987    pub fn git_submodule_update_init_options(
2988        options: *mut git_submodule_update_options,
2989        version: c_uint,
2990    ) -> c_int;
2991    pub fn git_submodule_url(submodule: *mut git_submodule) -> *const c_char;
2992    pub fn git_submodule_wd_id(submodule: *mut git_submodule) -> *const git_oid;
2993    pub fn git_submodule_status(
2994        status: *mut c_uint,
2995        repo: *mut git_repository,
2996        name: *const c_char,
2997        ignore: git_submodule_ignore_t,
2998    ) -> c_int;
2999    pub fn git_submodule_set_branch(
3000        repo: *mut git_repository,
3001        name: *const c_char,
3002        branch: *const c_char,
3003    ) -> c_int;
3004
3005    // blob
3006    pub fn git_blob_free(blob: *mut git_blob);
3007    pub fn git_blob_id(blob: *const git_blob) -> *const git_oid;
3008    pub fn git_blob_is_binary(blob: *const git_blob) -> c_int;
3009    pub fn git_blob_lookup(
3010        blob: *mut *mut git_blob,
3011        repo: *mut git_repository,
3012        id: *const git_oid,
3013    ) -> c_int;
3014    pub fn git_blob_lookup_prefix(
3015        blob: *mut *mut git_blob,
3016        repo: *mut git_repository,
3017        id: *const git_oid,
3018        len: size_t,
3019    ) -> c_int;
3020    pub fn git_blob_rawcontent(blob: *const git_blob) -> *const c_void;
3021    pub fn git_blob_rawsize(blob: *const git_blob) -> git_object_size_t;
3022    pub fn git_blob_create_frombuffer(
3023        id: *mut git_oid,
3024        repo: *mut git_repository,
3025        buffer: *const c_void,
3026        len: size_t,
3027    ) -> c_int;
3028    pub fn git_blob_create_fromdisk(
3029        id: *mut git_oid,
3030        repo: *mut git_repository,
3031        path: *const c_char,
3032    ) -> c_int;
3033    pub fn git_blob_create_fromworkdir(
3034        id: *mut git_oid,
3035        repo: *mut git_repository,
3036        relative_path: *const c_char,
3037    ) -> c_int;
3038    pub fn git_blob_create_fromstream(
3039        out: *mut *mut git_writestream,
3040        repo: *mut git_repository,
3041        hintpath: *const c_char,
3042    ) -> c_int;
3043    pub fn git_blob_create_fromstream_commit(
3044        id: *mut git_oid,
3045        stream: *mut git_writestream,
3046    ) -> c_int;
3047
3048    // tree
3049    pub fn git_tree_entry_byid(tree: *const git_tree, id: *const git_oid) -> *const git_tree_entry;
3050    pub fn git_tree_entry_byindex(tree: *const git_tree, idx: size_t) -> *const git_tree_entry;
3051    pub fn git_tree_entry_byname(
3052        tree: *const git_tree,
3053        filename: *const c_char,
3054    ) -> *const git_tree_entry;
3055    pub fn git_tree_entry_bypath(
3056        out: *mut *mut git_tree_entry,
3057        tree: *const git_tree,
3058        filename: *const c_char,
3059    ) -> c_int;
3060    pub fn git_tree_entry_cmp(e1: *const git_tree_entry, e2: *const git_tree_entry) -> c_int;
3061    pub fn git_tree_entry_dup(dest: *mut *mut git_tree_entry, src: *const git_tree_entry) -> c_int;
3062    pub fn git_tree_entry_filemode(entry: *const git_tree_entry) -> git_filemode_t;
3063    pub fn git_tree_entry_filemode_raw(entry: *const git_tree_entry) -> git_filemode_t;
3064    pub fn git_tree_entry_free(entry: *mut git_tree_entry);
3065    pub fn git_tree_entry_id(entry: *const git_tree_entry) -> *const git_oid;
3066    pub fn git_tree_entry_name(entry: *const git_tree_entry) -> *const c_char;
3067    pub fn git_tree_entry_to_object(
3068        out: *mut *mut git_object,
3069        repo: *mut git_repository,
3070        entry: *const git_tree_entry,
3071    ) -> c_int;
3072    pub fn git_tree_entry_type(entry: *const git_tree_entry) -> git_object_t;
3073    pub fn git_tree_entrycount(tree: *const git_tree) -> size_t;
3074    pub fn git_tree_free(tree: *mut git_tree);
3075    pub fn git_tree_id(tree: *const git_tree) -> *const git_oid;
3076    pub fn git_tree_lookup(
3077        tree: *mut *mut git_tree,
3078        repo: *mut git_repository,
3079        id: *const git_oid,
3080    ) -> c_int;
3081    pub fn git_tree_walk(
3082        tree: *const git_tree,
3083        mode: git_treewalk_mode,
3084        callback: git_treewalk_cb,
3085        payload: *mut c_void,
3086    ) -> c_int;
3087    pub fn git_tree_create_updated(
3088        out: *mut git_oid,
3089        repo: *mut git_repository,
3090        baseline: *mut git_tree,
3091        nupdates: usize,
3092        updates: *const git_tree_update,
3093    ) -> c_int;
3094
3095    // treebuilder
3096    pub fn git_treebuilder_new(
3097        out: *mut *mut git_treebuilder,
3098        repo: *mut git_repository,
3099        source: *const git_tree,
3100    ) -> c_int;
3101    pub fn git_treebuilder_clear(bld: *mut git_treebuilder) -> c_int;
3102    pub fn git_treebuilder_entrycount(bld: *mut git_treebuilder) -> size_t;
3103    pub fn git_treebuilder_free(bld: *mut git_treebuilder);
3104    pub fn git_treebuilder_get(
3105        bld: *mut git_treebuilder,
3106        filename: *const c_char,
3107    ) -> *const git_tree_entry;
3108    pub fn git_treebuilder_insert(
3109        out: *mut *const git_tree_entry,
3110        bld: *mut git_treebuilder,
3111        filename: *const c_char,
3112        id: *const git_oid,
3113        filemode: git_filemode_t,
3114    ) -> c_int;
3115    pub fn git_treebuilder_remove(bld: *mut git_treebuilder, filename: *const c_char) -> c_int;
3116    pub fn git_treebuilder_filter(
3117        bld: *mut git_treebuilder,
3118        filter: git_treebuilder_filter_cb,
3119        payload: *mut c_void,
3120    ) -> c_int;
3121    pub fn git_treebuilder_write(id: *mut git_oid, bld: *mut git_treebuilder) -> c_int;
3122
3123    // buf
3124    pub fn git_buf_dispose(buffer: *mut git_buf);
3125    pub fn git_buf_grow(buffer: *mut git_buf, target_size: size_t) -> c_int;
3126    pub fn git_buf_set(buffer: *mut git_buf, data: *const c_void, datalen: size_t) -> c_int;
3127
3128    // commit
3129    pub fn git_commit_author(commit: *const git_commit) -> *const git_signature;
3130    pub fn git_commit_author_with_mailmap(
3131        out: *mut *mut git_signature,
3132        commit: *const git_commit,
3133        mailmap: *const git_mailmap,
3134    ) -> c_int;
3135    pub fn git_commit_committer(commit: *const git_commit) -> *const git_signature;
3136    pub fn git_commit_committer_with_mailmap(
3137        out: *mut *mut git_signature,
3138        commit: *const git_commit,
3139        mailmap: *const git_mailmap,
3140    ) -> c_int;
3141    pub fn git_commit_free(commit: *mut git_commit);
3142    pub fn git_commit_id(commit: *const git_commit) -> *const git_oid;
3143    pub fn git_commit_lookup(
3144        commit: *mut *mut git_commit,
3145        repo: *mut git_repository,
3146        id: *const git_oid,
3147    ) -> c_int;
3148    pub fn git_commit_lookup_prefix(
3149        commit: *mut *mut git_commit,
3150        repo: *mut git_repository,
3151        id: *const git_oid,
3152        len: size_t,
3153    ) -> c_int;
3154    pub fn git_commit_message(commit: *const git_commit) -> *const c_char;
3155    pub fn git_commit_message_encoding(commit: *const git_commit) -> *const c_char;
3156    pub fn git_commit_message_raw(commit: *const git_commit) -> *const c_char;
3157    pub fn git_commit_nth_gen_ancestor(
3158        ancestor: *mut *mut git_commit,
3159        commit: *const git_commit,
3160        n: c_uint,
3161    ) -> c_int;
3162    pub fn git_commit_parent(
3163        out: *mut *mut git_commit,
3164        commit: *const git_commit,
3165        n: c_uint,
3166    ) -> c_int;
3167    pub fn git_commit_parent_id(commit: *const git_commit, n: c_uint) -> *const git_oid;
3168    pub fn git_commit_parentcount(commit: *const git_commit) -> c_uint;
3169    pub fn git_commit_raw_header(commit: *const git_commit) -> *const c_char;
3170    pub fn git_commit_summary(commit: *mut git_commit) -> *const c_char;
3171    pub fn git_commit_body(commit: *mut git_commit) -> *const c_char;
3172    pub fn git_commit_time(commit: *const git_commit) -> git_time_t;
3173    pub fn git_commit_time_offset(commit: *const git_commit) -> c_int;
3174    pub fn git_commit_tree(tree_out: *mut *mut git_tree, commit: *const git_commit) -> c_int;
3175    pub fn git_commit_tree_id(commit: *const git_commit) -> *const git_oid;
3176    pub fn git_commit_amend(
3177        id: *mut git_oid,
3178        commit_to_amend: *const git_commit,
3179        update_ref: *const c_char,
3180        author: *const git_signature,
3181        committer: *const git_signature,
3182        message_encoding: *const c_char,
3183        message: *const c_char,
3184        tree: *const git_tree,
3185    ) -> c_int;
3186    pub fn git_commit_create(
3187        id: *mut git_oid,
3188        repo: *mut git_repository,
3189        update_ref: *const c_char,
3190        author: *const git_signature,
3191        committer: *const git_signature,
3192        message_encoding: *const c_char,
3193        message: *const c_char,
3194        tree: *const git_tree,
3195        parent_count: size_t,
3196        parents: *mut *const git_commit,
3197    ) -> c_int;
3198    pub fn git_commit_create_buffer(
3199        out: *mut git_buf,
3200        repo: *mut git_repository,
3201        author: *const git_signature,
3202        committer: *const git_signature,
3203        message_encoding: *const c_char,
3204        message: *const c_char,
3205        tree: *const git_tree,
3206        parent_count: size_t,
3207        parents: *mut *const git_commit,
3208    ) -> c_int;
3209    pub fn git_commit_header_field(
3210        out: *mut git_buf,
3211        commit: *const git_commit,
3212        field: *const c_char,
3213    ) -> c_int;
3214    pub fn git_annotated_commit_lookup(
3215        out: *mut *mut git_annotated_commit,
3216        repo: *mut git_repository,
3217        id: *const git_oid,
3218    ) -> c_int;
3219    pub fn git_commit_create_with_signature(
3220        id: *mut git_oid,
3221        repo: *mut git_repository,
3222        commit_content: *const c_char,
3223        signature: *const c_char,
3224        signature_field: *const c_char,
3225    ) -> c_int;
3226    pub fn git_commit_extract_signature(
3227        signature: *mut git_buf,
3228        signed_data: *mut git_buf,
3229        repo: *mut git_repository,
3230        commit_id: *mut git_oid,
3231        field: *const c_char,
3232    ) -> c_int;
3233
3234    // branch
3235    pub fn git_branch_create(
3236        out: *mut *mut git_reference,
3237        repo: *mut git_repository,
3238        branch_name: *const c_char,
3239        target: *const git_commit,
3240        force: c_int,
3241    ) -> c_int;
3242    pub fn git_branch_create_from_annotated(
3243        ref_out: *mut *mut git_reference,
3244        repository: *mut git_repository,
3245        branch_name: *const c_char,
3246        commit: *const git_annotated_commit,
3247        force: c_int,
3248    ) -> c_int;
3249    pub fn git_branch_delete(branch: *mut git_reference) -> c_int;
3250    pub fn git_branch_is_head(branch: *const git_reference) -> c_int;
3251    pub fn git_branch_iterator_free(iter: *mut git_branch_iterator);
3252    pub fn git_branch_iterator_new(
3253        iter: *mut *mut git_branch_iterator,
3254        repo: *mut git_repository,
3255        list_flags: git_branch_t,
3256    ) -> c_int;
3257    pub fn git_branch_lookup(
3258        out: *mut *mut git_reference,
3259        repo: *mut git_repository,
3260        branch_name: *const c_char,
3261        branch_type: git_branch_t,
3262    ) -> c_int;
3263    pub fn git_branch_move(
3264        out: *mut *mut git_reference,
3265        branch: *mut git_reference,
3266        new_branch_name: *const c_char,
3267        force: c_int,
3268    ) -> c_int;
3269    pub fn git_branch_name(out: *mut *const c_char, branch: *const git_reference) -> c_int;
3270    pub fn git_branch_name_is_valid(valid: *mut c_int, name: *const c_char) -> c_int;
3271    pub fn git_branch_remote_name(
3272        out: *mut git_buf,
3273        repo: *mut git_repository,
3274        refname: *const c_char,
3275    ) -> c_int;
3276    pub fn git_branch_next(
3277        out: *mut *mut git_reference,
3278        out_type: *mut git_branch_t,
3279        iter: *mut git_branch_iterator,
3280    ) -> c_int;
3281    pub fn git_branch_set_upstream(
3282        branch: *mut git_reference,
3283        upstream_name: *const c_char,
3284    ) -> c_int;
3285    pub fn git_branch_upstream(out: *mut *mut git_reference, branch: *const git_reference)
3286        -> c_int;
3287    pub fn git_branch_upstream_name(
3288        out: *mut git_buf,
3289        repo: *mut git_repository,
3290        refname: *const c_char,
3291    ) -> c_int;
3292    pub fn git_branch_upstream_remote(
3293        out: *mut git_buf,
3294        repo: *mut git_repository,
3295        refname: *const c_char,
3296    ) -> c_int;
3297    pub fn git_branch_upstream_merge(
3298        out: *mut git_buf,
3299        repo: *mut git_repository,
3300        refname: *const c_char,
3301    ) -> c_int;
3302
3303    // index
3304    pub fn git_index_version(index: *mut git_index) -> c_uint;
3305    pub fn git_index_set_version(index: *mut git_index, version: c_uint) -> c_int;
3306    pub fn git_index_add(index: *mut git_index, entry: *const git_index_entry) -> c_int;
3307    pub fn git_index_add_all(
3308        index: *mut git_index,
3309        pathspec: *const git_strarray,
3310        flags: c_uint,
3311        callback: git_index_matched_path_cb,
3312        payload: *mut c_void,
3313    ) -> c_int;
3314    pub fn git_index_add_bypath(index: *mut git_index, path: *const c_char) -> c_int;
3315    pub fn git_index_add_frombuffer(
3316        index: *mut git_index,
3317        entry: *const git_index_entry,
3318        buffer: *const c_void,
3319        len: size_t,
3320    ) -> c_int;
3321    pub fn git_index_conflict_add(
3322        index: *mut git_index,
3323        ancestor_entry: *const git_index_entry,
3324        our_entry: *const git_index_entry,
3325        their_entry: *const git_index_entry,
3326    ) -> c_int;
3327    pub fn git_index_conflict_remove(index: *mut git_index, path: *const c_char) -> c_int;
3328    pub fn git_index_conflict_get(
3329        ancestor_out: *mut *const git_index_entry,
3330        our_out: *mut *const git_index_entry,
3331        their_out: *mut *const git_index_entry,
3332        index: *mut git_index,
3333        path: *const c_char,
3334    ) -> c_int;
3335    pub fn git_index_conflict_iterator_new(
3336        iter: *mut *mut git_index_conflict_iterator,
3337        index: *mut git_index,
3338    ) -> c_int;
3339    pub fn git_index_conflict_next(
3340        ancestor_out: *mut *const git_index_entry,
3341        our_out: *mut *const git_index_entry,
3342        their_out: *mut *const git_index_entry,
3343        iter: *mut git_index_conflict_iterator,
3344    ) -> c_int;
3345    pub fn git_index_conflict_iterator_free(iter: *mut git_index_conflict_iterator);
3346    pub fn git_index_clear(index: *mut git_index) -> c_int;
3347    pub fn git_index_entry_stage(entry: *const git_index_entry) -> c_int;
3348    pub fn git_index_entrycount(entry: *const git_index) -> size_t;
3349    pub fn git_index_find(at_pos: *mut size_t, index: *mut git_index, path: *const c_char)
3350        -> c_int;
3351    pub fn git_index_find_prefix(
3352        at_pos: *mut size_t,
3353        index: *mut git_index,
3354        prefix: *const c_char,
3355    ) -> c_int;
3356    pub fn git_index_free(index: *mut git_index);
3357    pub fn git_index_get_byindex(index: *mut git_index, n: size_t) -> *const git_index_entry;
3358    pub fn git_index_get_bypath(
3359        index: *mut git_index,
3360        path: *const c_char,
3361        stage: c_int,
3362    ) -> *const git_index_entry;
3363    pub fn git_index_has_conflicts(index: *const git_index) -> c_int;
3364    #[cfg(not(feature = "unstable-sha256"))]
3365    pub fn git_index_new(index: *mut *mut git_index) -> c_int;
3366    #[cfg(feature = "unstable-sha256")]
3367    pub fn git_index_new(index: *mut *mut git_index, opts: *const git_index_options) -> c_int;
3368    #[cfg(not(feature = "unstable-sha256"))]
3369    pub fn git_index_open(index: *mut *mut git_index, index_path: *const c_char) -> c_int;
3370    #[cfg(feature = "unstable-sha256")]
3371    pub fn git_index_open(
3372        index: *mut *mut git_index,
3373        index_path: *const c_char,
3374        opts: *const git_index_options,
3375    ) -> c_int;
3376    // #[cfg(feature = "unstable-sha256")]
3377    // pub fn git_index_options_init(opts: *mut git_index_options, version: c_uint) -> c_int;
3378    pub fn git_index_path(index: *const git_index) -> *const c_char;
3379    pub fn git_index_read(index: *mut git_index, force: c_int) -> c_int;
3380    pub fn git_index_read_tree(index: *mut git_index, tree: *const git_tree) -> c_int;
3381    pub fn git_index_remove(index: *mut git_index, path: *const c_char, stage: c_int) -> c_int;
3382    pub fn git_index_remove_all(
3383        index: *mut git_index,
3384        pathspec: *const git_strarray,
3385        callback: git_index_matched_path_cb,
3386        payload: *mut c_void,
3387    ) -> c_int;
3388    pub fn git_index_remove_bypath(index: *mut git_index, path: *const c_char) -> c_int;
3389    pub fn git_index_remove_directory(
3390        index: *mut git_index,
3391        dir: *const c_char,
3392        stage: c_int,
3393    ) -> c_int;
3394    pub fn git_index_update_all(
3395        index: *mut git_index,
3396        pathspec: *const git_strarray,
3397        callback: git_index_matched_path_cb,
3398        payload: *mut c_void,
3399    ) -> c_int;
3400    pub fn git_index_write(index: *mut git_index) -> c_int;
3401    pub fn git_index_write_tree(out: *mut git_oid, index: *mut git_index) -> c_int;
3402    pub fn git_index_write_tree_to(
3403        out: *mut git_oid,
3404        index: *mut git_index,
3405        repo: *mut git_repository,
3406    ) -> c_int;
3407
3408    // config
3409    pub fn git_config_add_backend(
3410        cfg: *mut git_config,
3411        file: *mut git_config_backend,
3412        level: git_config_level_t,
3413        repo: *const git_repository,
3414        force: c_int,
3415    ) -> c_int;
3416    pub fn git_config_add_file_ondisk(
3417        cfg: *mut git_config,
3418        path: *const c_char,
3419        level: git_config_level_t,
3420        repo: *const git_repository,
3421        force: c_int,
3422    ) -> c_int;
3423    pub fn git_config_delete_entry(cfg: *mut git_config, name: *const c_char) -> c_int;
3424    pub fn git_config_delete_multivar(
3425        cfg: *mut git_config,
3426        name: *const c_char,
3427        regexp: *const c_char,
3428    ) -> c_int;
3429    pub fn git_config_find_programdata(out: *mut git_buf) -> c_int;
3430    pub fn git_config_find_global(out: *mut git_buf) -> c_int;
3431    pub fn git_config_find_system(out: *mut git_buf) -> c_int;
3432    pub fn git_config_find_xdg(out: *mut git_buf) -> c_int;
3433    pub fn git_config_free(cfg: *mut git_config);
3434    pub fn git_config_get_bool(
3435        out: *mut c_int,
3436        cfg: *const git_config,
3437        name: *const c_char,
3438    ) -> c_int;
3439    pub fn git_config_get_entry(
3440        out: *mut *mut git_config_entry,
3441        cfg: *const git_config,
3442        name: *const c_char,
3443    ) -> c_int;
3444    pub fn git_config_get_int32(
3445        out: *mut i32,
3446        cfg: *const git_config,
3447        name: *const c_char,
3448    ) -> c_int;
3449    pub fn git_config_get_int64(
3450        out: *mut i64,
3451        cfg: *const git_config,
3452        name: *const c_char,
3453    ) -> c_int;
3454    pub fn git_config_get_string(
3455        out: *mut *const c_char,
3456        cfg: *const git_config,
3457        name: *const c_char,
3458    ) -> c_int;
3459    pub fn git_config_get_string_buf(
3460        out: *mut git_buf,
3461        cfg: *const git_config,
3462        name: *const c_char,
3463    ) -> c_int;
3464    pub fn git_config_get_path(
3465        out: *mut git_buf,
3466        cfg: *const git_config,
3467        name: *const c_char,
3468    ) -> c_int;
3469    pub fn git_config_init_backend(backend: *mut git_config_backend, version: c_uint) -> c_int;
3470    pub fn git_config_iterator_free(iter: *mut git_config_iterator);
3471    pub fn git_config_iterator_glob_new(
3472        out: *mut *mut git_config_iterator,
3473        cfg: *const git_config,
3474        regexp: *const c_char,
3475    ) -> c_int;
3476    pub fn git_config_iterator_new(
3477        out: *mut *mut git_config_iterator,
3478        cfg: *const git_config,
3479    ) -> c_int;
3480    pub fn git_config_new(out: *mut *mut git_config) -> c_int;
3481    pub fn git_config_next(
3482        entry: *mut *mut git_config_entry,
3483        iter: *mut git_config_iterator,
3484    ) -> c_int;
3485    pub fn git_config_open_default(out: *mut *mut git_config) -> c_int;
3486    pub fn git_config_open_global(out: *mut *mut git_config, config: *mut git_config) -> c_int;
3487    pub fn git_config_open_level(
3488        out: *mut *mut git_config,
3489        parent: *const git_config,
3490        level: git_config_level_t,
3491    ) -> c_int;
3492    pub fn git_config_open_ondisk(out: *mut *mut git_config, path: *const c_char) -> c_int;
3493    pub fn git_config_parse_bool(out: *mut c_int, value: *const c_char) -> c_int;
3494    pub fn git_config_parse_int32(out: *mut i32, value: *const c_char) -> c_int;
3495    pub fn git_config_parse_int64(out: *mut i64, value: *const c_char) -> c_int;
3496    pub fn git_config_set_bool(cfg: *mut git_config, name: *const c_char, value: c_int) -> c_int;
3497    pub fn git_config_set_int32(cfg: *mut git_config, name: *const c_char, value: i32) -> c_int;
3498    pub fn git_config_set_int64(cfg: *mut git_config, name: *const c_char, value: i64) -> c_int;
3499    pub fn git_config_set_multivar(
3500        cfg: *mut git_config,
3501        name: *const c_char,
3502        regexp: *const c_char,
3503        value: *const c_char,
3504    ) -> c_int;
3505    pub fn git_config_set_string(
3506        cfg: *mut git_config,
3507        name: *const c_char,
3508        value: *const c_char,
3509    ) -> c_int;
3510    pub fn git_config_snapshot(out: *mut *mut git_config, config: *mut git_config) -> c_int;
3511    pub fn git_config_entry_free(entry: *mut git_config_entry);
3512    pub fn git_config_multivar_iterator_new(
3513        out: *mut *mut git_config_iterator,
3514        cfg: *const git_config,
3515        name: *const c_char,
3516        regexp: *const c_char,
3517    ) -> c_int;
3518
3519    // attr
3520    pub fn git_attr_get(
3521        value_out: *mut *const c_char,
3522        repo: *mut git_repository,
3523        flags: u32,
3524        path: *const c_char,
3525        name: *const c_char,
3526    ) -> c_int;
3527    pub fn git_attr_value(value: *const c_char) -> git_attr_value_t;
3528
3529    // cred
3530    pub fn git_cred_default_new(out: *mut *mut git_cred) -> c_int;
3531    pub fn git_cred_has_username(cred: *mut git_cred) -> c_int;
3532    pub fn git_cred_ssh_custom_new(
3533        out: *mut *mut git_cred,
3534        username: *const c_char,
3535        publickey: *const c_char,
3536        publickey_len: size_t,
3537        sign_callback: git_cred_sign_callback,
3538        payload: *mut c_void,
3539    ) -> c_int;
3540    pub fn git_cred_ssh_interactive_new(
3541        out: *mut *mut git_cred,
3542        username: *const c_char,
3543        prompt_callback: git_cred_ssh_interactive_callback,
3544        payload: *mut c_void,
3545    ) -> c_int;
3546    pub fn git_cred_ssh_key_from_agent(out: *mut *mut git_cred, username: *const c_char) -> c_int;
3547    pub fn git_cred_ssh_key_new(
3548        out: *mut *mut git_cred,
3549        username: *const c_char,
3550        publickey: *const c_char,
3551        privatekey: *const c_char,
3552        passphrase: *const c_char,
3553    ) -> c_int;
3554    pub fn git_cred_ssh_key_memory_new(
3555        out: *mut *mut git_cred,
3556        username: *const c_char,
3557        publickey: *const c_char,
3558        privatekey: *const c_char,
3559        passphrase: *const c_char,
3560    ) -> c_int;
3561    pub fn git_cred_userpass(
3562        cred: *mut *mut git_cred,
3563        url: *const c_char,
3564        user_from_url: *const c_char,
3565        allowed_types: c_uint,
3566        payload: *mut c_void,
3567    ) -> c_int;
3568    pub fn git_cred_userpass_plaintext_new(
3569        out: *mut *mut git_cred,
3570        username: *const c_char,
3571        password: *const c_char,
3572    ) -> c_int;
3573    pub fn git_cred_username_new(cred: *mut *mut git_cred, username: *const c_char) -> c_int;
3574
3575    // tags
3576    pub fn git_tag_annotation_create(
3577        oid: *mut git_oid,
3578        repo: *mut git_repository,
3579        tag_name: *const c_char,
3580        target: *const git_object,
3581        tagger: *const git_signature,
3582        message: *const c_char,
3583    ) -> c_int;
3584    pub fn git_tag_create(
3585        oid: *mut git_oid,
3586        repo: *mut git_repository,
3587        tag_name: *const c_char,
3588        target: *const git_object,
3589        tagger: *const git_signature,
3590        message: *const c_char,
3591        force: c_int,
3592    ) -> c_int;
3593    pub fn git_tag_create_frombuffer(
3594        oid: *mut git_oid,
3595        repo: *mut git_repository,
3596        buffer: *const c_char,
3597        force: c_int,
3598    ) -> c_int;
3599    pub fn git_tag_create_lightweight(
3600        oid: *mut git_oid,
3601        repo: *mut git_repository,
3602        tag_name: *const c_char,
3603        target: *const git_object,
3604        force: c_int,
3605    ) -> c_int;
3606    pub fn git_tag_delete(repo: *mut git_repository, tag_name: *const c_char) -> c_int;
3607    pub fn git_tag_foreach(
3608        repo: *mut git_repository,
3609        callback: git_tag_foreach_cb,
3610        payload: *mut c_void,
3611    ) -> c_int;
3612    pub fn git_tag_free(tag: *mut git_tag);
3613    pub fn git_tag_id(tag: *const git_tag) -> *const git_oid;
3614    pub fn git_tag_list(tag_names: *mut git_strarray, repo: *mut git_repository) -> c_int;
3615    pub fn git_tag_list_match(
3616        tag_names: *mut git_strarray,
3617        pattern: *const c_char,
3618        repo: *mut git_repository,
3619    ) -> c_int;
3620    pub fn git_tag_lookup(
3621        out: *mut *mut git_tag,
3622        repo: *mut git_repository,
3623        id: *const git_oid,
3624    ) -> c_int;
3625    pub fn git_tag_lookup_prefix(
3626        out: *mut *mut git_tag,
3627        repo: *mut git_repository,
3628        id: *const git_oid,
3629        len: size_t,
3630    ) -> c_int;
3631    pub fn git_tag_message(tag: *const git_tag) -> *const c_char;
3632    pub fn git_tag_name(tag: *const git_tag) -> *const c_char;
3633    pub fn git_tag_peel(tag_target_out: *mut *mut git_object, tag: *const git_tag) -> c_int;
3634    pub fn git_tag_tagger(tag: *const git_tag) -> *const git_signature;
3635    pub fn git_tag_target(target_out: *mut *mut git_object, tag: *const git_tag) -> c_int;
3636    pub fn git_tag_target_id(tag: *const git_tag) -> *const git_oid;
3637    pub fn git_tag_target_type(tag: *const git_tag) -> git_object_t;
3638    pub fn git_tag_name_is_valid(valid: *mut c_int, tag_name: *const c_char) -> c_int;
3639
3640    // checkout
3641    pub fn git_checkout_head(repo: *mut git_repository, opts: *const git_checkout_options)
3642        -> c_int;
3643    pub fn git_checkout_index(
3644        repo: *mut git_repository,
3645        index: *mut git_index,
3646        opts: *const git_checkout_options,
3647    ) -> c_int;
3648    pub fn git_checkout_tree(
3649        repo: *mut git_repository,
3650        treeish: *const git_object,
3651        opts: *const git_checkout_options,
3652    ) -> c_int;
3653    pub fn git_checkout_init_options(opts: *mut git_checkout_options, version: c_uint) -> c_int;
3654
3655    // merge
3656    pub fn git_annotated_commit_id(commit: *const git_annotated_commit) -> *const git_oid;
3657    pub fn git_annotated_commit_ref(commit: *const git_annotated_commit) -> *const c_char;
3658    pub fn git_annotated_commit_from_ref(
3659        out: *mut *mut git_annotated_commit,
3660        repo: *mut git_repository,
3661        reference: *const git_reference,
3662    ) -> c_int;
3663    pub fn git_annotated_commit_from_fetchhead(
3664        out: *mut *mut git_annotated_commit,
3665        repo: *mut git_repository,
3666        branch_name: *const c_char,
3667        remote_url: *const c_char,
3668        oid: *const git_oid,
3669    ) -> c_int;
3670    pub fn git_annotated_commit_free(commit: *mut git_annotated_commit);
3671    pub fn git_merge_init_options(opts: *mut git_merge_options, version: c_uint) -> c_int;
3672    pub fn git_merge(
3673        repo: *mut git_repository,
3674        their_heads: *mut *const git_annotated_commit,
3675        len: size_t,
3676        merge_opts: *const git_merge_options,
3677        checkout_opts: *const git_checkout_options,
3678    ) -> c_int;
3679    pub fn git_merge_commits(
3680        out: *mut *mut git_index,
3681        repo: *mut git_repository,
3682        our_commit: *const git_commit,
3683        their_commit: *const git_commit,
3684        opts: *const git_merge_options,
3685    ) -> c_int;
3686    pub fn git_merge_trees(
3687        out: *mut *mut git_index,
3688        repo: *mut git_repository,
3689        ancestor_tree: *const git_tree,
3690        our_tree: *const git_tree,
3691        their_tree: *const git_tree,
3692        opts: *const git_merge_options,
3693    ) -> c_int;
3694    pub fn git_merge_file_input_init(opts: *mut git_merge_file_input, version: c_uint) -> c_int;
3695    pub fn git_merge_file_options_init(opts: *mut git_merge_file_options, version: c_uint)
3696        -> c_int;
3697    pub fn git_repository_state_cleanup(repo: *mut git_repository) -> c_int;
3698
3699    // merge analysis
3700
3701    pub fn git_merge_analysis(
3702        analysis_out: *mut git_merge_analysis_t,
3703        pref_out: *mut git_merge_preference_t,
3704        repo: *mut git_repository,
3705        their_heads: *mut *const git_annotated_commit,
3706        their_heads_len: usize,
3707    ) -> c_int;
3708
3709    pub fn git_merge_analysis_for_ref(
3710        analysis_out: *mut git_merge_analysis_t,
3711        pref_out: *mut git_merge_preference_t,
3712        repo: *mut git_repository,
3713        git_reference: *mut git_reference,
3714        their_heads: *mut *const git_annotated_commit,
3715        their_heads_len: usize,
3716    ) -> c_int;
3717
3718    // notes
3719    pub fn git_note_author(note: *const git_note) -> *const git_signature;
3720    pub fn git_note_committer(note: *const git_note) -> *const git_signature;
3721    pub fn git_note_create(
3722        out: *mut git_oid,
3723        repo: *mut git_repository,
3724        notes_ref: *const c_char,
3725        author: *const git_signature,
3726        committer: *const git_signature,
3727        oid: *const git_oid,
3728        note: *const c_char,
3729        force: c_int,
3730    ) -> c_int;
3731    pub fn git_note_default_ref(out: *mut git_buf, repo: *mut git_repository) -> c_int;
3732    pub fn git_note_free(note: *mut git_note);
3733    pub fn git_note_id(note: *const git_note) -> *const git_oid;
3734    pub fn git_note_iterator_free(it: *mut git_note_iterator);
3735    pub fn git_note_iterator_new(
3736        out: *mut *mut git_note_iterator,
3737        repo: *mut git_repository,
3738        notes_ref: *const c_char,
3739    ) -> c_int;
3740    pub fn git_note_message(note: *const git_note) -> *const c_char;
3741    pub fn git_note_next(
3742        note_id: *mut git_oid,
3743        annotated_id: *mut git_oid,
3744        it: *mut git_note_iterator,
3745    ) -> c_int;
3746    pub fn git_note_read(
3747        out: *mut *mut git_note,
3748        repo: *mut git_repository,
3749        notes_ref: *const c_char,
3750        oid: *const git_oid,
3751    ) -> c_int;
3752    pub fn git_note_remove(
3753        repo: *mut git_repository,
3754        notes_ref: *const c_char,
3755        author: *const git_signature,
3756        committer: *const git_signature,
3757        oid: *const git_oid,
3758    ) -> c_int;
3759
3760    // blame
3761    pub fn git_blame_buffer(
3762        out: *mut *mut git_blame,
3763        reference: *mut git_blame,
3764        buffer: *const c_char,
3765        buffer_len: size_t,
3766    ) -> c_int;
3767    pub fn git_blame_file(
3768        out: *mut *mut git_blame,
3769        repo: *mut git_repository,
3770        path: *const c_char,
3771        options: *mut git_blame_options,
3772    ) -> c_int;
3773    pub fn git_blame_free(blame: *mut git_blame);
3774
3775    pub fn git_blame_init_options(opts: *mut git_blame_options, version: c_uint) -> c_int;
3776    pub fn git_blame_get_hunk_count(blame: *mut git_blame) -> u32;
3777
3778    pub fn git_blame_get_hunk_byline(blame: *mut git_blame, lineno: usize)
3779        -> *const git_blame_hunk;
3780    pub fn git_blame_get_hunk_byindex(blame: *mut git_blame, index: u32) -> *const git_blame_hunk;
3781
3782    // revwalk
3783    pub fn git_revwalk_new(out: *mut *mut git_revwalk, repo: *mut git_repository) -> c_int;
3784    pub fn git_revwalk_free(walk: *mut git_revwalk);
3785
3786    pub fn git_revwalk_reset(walk: *mut git_revwalk) -> c_int;
3787
3788    pub fn git_revwalk_sorting(walk: *mut git_revwalk, sort_mode: c_uint) -> c_int;
3789
3790    pub fn git_revwalk_push_head(walk: *mut git_revwalk) -> c_int;
3791    pub fn git_revwalk_push(walk: *mut git_revwalk, oid: *const git_oid) -> c_int;
3792    pub fn git_revwalk_push_ref(walk: *mut git_revwalk, refname: *const c_char) -> c_int;
3793    pub fn git_revwalk_push_glob(walk: *mut git_revwalk, glob: *const c_char) -> c_int;
3794    pub fn git_revwalk_push_range(walk: *mut git_revwalk, range: *const c_char) -> c_int;
3795    pub fn git_revwalk_simplify_first_parent(walk: *mut git_revwalk) -> c_int;
3796
3797    pub fn git_revwalk_hide_head(walk: *mut git_revwalk) -> c_int;
3798    pub fn git_revwalk_hide(walk: *mut git_revwalk, oid: *const git_oid) -> c_int;
3799    pub fn git_revwalk_hide_ref(walk: *mut git_revwalk, refname: *const c_char) -> c_int;
3800    pub fn git_revwalk_hide_glob(walk: *mut git_revwalk, refname: *const c_char) -> c_int;
3801    pub fn git_revwalk_add_hide_cb(
3802        walk: *mut git_revwalk,
3803        hide_cb: git_revwalk_hide_cb,
3804        payload: *mut c_void,
3805    ) -> c_int;
3806
3807    pub fn git_revwalk_next(out: *mut git_oid, walk: *mut git_revwalk) -> c_int;
3808
3809    // merge
3810    pub fn git_merge_base(
3811        out: *mut git_oid,
3812        repo: *mut git_repository,
3813        one: *const git_oid,
3814        two: *const git_oid,
3815    ) -> c_int;
3816
3817    pub fn git_merge_base_many(
3818        out: *mut git_oid,
3819        repo: *mut git_repository,
3820        length: size_t,
3821        input_array: *const git_oid,
3822    ) -> c_int;
3823
3824    pub fn git_merge_base_octopus(
3825        out: *mut git_oid,
3826        repo: *mut git_repository,
3827        length: size_t,
3828        input_array: *const git_oid,
3829    ) -> c_int;
3830
3831    pub fn git_merge_bases(
3832        out: *mut git_oidarray,
3833        repo: *mut git_repository,
3834        one: *const git_oid,
3835        two: *const git_oid,
3836    ) -> c_int;
3837
3838    pub fn git_merge_bases_many(
3839        out: *mut git_oidarray,
3840        repo: *mut git_repository,
3841        length: size_t,
3842        input_array: *const git_oid,
3843    ) -> c_int;
3844
3845    pub fn git_merge_file_from_index(
3846        out: *mut git_merge_file_result,
3847        repo: *mut git_repository,
3848        ancestor: *const git_index_entry,
3849        ours: *const git_index_entry,
3850        theirs: *const git_index_entry,
3851        opts: *const git_merge_file_options,
3852    ) -> c_int;
3853
3854    pub fn git_merge_file(
3855        out: *mut git_merge_file_result,
3856        ancestor: *const git_merge_file_input,
3857        ours: *const git_merge_file_input,
3858        theirs: *const git_merge_file_input,
3859        opts: *const git_merge_file_options,
3860    ) -> c_int;
3861
3862    pub fn git_merge_file_result_free(file_result: *mut git_merge_file_result);
3863
3864    // pathspec
3865    pub fn git_pathspec_free(ps: *mut git_pathspec);
3866    pub fn git_pathspec_match_diff(
3867        out: *mut *mut git_pathspec_match_list,
3868        diff: *mut git_diff,
3869        flags: u32,
3870        ps: *mut git_pathspec,
3871    ) -> c_int;
3872    pub fn git_pathspec_match_index(
3873        out: *mut *mut git_pathspec_match_list,
3874        index: *mut git_index,
3875        flags: u32,
3876        ps: *mut git_pathspec,
3877    ) -> c_int;
3878    pub fn git_pathspec_match_list_diff_entry(
3879        m: *const git_pathspec_match_list,
3880        pos: size_t,
3881    ) -> *const git_diff_delta;
3882    pub fn git_pathspec_match_list_entry(
3883        m: *const git_pathspec_match_list,
3884        pos: size_t,
3885    ) -> *const c_char;
3886    pub fn git_pathspec_match_list_entrycount(m: *const git_pathspec_match_list) -> size_t;
3887    pub fn git_pathspec_match_list_failed_entry(
3888        m: *const git_pathspec_match_list,
3889        pos: size_t,
3890    ) -> *const c_char;
3891    pub fn git_pathspec_match_list_failed_entrycount(m: *const git_pathspec_match_list) -> size_t;
3892    pub fn git_pathspec_match_list_free(m: *mut git_pathspec_match_list);
3893    pub fn git_pathspec_match_tree(
3894        out: *mut *mut git_pathspec_match_list,
3895        tree: *mut git_tree,
3896        flags: u32,
3897        ps: *mut git_pathspec,
3898    ) -> c_int;
3899    pub fn git_pathspec_match_workdir(
3900        out: *mut *mut git_pathspec_match_list,
3901        repo: *mut git_repository,
3902        flags: u32,
3903        ps: *mut git_pathspec,
3904    ) -> c_int;
3905    pub fn git_pathspec_matches_path(
3906        ps: *const git_pathspec,
3907        flags: u32,
3908        path: *const c_char,
3909    ) -> c_int;
3910    pub fn git_pathspec_new(out: *mut *mut git_pathspec, pathspec: *const git_strarray) -> c_int;
3911
3912    // diff
3913    pub fn git_diff_blob_to_buffer(
3914        old_blob: *const git_blob,
3915        old_as_path: *const c_char,
3916        buffer: *const c_char,
3917        buffer_len: size_t,
3918        buffer_as_path: *const c_char,
3919        options: *const git_diff_options,
3920        file_cb: git_diff_file_cb,
3921        binary_cb: git_diff_binary_cb,
3922        hunk_cb: git_diff_hunk_cb,
3923        line_cb: git_diff_line_cb,
3924        payload: *mut c_void,
3925    ) -> c_int;
3926    pub fn git_diff_blobs(
3927        old_blob: *const git_blob,
3928        old_as_path: *const c_char,
3929        new_blob: *const git_blob,
3930        new_as_path: *const c_char,
3931        options: *const git_diff_options,
3932        file_cb: git_diff_file_cb,
3933        binary_cb: git_diff_binary_cb,
3934        hunk_cb: git_diff_hunk_cb,
3935        line_cb: git_diff_line_cb,
3936        payload: *mut c_void,
3937    ) -> c_int;
3938    pub fn git_diff_buffers(
3939        old_buffer: *const c_void,
3940        old_len: size_t,
3941        old_as_path: *const c_char,
3942        new_buffer: *const c_void,
3943        new_len: size_t,
3944        new_as_path: *const c_char,
3945        options: *const git_diff_options,
3946        file_cb: git_diff_file_cb,
3947        binary_cb: git_diff_binary_cb,
3948        hunk_cb: git_diff_hunk_cb,
3949        line_cb: git_diff_line_cb,
3950        payload: *mut c_void,
3951    ) -> c_int;
3952    #[cfg(not(feature = "unstable-sha256"))]
3953    pub fn git_diff_from_buffer(
3954        diff: *mut *mut git_diff,
3955        content: *const c_char,
3956        content_len: size_t,
3957    ) -> c_int;
3958    #[cfg(feature = "unstable-sha256")]
3959    pub fn git_diff_from_buffer(
3960        diff: *mut *mut git_diff,
3961        content: *const c_char,
3962        content_len: size_t,
3963        opts: *mut git_diff_parse_options,
3964    ) -> c_int;
3965    pub fn git_diff_find_similar(
3966        diff: *mut git_diff,
3967        options: *const git_diff_find_options,
3968    ) -> c_int;
3969    pub fn git_diff_find_init_options(opts: *mut git_diff_find_options, version: c_uint) -> c_int;
3970    pub fn git_diff_foreach(
3971        diff: *mut git_diff,
3972        file_cb: git_diff_file_cb,
3973        binary_cb: git_diff_binary_cb,
3974        hunk_cb: git_diff_hunk_cb,
3975        line_cb: git_diff_line_cb,
3976        payload: *mut c_void,
3977    ) -> c_int;
3978    pub fn git_diff_free(diff: *mut git_diff);
3979    pub fn git_diff_get_delta(diff: *const git_diff, idx: size_t) -> *const git_diff_delta;
3980    pub fn git_diff_get_stats(out: *mut *mut git_diff_stats, diff: *mut git_diff) -> c_int;
3981    pub fn git_diff_index_to_index(
3982        diff: *mut *mut git_diff,
3983        repo: *mut git_repository,
3984        old_index: *mut git_index,
3985        new_index: *mut git_index,
3986        opts: *const git_diff_options,
3987    ) -> c_int;
3988    pub fn git_diff_index_to_workdir(
3989        diff: *mut *mut git_diff,
3990        repo: *mut git_repository,
3991        index: *mut git_index,
3992        opts: *const git_diff_options,
3993    ) -> c_int;
3994    pub fn git_diff_init_options(opts: *mut git_diff_options, version: c_uint) -> c_int;
3995    pub fn git_diff_is_sorted_icase(diff: *const git_diff) -> c_int;
3996    pub fn git_diff_merge(onto: *mut git_diff, from: *const git_diff) -> c_int;
3997    pub fn git_diff_num_deltas(diff: *const git_diff) -> size_t;
3998    pub fn git_diff_num_deltas_of_type(diff: *const git_diff, delta: git_delta_t) -> size_t;
3999    pub fn git_diff_print(
4000        diff: *mut git_diff,
4001        format: git_diff_format_t,
4002        print_cb: git_diff_line_cb,
4003        payload: *mut c_void,
4004    ) -> c_int;
4005    pub fn git_diff_stats_deletions(stats: *const git_diff_stats) -> size_t;
4006    pub fn git_diff_stats_files_changed(stats: *const git_diff_stats) -> size_t;
4007    pub fn git_diff_stats_free(stats: *mut git_diff_stats);
4008    pub fn git_diff_stats_insertions(stats: *const git_diff_stats) -> size_t;
4009    pub fn git_diff_stats_to_buf(
4010        out: *mut git_buf,
4011        stats: *const git_diff_stats,
4012        format: git_diff_stats_format_t,
4013        width: size_t,
4014    ) -> c_int;
4015    pub fn git_diff_status_char(status: git_delta_t) -> c_char;
4016    pub fn git_diff_tree_to_index(
4017        diff: *mut *mut git_diff,
4018        repo: *mut git_repository,
4019        old_tree: *mut git_tree,
4020        index: *mut git_index,
4021        opts: *const git_diff_options,
4022    ) -> c_int;
4023    pub fn git_diff_tree_to_tree(
4024        diff: *mut *mut git_diff,
4025        repo: *mut git_repository,
4026        old_tree: *mut git_tree,
4027        new_tree: *mut git_tree,
4028        opts: *const git_diff_options,
4029    ) -> c_int;
4030    pub fn git_diff_tree_to_workdir(
4031        diff: *mut *mut git_diff,
4032        repo: *mut git_repository,
4033        old_tree: *mut git_tree,
4034        opts: *const git_diff_options,
4035    ) -> c_int;
4036    pub fn git_diff_tree_to_workdir_with_index(
4037        diff: *mut *mut git_diff,
4038        repo: *mut git_repository,
4039        old_tree: *mut git_tree,
4040        opts: *const git_diff_options,
4041    ) -> c_int;
4042
4043    pub fn git_graph_ahead_behind(
4044        ahead: *mut size_t,
4045        behind: *mut size_t,
4046        repo: *mut git_repository,
4047        local: *const git_oid,
4048        upstream: *const git_oid,
4049    ) -> c_int;
4050
4051    pub fn git_graph_descendant_of(
4052        repo: *mut git_repository,
4053        commit: *const git_oid,
4054        ancestor: *const git_oid,
4055    ) -> c_int;
4056
4057    pub fn git_diff_format_email(
4058        out: *mut git_buf,
4059        diff: *mut git_diff,
4060        opts: *const git_diff_format_email_options,
4061    ) -> c_int;
4062    pub fn git_diff_format_email_options_init(
4063        opts: *mut git_diff_format_email_options,
4064        version: c_uint,
4065    ) -> c_int;
4066
4067    pub fn git_diff_patchid(
4068        out: *mut git_oid,
4069        diff: *mut git_diff,
4070        opts: *mut git_diff_patchid_options,
4071    ) -> c_int;
4072    pub fn git_diff_patchid_options_init(
4073        opts: *mut git_diff_patchid_options,
4074        version: c_uint,
4075    ) -> c_int;
4076
4077    // patch
4078    pub fn git_patch_from_diff(out: *mut *mut git_patch, diff: *mut git_diff, idx: size_t)
4079        -> c_int;
4080    pub fn git_patch_from_blobs(
4081        out: *mut *mut git_patch,
4082        old_blob: *const git_blob,
4083        old_as_path: *const c_char,
4084        new_blob: *const git_blob,
4085        new_as_path: *const c_char,
4086        opts: *const git_diff_options,
4087    ) -> c_int;
4088    pub fn git_patch_from_blob_and_buffer(
4089        out: *mut *mut git_patch,
4090        old_blob: *const git_blob,
4091        old_as_path: *const c_char,
4092        buffer: *const c_void,
4093        buffer_len: size_t,
4094        buffer_as_path: *const c_char,
4095        opts: *const git_diff_options,
4096    ) -> c_int;
4097    pub fn git_patch_from_buffers(
4098        out: *mut *mut git_patch,
4099        old_buffer: *const c_void,
4100        old_len: size_t,
4101        old_as_path: *const c_char,
4102        new_buffer: *const c_void,
4103        new_len: size_t,
4104        new_as_path: *const c_char,
4105        opts: *const git_diff_options,
4106    ) -> c_int;
4107    pub fn git_patch_free(patch: *mut git_patch);
4108    pub fn git_patch_get_delta(patch: *const git_patch) -> *const git_diff_delta;
4109    pub fn git_patch_num_hunks(patch: *const git_patch) -> size_t;
4110    pub fn git_patch_line_stats(
4111        total_context: *mut size_t,
4112        total_additions: *mut size_t,
4113        total_deletions: *mut size_t,
4114        patch: *const git_patch,
4115    ) -> c_int;
4116    pub fn git_patch_get_hunk(
4117        out: *mut *const git_diff_hunk,
4118        lines_in_hunk: *mut size_t,
4119        patch: *mut git_patch,
4120        hunk_idx: size_t,
4121    ) -> c_int;
4122    pub fn git_patch_num_lines_in_hunk(patch: *const git_patch, hunk_idx: size_t) -> c_int;
4123    pub fn git_patch_get_line_in_hunk(
4124        out: *mut *const git_diff_line,
4125        patch: *mut git_patch,
4126        hunk_idx: size_t,
4127        line_of_hunk: size_t,
4128    ) -> c_int;
4129    pub fn git_patch_size(
4130        patch: *mut git_patch,
4131        include_context: c_int,
4132        include_hunk_headers: c_int,
4133        include_file_headers: c_int,
4134    ) -> size_t;
4135    pub fn git_patch_print(
4136        patch: *mut git_patch,
4137        print_cb: git_diff_line_cb,
4138        payload: *mut c_void,
4139    ) -> c_int;
4140    pub fn git_patch_to_buf(buf: *mut git_buf, patch: *mut git_patch) -> c_int;
4141
4142    // reflog
4143    pub fn git_reflog_append(
4144        reflog: *mut git_reflog,
4145        id: *const git_oid,
4146        committer: *const git_signature,
4147        msg: *const c_char,
4148    ) -> c_int;
4149    pub fn git_reflog_delete(repo: *mut git_repository, name: *const c_char) -> c_int;
4150    pub fn git_reflog_drop(
4151        reflog: *mut git_reflog,
4152        idx: size_t,
4153        rewrite_previous_entry: c_int,
4154    ) -> c_int;
4155    pub fn git_reflog_entry_byindex(
4156        reflog: *const git_reflog,
4157        idx: size_t,
4158    ) -> *const git_reflog_entry;
4159    pub fn git_reflog_entry_committer(entry: *const git_reflog_entry) -> *const git_signature;
4160    pub fn git_reflog_entry_id_new(entry: *const git_reflog_entry) -> *const git_oid;
4161    pub fn git_reflog_entry_id_old(entry: *const git_reflog_entry) -> *const git_oid;
4162    pub fn git_reflog_entry_message(entry: *const git_reflog_entry) -> *const c_char;
4163    pub fn git_reflog_entrycount(reflog: *mut git_reflog) -> size_t;
4164    pub fn git_reflog_free(reflog: *mut git_reflog);
4165    pub fn git_reflog_read(
4166        out: *mut *mut git_reflog,
4167        repo: *mut git_repository,
4168        name: *const c_char,
4169    ) -> c_int;
4170    pub fn git_reflog_rename(
4171        repo: *mut git_repository,
4172        old_name: *const c_char,
4173        name: *const c_char,
4174    ) -> c_int;
4175    pub fn git_reflog_write(reflog: *mut git_reflog) -> c_int;
4176
4177    // transport
4178    pub fn git_transport_register(
4179        prefix: *const c_char,
4180        cb: git_transport_cb,
4181        param: *mut c_void,
4182    ) -> c_int;
4183    pub fn git_transport_unregister(prefix: *const c_char) -> c_int;
4184    pub fn git_transport_smart(
4185        out: *mut *mut git_transport,
4186        owner: *mut git_remote,
4187        payload: *mut c_void,
4188    ) -> c_int;
4189
4190    // describe
4191    pub fn git_describe_commit(
4192        result: *mut *mut git_describe_result,
4193        object: *mut git_object,
4194        opts: *mut git_describe_options,
4195    ) -> c_int;
4196    pub fn git_describe_format(
4197        buf: *mut git_buf,
4198        result: *const git_describe_result,
4199        opts: *const git_describe_format_options,
4200    ) -> c_int;
4201    pub fn git_describe_result_free(result: *mut git_describe_result);
4202    pub fn git_describe_workdir(
4203        out: *mut *mut git_describe_result,
4204        repo: *mut git_repository,
4205        opts: *mut git_describe_options,
4206    ) -> c_int;
4207
4208    // message
4209    pub fn git_message_prettify(
4210        out: *mut git_buf,
4211        message: *const c_char,
4212        strip_comments: c_int,
4213        comment_char: c_char,
4214    ) -> c_int;
4215
4216    pub fn git_message_trailers(
4217        out: *mut git_message_trailer_array,
4218        message: *const c_char,
4219    ) -> c_int;
4220
4221    pub fn git_message_trailer_array_free(trailer: *mut git_message_trailer_array);
4222
4223    // packbuilder
4224    pub fn git_packbuilder_new(out: *mut *mut git_packbuilder, repo: *mut git_repository) -> c_int;
4225    pub fn git_packbuilder_set_threads(pb: *mut git_packbuilder, n: c_uint) -> c_uint;
4226    pub fn git_packbuilder_insert(
4227        pb: *mut git_packbuilder,
4228        id: *const git_oid,
4229        name: *const c_char,
4230    ) -> c_int;
4231    pub fn git_packbuilder_insert_tree(pb: *mut git_packbuilder, id: *const git_oid) -> c_int;
4232    pub fn git_packbuilder_insert_commit(pb: *mut git_packbuilder, id: *const git_oid) -> c_int;
4233    pub fn git_packbuilder_insert_walk(pb: *mut git_packbuilder, walk: *mut git_revwalk) -> c_int;
4234    pub fn git_packbuilder_insert_recur(
4235        pb: *mut git_packbuilder,
4236        id: *const git_oid,
4237        name: *const c_char,
4238    ) -> c_int;
4239    pub fn git_packbuilder_write_buf(buf: *mut git_buf, pb: *mut git_packbuilder) -> c_int;
4240    pub fn git_packbuilder_write(
4241        pb: *mut git_packbuilder,
4242        path: *const c_char,
4243        mode: c_uint,
4244        progress_cb: git_indexer_progress_cb,
4245        progress_cb_payload: *mut c_void,
4246    ) -> c_int;
4247    #[deprecated = "use `git_packbuilder_name` to retrieve the filename"]
4248    pub fn git_packbuilder_hash(pb: *mut git_packbuilder) -> *const git_oid;
4249    pub fn git_packbuilder_name(pb: *mut git_packbuilder) -> *const c_char;
4250    pub fn git_packbuilder_foreach(
4251        pb: *mut git_packbuilder,
4252        cb: git_packbuilder_foreach_cb,
4253        payload: *mut c_void,
4254    ) -> c_int;
4255    pub fn git_packbuilder_object_count(pb: *mut git_packbuilder) -> size_t;
4256    pub fn git_packbuilder_written(pb: *mut git_packbuilder) -> size_t;
4257    pub fn git_packbuilder_set_callbacks(
4258        pb: *mut git_packbuilder,
4259        progress_cb: git_packbuilder_progress,
4260        progress_cb_payload: *mut c_void,
4261    ) -> c_int;
4262    pub fn git_packbuilder_free(pb: *mut git_packbuilder);
4263
4264    // indexer
4265    #[cfg(not(feature = "unstable-sha256"))]
4266    pub fn git_indexer_new(
4267        out: *mut *mut git_indexer,
4268        path: *const c_char,
4269        mode: c_uint,
4270        odb: *mut git_odb,
4271        opts: *mut git_indexer_options,
4272    ) -> c_int;
4273    #[cfg(feature = "unstable-sha256")]
4274    pub fn git_indexer_new(
4275        out: *mut *mut git_indexer,
4276        path: *const c_char,
4277        opts: *mut git_indexer_options,
4278    ) -> c_int;
4279    pub fn git_indexer_append(
4280        idx: *mut git_indexer,
4281        data: *const c_void,
4282        size: size_t,
4283        stats: *mut git_indexer_progress,
4284    ) -> c_int;
4285    pub fn git_indexer_commit(idx: *mut git_indexer, stats: *mut git_indexer_progress) -> c_int;
4286    #[deprecated = "use `git_indexer_name` to retrieve the filename"]
4287    pub fn git_indexer_hash(idx: *const git_indexer) -> *const git_oid;
4288    pub fn git_indexer_name(idx: *const git_indexer) -> *const c_char;
4289    pub fn git_indexer_free(idx: *mut git_indexer);
4290
4291    pub fn git_indexer_options_init(opts: *mut git_indexer_options, version: c_uint) -> c_int;
4292
4293    // odb
4294    pub fn git_repository_odb(out: *mut *mut git_odb, repo: *mut git_repository) -> c_int;
4295    #[cfg(not(feature = "unstable-sha256"))]
4296    pub fn git_odb_new(db: *mut *mut git_odb) -> c_int;
4297    #[cfg(feature = "unstable-sha256")]
4298    pub fn git_odb_new(db: *mut *mut git_odb, opts: *const git_odb_options) -> c_int;
4299    #[cfg(not(feature = "unstable-sha256"))]
4300    pub fn git_odb_open(out: *mut *mut git_odb, objects_dir: *const c_char) -> c_int;
4301    #[cfg(feature = "unstable-sha256")]
4302    pub fn git_odb_open(
4303        out: *mut *mut git_odb,
4304        objects_dir: *const c_char,
4305        opts: *const git_odb_options,
4306    ) -> c_int;
4307    pub fn git_odb_free(db: *mut git_odb);
4308    pub fn git_odb_open_rstream(
4309        out: *mut *mut git_odb_stream,
4310        len: *mut size_t,
4311        otype: *mut git_object_t,
4312        db: *mut git_odb,
4313        oid: *const git_oid,
4314    ) -> c_int;
4315    pub fn git_odb_stream_read(
4316        stream: *mut git_odb_stream,
4317        buffer: *mut c_char,
4318        len: size_t,
4319    ) -> c_int;
4320    pub fn git_odb_open_wstream(
4321        out: *mut *mut git_odb_stream,
4322        db: *mut git_odb,
4323        size: git_object_size_t,
4324        obj_type: git_object_t,
4325    ) -> c_int;
4326    pub fn git_odb_stream_write(
4327        stream: *mut git_odb_stream,
4328        buffer: *const c_char,
4329        len: size_t,
4330    ) -> c_int;
4331    pub fn git_odb_stream_finalize_write(id: *mut git_oid, stream: *mut git_odb_stream) -> c_int;
4332    pub fn git_odb_stream_free(stream: *mut git_odb_stream);
4333    pub fn git_odb_foreach(db: *mut git_odb, cb: git_odb_foreach_cb, payload: *mut c_void)
4334        -> c_int;
4335
4336    pub fn git_odb_read(
4337        out: *mut *mut git_odb_object,
4338        odb: *mut git_odb,
4339        oid: *const git_oid,
4340    ) -> c_int;
4341
4342    pub fn git_odb_read_header(
4343        len_out: *mut size_t,
4344        type_out: *mut git_object_t,
4345        odb: *mut git_odb,
4346        oid: *const git_oid,
4347    ) -> c_int;
4348
4349    pub fn git_odb_write(
4350        out: *mut git_oid,
4351        odb: *mut git_odb,
4352        data: *const c_void,
4353        len: size_t,
4354        otype: git_object_t,
4355    ) -> c_int;
4356
4357    pub fn git_odb_write_pack(
4358        out: *mut *mut git_odb_writepack,
4359        odb: *mut git_odb,
4360        progress_cb: git_indexer_progress_cb,
4361        progress_payload: *mut c_void,
4362    ) -> c_int;
4363
4364    #[cfg(not(feature = "unstable-sha256"))]
4365    pub fn git_odb_hash(
4366        out: *mut git_oid,
4367        data: *const c_void,
4368        len: size_t,
4369        otype: git_object_t,
4370    ) -> c_int;
4371    #[cfg(feature = "unstable-sha256")]
4372    pub fn git_odb_hash(
4373        out: *mut git_oid,
4374        data: *const c_void,
4375        len: size_t,
4376        otype: git_object_t,
4377        oid_type: git_oid_t,
4378    ) -> c_int;
4379
4380    #[cfg(not(feature = "unstable-sha256"))]
4381    pub fn git_odb_hashfile(out: *mut git_oid, path: *const c_char, otype: git_object_t) -> c_int;
4382    #[cfg(feature = "unstable-sha256")]
4383    pub fn git_odb_hashfile(
4384        out: *mut git_oid,
4385        path: *const c_char,
4386        otype: git_object_t,
4387        oid_type: git_oid_t,
4388    ) -> c_int;
4389
4390    pub fn git_odb_exists_prefix(
4391        out: *mut git_oid,
4392        odb: *mut git_odb,
4393        short_oid: *const git_oid,
4394        len: size_t,
4395    ) -> c_int;
4396
4397    pub fn git_odb_exists(odb: *mut git_odb, oid: *const git_oid) -> c_int;
4398    pub fn git_odb_exists_ext(odb: *mut git_odb, oid: *const git_oid, flags: c_uint) -> c_int;
4399
4400    pub fn git_odb_refresh(odb: *mut git_odb) -> c_int;
4401
4402    pub fn git_odb_object_id(obj: *mut git_odb_object) -> *const git_oid;
4403    pub fn git_odb_object_size(obj: *mut git_odb_object) -> size_t;
4404    pub fn git_odb_object_type(obj: *mut git_odb_object) -> git_object_t;
4405    pub fn git_odb_object_data(obj: *mut git_odb_object) -> *const c_void;
4406    pub fn git_odb_object_dup(out: *mut *mut git_odb_object, obj: *mut git_odb_object) -> c_int;
4407    pub fn git_odb_object_free(obj: *mut git_odb_object);
4408
4409    pub fn git_odb_init_backend(odb: *mut git_odb_backend, version: c_uint) -> c_int;
4410
4411    pub fn git_odb_add_backend(
4412        odb: *mut git_odb,
4413        backend: *mut git_odb_backend,
4414        priority: c_int,
4415    ) -> c_int;
4416
4417    #[cfg(not(feature = "unstable-sha256"))]
4418    pub fn git_odb_backend_pack(
4419        out: *mut *mut git_odb_backend,
4420        objects_dir: *const c_char,
4421    ) -> c_int;
4422    #[cfg(feature = "unstable-sha256")]
4423    pub fn git_odb_backend_pack(
4424        out: *mut *mut git_odb_backend,
4425        objects_dir: *const c_char,
4426        opts: *const git_odb_backend_pack_options,
4427    ) -> c_int;
4428
4429    #[cfg(not(feature = "unstable-sha256"))]
4430    pub fn git_odb_backend_one_pack(
4431        out: *mut *mut git_odb_backend,
4432        index_file: *const c_char,
4433    ) -> c_int;
4434    #[cfg(feature = "unstable-sha256")]
4435    pub fn git_odb_backend_one_pack(
4436        out: *mut *mut git_odb_backend,
4437        index_file: *const c_char,
4438        opts: *const git_odb_backend_pack_options,
4439    ) -> c_int;
4440
4441    pub fn git_odb_add_disk_alternate(odb: *mut git_odb, path: *const c_char) -> c_int;
4442
4443    #[cfg(not(feature = "unstable-sha256"))]
4444    pub fn git_odb_backend_loose(
4445        out: *mut *mut git_odb_backend,
4446        objects_dir: *const c_char,
4447        compression_level: c_int,
4448        do_fsync: c_int,
4449        dir_mode: c_uint,
4450        file_mode: c_uint,
4451    ) -> c_int;
4452    #[cfg(feature = "unstable-sha256")]
4453    pub fn git_odb_backend_loose(
4454        out: *mut *mut git_odb_backend,
4455        objects_dir: *const c_char,
4456        opts: *mut git_odb_backend_loose_options,
4457    ) -> c_int;
4458
4459    pub fn git_odb_add_alternate(
4460        odb: *mut git_odb,
4461        backend: *mut git_odb_backend,
4462        priority: c_int,
4463    ) -> c_int;
4464
4465    #[deprecated(note = "only kept for compatibility; prefer git_odb_backend_data_alloc")]
4466    pub fn git_odb_backend_malloc(backend: *mut git_odb_backend, len: size_t) -> *mut c_void;
4467
4468    pub fn git_odb_backend_data_alloc(backend: *mut git_odb_backend, len: size_t) -> *mut c_void;
4469    pub fn git_odb_backend_data_free(backend: *mut git_odb_backend, data: *mut c_void);
4470
4471    pub fn git_odb_num_backends(odb: *mut git_odb) -> size_t;
4472    pub fn git_odb_get_backend(
4473        backend: *mut *mut git_odb_backend,
4474        odb: *mut git_odb,
4475        position: size_t,
4476    ) -> c_int;
4477
4478    // mempack
4479    pub fn git_mempack_new(out: *mut *mut git_odb_backend) -> c_int;
4480    pub fn git_mempack_reset(backend: *mut git_odb_backend) -> c_int;
4481    pub fn git_mempack_dump(
4482        pack: *mut git_buf,
4483        repo: *mut git_repository,
4484        backend: *mut git_odb_backend,
4485    ) -> c_int;
4486
4487    // refdb
4488    pub fn git_refdb_new(out: *mut *mut git_refdb, repo: *mut git_repository) -> c_int;
4489    pub fn git_refdb_open(out: *mut *mut git_refdb, repo: *mut git_repository) -> c_int;
4490    pub fn git_refdb_backend_fs(
4491        out: *mut *mut git_refdb_backend,
4492        repo: *mut git_repository,
4493    ) -> c_int;
4494    pub fn git_refdb_init_backend(backend: *mut git_refdb_backend, version: c_uint) -> c_int;
4495    pub fn git_refdb_set_backend(refdb: *mut git_refdb, backend: *mut git_refdb_backend) -> c_int;
4496    pub fn git_refdb_compress(refdb: *mut git_refdb) -> c_int;
4497    pub fn git_refdb_free(refdb: *mut git_refdb);
4498
4499    // rebase
4500    pub fn git_rebase_init_options(opts: *mut git_rebase_options, version: c_uint) -> c_int;
4501    pub fn git_rebase_init(
4502        out: *mut *mut git_rebase,
4503        repo: *mut git_repository,
4504        branch: *const git_annotated_commit,
4505        upstream: *const git_annotated_commit,
4506        onto: *const git_annotated_commit,
4507        opts: *const git_rebase_options,
4508    ) -> c_int;
4509    pub fn git_rebase_open(
4510        out: *mut *mut git_rebase,
4511        repo: *mut git_repository,
4512        opts: *const git_rebase_options,
4513    ) -> c_int;
4514    pub fn git_rebase_operation_entrycount(rebase: *mut git_rebase) -> size_t;
4515    pub fn git_rebase_operation_current(rebase: *mut git_rebase) -> size_t;
4516    pub fn git_rebase_operation_byindex(
4517        rebase: *mut git_rebase,
4518        idx: size_t,
4519    ) -> *mut git_rebase_operation;
4520    pub fn git_rebase_orig_head_id(rebase: *mut git_rebase) -> *const git_oid;
4521    pub fn git_rebase_orig_head_name(rebase: *mut git_rebase) -> *const c_char;
4522    pub fn git_rebase_next(
4523        operation: *mut *mut git_rebase_operation,
4524        rebase: *mut git_rebase,
4525    ) -> c_int;
4526    pub fn git_rebase_inmemory_index(index: *mut *mut git_index, rebase: *mut git_rebase) -> c_int;
4527    pub fn git_rebase_commit(
4528        id: *mut git_oid,
4529        rebase: *mut git_rebase,
4530        author: *const git_signature,
4531        committer: *const git_signature,
4532        message_encoding: *const c_char,
4533        message: *const c_char,
4534    ) -> c_int;
4535    pub fn git_rebase_abort(rebase: *mut git_rebase) -> c_int;
4536    pub fn git_rebase_finish(rebase: *mut git_rebase, signature: *const git_signature) -> c_int;
4537    pub fn git_rebase_free(rebase: *mut git_rebase);
4538
4539    // cherrypick
4540    pub fn git_cherrypick_init_options(opts: *mut git_cherrypick_options, version: c_uint)
4541        -> c_int;
4542    pub fn git_cherrypick(
4543        repo: *mut git_repository,
4544        commit: *mut git_commit,
4545        options: *const git_cherrypick_options,
4546    ) -> c_int;
4547    pub fn git_cherrypick_commit(
4548        out: *mut *mut git_index,
4549        repo: *mut git_repository,
4550        cherrypick_commit: *mut git_commit,
4551        our_commit: *mut git_commit,
4552        mainline: c_uint,
4553        merge_options: *const git_merge_options,
4554    ) -> c_int;
4555
4556    // apply
4557    pub fn git_apply_options_init(opts: *mut git_apply_options, version: c_uint) -> c_int;
4558    pub fn git_apply_to_tree(
4559        out: *mut *mut git_index,
4560        repo: *mut git_repository,
4561        preimage: *mut git_tree,
4562        diff: *mut git_diff,
4563        options: *const git_apply_options,
4564    ) -> c_int;
4565    pub fn git_apply(
4566        repo: *mut git_repository,
4567        diff: *mut git_diff,
4568        location: git_apply_location_t,
4569        options: *const git_apply_options,
4570    ) -> c_int;
4571
4572    // revert
4573    pub fn git_revert_options_init(opts: *mut git_revert_options, version: c_uint) -> c_int;
4574    pub fn git_revert_commit(
4575        out: *mut *mut git_index,
4576        repo: *mut git_repository,
4577        revert_commit: *mut git_commit,
4578        our_commit: *mut git_commit,
4579        mainline: c_uint,
4580        merge_options: *const git_merge_options,
4581    ) -> c_int;
4582    pub fn git_revert(
4583        repo: *mut git_repository,
4584        commit: *mut git_commit,
4585        given_opts: *const git_revert_options,
4586    ) -> c_int;
4587
4588    // Common
4589    pub fn git_libgit2_version(major: *mut c_int, minor: *mut c_int, rev: *mut c_int) -> c_int;
4590    pub fn git_libgit2_features() -> c_int;
4591    pub fn git_libgit2_opts(option: c_int, ...) -> c_int;
4592
4593    // Worktrees
4594    pub fn git_worktree_list(out: *mut git_strarray, repo: *mut git_repository) -> c_int;
4595    pub fn git_worktree_lookup(
4596        out: *mut *mut git_worktree,
4597        repo: *mut git_repository,
4598        name: *const c_char,
4599    ) -> c_int;
4600    pub fn git_worktree_open_from_repository(
4601        out: *mut *mut git_worktree,
4602        repo: *mut git_repository,
4603    ) -> c_int;
4604    pub fn git_worktree_free(wt: *mut git_worktree);
4605    pub fn git_worktree_validate(wt: *const git_worktree) -> c_int;
4606    pub fn git_worktree_add_options_init(
4607        opts: *mut git_worktree_add_options,
4608        version: c_uint,
4609    ) -> c_int;
4610    pub fn git_worktree_add(
4611        out: *mut *mut git_worktree,
4612        repo: *mut git_repository,
4613        name: *const c_char,
4614        path: *const c_char,
4615        opts: *const git_worktree_add_options,
4616    ) -> c_int;
4617    pub fn git_worktree_lock(wt: *mut git_worktree, reason: *const c_char) -> c_int;
4618    pub fn git_worktree_unlock(wt: *mut git_worktree) -> c_int;
4619    pub fn git_worktree_is_locked(reason: *mut git_buf, wt: *const git_worktree) -> c_int;
4620    pub fn git_worktree_name(wt: *const git_worktree) -> *const c_char;
4621    pub fn git_worktree_path(wt: *const git_worktree) -> *const c_char;
4622    pub fn git_worktree_prune_options_init(
4623        opts: *mut git_worktree_prune_options,
4624        version: c_uint,
4625    ) -> c_int;
4626    pub fn git_worktree_is_prunable(
4627        wt: *mut git_worktree,
4628        opts: *mut git_worktree_prune_options,
4629    ) -> c_int;
4630    pub fn git_worktree_prune(
4631        wt: *mut git_worktree,
4632        opts: *mut git_worktree_prune_options,
4633    ) -> c_int;
4634
4635    // Ref transactions
4636    pub fn git_transaction_new(out: *mut *mut git_transaction, repo: *mut git_repository) -> c_int;
4637    pub fn git_transaction_lock_ref(tx: *mut git_transaction, refname: *const c_char) -> c_int;
4638    pub fn git_transaction_set_target(
4639        tx: *mut git_transaction,
4640        refname: *const c_char,
4641        target: *const git_oid,
4642        sig: *const git_signature,
4643        msg: *const c_char,
4644    ) -> c_int;
4645    pub fn git_transaction_set_symbolic_target(
4646        tx: *mut git_transaction,
4647        refname: *const c_char,
4648        target: *const c_char,
4649        sig: *const git_signature,
4650        msg: *const c_char,
4651    ) -> c_int;
4652    pub fn git_transaction_set_reflog(
4653        tx: *mut git_transaction,
4654        refname: *const c_char,
4655        reflog: *const git_reflog,
4656    ) -> c_int;
4657    pub fn git_transaction_remove(tx: *mut git_transaction, refname: *const c_char) -> c_int;
4658    pub fn git_transaction_commit(tx: *mut git_transaction) -> c_int;
4659    pub fn git_transaction_free(tx: *mut git_transaction);
4660
4661    // Mailmap
4662    pub fn git_mailmap_new(out: *mut *mut git_mailmap) -> c_int;
4663    pub fn git_mailmap_from_buffer(
4664        out: *mut *mut git_mailmap,
4665        buf: *const c_char,
4666        len: size_t,
4667    ) -> c_int;
4668    pub fn git_mailmap_from_repository(
4669        out: *mut *mut git_mailmap,
4670        repo: *mut git_repository,
4671    ) -> c_int;
4672    pub fn git_mailmap_free(mm: *mut git_mailmap);
4673    pub fn git_mailmap_resolve_signature(
4674        out: *mut *mut git_signature,
4675        mm: *const git_mailmap,
4676        sig: *const git_signature,
4677    ) -> c_int;
4678    pub fn git_mailmap_add_entry(
4679        mm: *mut git_mailmap,
4680        real_name: *const c_char,
4681        real_email: *const c_char,
4682        replace_name: *const c_char,
4683        replace_email: *const c_char,
4684    ) -> c_int;
4685
4686    // email
4687    pub fn git_email_create_from_diff(
4688        out: *mut git_buf,
4689        diff: *mut git_diff,
4690        patch_idx: usize,
4691        patch_count: usize,
4692        commit_id: *const git_oid,
4693        summary: *const c_char,
4694        body: *const c_char,
4695        author: *const git_signature,
4696        given_opts: *const git_email_create_options,
4697    ) -> c_int;
4698
4699    pub fn git_email_create_from_commit(
4700        out: *mut git_buf,
4701        commit: *mut git_commit,
4702        given_opts: *const git_email_create_options,
4703    ) -> c_int;
4704
4705    pub fn git_trace_set(level: git_trace_level_t, cb: git_trace_cb) -> c_int;
4706}
4707
4708pub fn init() {
4709    use std::sync::Once;
4710
4711    static INIT: Once = Once::new();
4712    INIT.call_once(|| unsafe {
4713        openssl_init();
4714        ssh_init();
4715        let rc = git_libgit2_init();
4716        if rc >= 0 {
4717            // Note that we intentionally never schedule `git_libgit2_shutdown`
4718            // to get called. There's not really a great time to call that and
4719            // #276 has some more info about how automatically doing it can
4720            // cause problems.
4721            return;
4722        }
4723
4724        let git_error = git_error_last();
4725        let error = if !git_error.is_null() {
4726            CStr::from_ptr((*git_error).message).to_string_lossy()
4727        } else {
4728            "unknown error".into()
4729        };
4730        panic!(
4731            "couldn't initialize the libgit2 library: {}, error: {}",
4732            rc, error
4733        );
4734    });
4735}
4736
4737#[cfg(all(unix, feature = "https"))]
4738#[doc(hidden)]
4739pub fn openssl_init() {
4740    openssl_sys::init();
4741}
4742
4743#[cfg(any(windows, not(feature = "https")))]
4744#[doc(hidden)]
4745pub fn openssl_init() {}
4746
4747#[cfg(feature = "ssh")]
4748fn ssh_init() {
4749    libssh2::init();
4750}
4751
4752#[cfg(not(feature = "ssh"))]
4753fn ssh_init() {}
4754
4755#[doc(hidden)]
4756pub fn vendored() -> bool {
4757    cfg!(libgit2_vendored)
4758}
4759
4760#[doc(hidden)]
4761pub fn experimental_features() -> Vec<&'static str> {
4762    let mut features = vec![];
4763
4764    if cfg!(libgit2_experimental_sha256) {
4765        features.push("sha256");
4766    }
4767
4768    features
4769}