| 1 | # ABSTRACT: Internal FFI::Platypus instance for Git::Libgit2 | ||
| 2 | |||
| 3 | package Git::Libgit2::FFI; | ||
| 4 | our $VERSION = '0.008'; | ||
| 5 | 31 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 31 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 31 | ▶ | use FFI::Platypus 2.00; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 0 | ▶ | use Alien::Libgit2; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 9 | |||
| 10 | my $ffi; | ||
| 11 | |||
| 12 | sub ffi { | ||
| 13 | return $ffi if $ffi; | ||
| 14 | $ffi = FFI::Platypus->new( api => 2, lib => [ Alien::Libgit2->dynamic_libs ] ); | ||
| 15 | |||
| 16 | $ffi->type( 'opaque' => 'git_repository' ); | ||
| 17 | $ffi->type( 'opaque' => 'git_reference' ); | ||
| 18 | $ffi->type( 'opaque' => 'git_reference_iterator' ); | ||
| 19 | $ffi->type( 'opaque' => 'git_config' ); | ||
| 20 | $ffi->type( 'opaque' => 'git_object' ); | ||
| 21 | $ffi->type( 'opaque' => 'git_blob' ); | ||
| 22 | $ffi->type( 'opaque' => 'git_tree' ); | ||
| 23 | $ffi->type( 'opaque' => 'git_treebuilder' ); | ||
| 24 | $ffi->type( 'opaque' => 'git_commit' ); | ||
| 25 | $ffi->type( 'opaque' => 'git_remote' ); | ||
| 26 | $ffi->type( 'opaque' => 'git_signature' ); | ||
| 27 | $ffi->type( 'opaque' => 'git_odb' ); | ||
| 28 | $ffi->type( 'opaque' => 'git_credential' ); | ||
| 29 | $ffi->type( 'opaque' => 'git_revwalk' ); | ||
| 30 | $ffi->type( 'opaque' => 'git_branch_iterator' ); | ||
| 31 | $ffi->type( 'opaque' => 'git_tag' ); | ||
| 32 | $ffi->type( 'opaque' => 'git_diff' ); | ||
| 33 | $ffi->type( 'opaque' => 'git_index' ); | ||
| 34 | $ffi->type( 'opaque' => 'git_index_entry' ); | ||
| 35 | $ffi->type( 'opaque' => 'git_annotated_commit' ); | ||
| 36 | $ffi->type( 'opaque' => 'git_merge_head' ); | ||
| 37 | $ffi->type( 'opaque' => 'git_reflog' ); | ||
| 38 | $ffi->type( 'opaque' => 'git_reflog_entry' ); | ||
| 39 | $ffi->type( 'opaque' => 'git_rebase' ); | ||
| 40 | $ffi->type( 'opaque' => 'git_rebase_operation' ); | ||
| 41 | |||
| 42 | # git_credential_acquire_cb signature. | ||
| 43 | # libgit2: int (*)(git_credential **out, const char *url, | ||
| 44 | # const char *username_from_url, | ||
| 45 | # unsigned int allowed_types, void *payload) | ||
| 46 | # Closures in FFI::Platypus allow only native types — so the **out** is passed | ||
| 47 | # as a plain `opaque` (the pointer value). The Perl closure pokes the | ||
| 48 | # allocated credential pointer into that address itself. | ||
| 49 | $ffi->type( '(opaque, string, string, uint, opaque)->int' => 'git_credential_acquire_cb' ); | ||
| 50 | |||
| 51 | # git_transport_certificate_check_cb signature. | ||
| 52 | # libgit2: int (*)(git_cert *cert, int valid, const char *host, void *payload) | ||
| 53 | # `cert` is passed as a plain `opaque` (pointer value); the Perl closure | ||
| 54 | # peeks the git_cert / git_cert_hostkey fields out of it directly. | ||
| 55 | $ffi->type( '(opaque, int, string, opaque)->int' => 'git_transport_certificate_check_cb' ); | ||
| 56 | |||
| 57 | # git_oid is a 20-byte struct, but for our MVP we pass it as opaque | ||
| 58 | # buffer (string of 20 bytes) or as hex via _fromstr/_tostr. | ||
| 59 | $ffi->type( 'opaque' => 'git_oid_ptr' ); | ||
| 60 | |||
| 61 | _attach_all(); | ||
| 62 | return $ffi; | ||
| 63 | } | ||
| 64 | |||
| 65 | |||
| 66 | sub _attach { | ||
| 67 | my ( $name, $args, $ret ) = @_; | ||
| 68 | $ffi->attach( $name => $args => $ret ); | ||
| 69 | } | ||
| 70 | |||
| 71 | sub _attach_all { | ||
| 72 | |||
| 73 | # ======================== | ||
| 74 | # Library init / shutdown | ||
| 75 | # ======================== | ||
| 76 | |||
| 77 | _attach git_libgit2_init => [] => 'int'; | ||
| 78 | _attach git_libgit2_shutdown => [] => 'int'; | ||
| 79 | _attach git_libgit2_version => [ 'int*', 'int*', 'int*' ] => 'int'; | ||
| 80 | |||
| 81 | # git_libgit2_opts is variadic (int option, ...). FFI::Platypus requires the | ||
| 82 | # variable-argument types to be fixed at attach time, so one function object | ||
| 83 | # serves exactly one vararg shape. Two are bound here, under two Perl names: | ||
| 84 | # the (int, string) form — i.e. only GIT_OPT_SET_SEARCH_PATH — and the | ||
| 85 | # (int, int) form, which covers the millisecond timeouts | ||
| 86 | # GIT_OPT_SET_SERVER_CONNECT_TIMEOUT and GIT_OPT_SET_SERVER_TIMEOUT (and the | ||
| 87 | # int-valued switches such as GIT_OPT_ENABLE_CACHING). Every option whose | ||
| 88 | # varargs match neither still needs its own function object via | ||
| 89 | # $ffi->function(...) at the call site; that explicitly includes the | ||
| 90 | # one-string options such as GIT_OPT_SET_TEMPLATE_PATH, not just obviously | ||
| 91 | # different ones like SET_MWINDOW_SIZE (size_t). A mismatched argument list | ||
| 92 | # is not reported as a return code — libgit2 va_arg's whatever is on the | ||
| 93 | # stack. Not wrapped via _attach because the helper takes one args array, | ||
| 94 | # not a fixed/var split. | ||
| 95 | # | ||
| 96 | # The GET_* counterparts are deliberately absent: their vararg is an out | ||
| 97 | # pointer, and FFI::Platypus 2.11 segfaults on a pointer type in a variadic | ||
| 98 | # argument list (`int*` here), rather than returning a value. | ||
| 99 | $ffi->attach( 'git_libgit2_opts' => [ 'int' ] => [ 'int', 'string' ] => 'int' ); | ||
| 100 | $ffi->attach( [ 'git_libgit2_opts' => 'git_libgit2_opts_int' ] | ||
| 101 | => [ 'int' ] => [ 'int', 'int' ] => 'int' ); | ||
| 102 | |||
| 103 | # ======================== | ||
| 104 | # Error | ||
| 105 | # ======================== | ||
| 106 | |||
| 107 | _attach git_error_last => [] => 'opaque'; | ||
| 108 | _attach git_error_clear => [] => 'void'; | ||
| 109 | |||
| 110 | # ======================== | ||
| 111 | # Repository | ||
| 112 | # ======================== | ||
| 113 | |||
| 114 | _attach git_repository_open => [ 'opaque*', 'string' ] => 'int'; | ||
| 115 | _attach git_repository_open_ext => [ 'opaque*', 'string', 'uint32', 'string' ] => 'int'; | ||
| 116 | _attach git_repository_init => [ 'opaque*', 'string', 'uint32' ] => 'int'; | ||
| 117 | _attach git_repository_workdir => [ 'git_repository' ] => 'string'; | ||
| 118 | _attach git_repository_path => [ 'git_repository' ] => 'string'; | ||
| 119 | _attach git_repository_is_bare => [ 'git_repository' ] => 'int'; | ||
| 120 | _attach git_repository_free => [ 'git_repository' ] => 'void'; | ||
| 121 | _attach git_repository_index => [ 'opaque*', 'git_repository' ] => 'int'; | ||
| 122 | _attach git_repository_config => [ 'opaque*', 'git_repository' ] => 'int'; | ||
| 123 | _attach git_repository_config_snapshot => [ 'opaque*', 'git_repository' ] => 'int'; | ||
| 124 | _attach git_repository_odb => [ 'opaque*', 'git_repository' ] => 'int'; | ||
| 125 | _attach git_repository_set_head => [ 'git_repository', 'string' ] => 'int'; | ||
| 126 | _attach git_repository_head => [ 'opaque*', 'git_repository' ] => 'int'; | ||
| 127 | _attach git_repository_head_unborn => [ 'git_repository' ] => 'int'; | ||
| 128 | _attach git_repository_head_detached => [ 'git_repository' ] => 'int'; | ||
| 129 | |||
| 130 | # ======================== | ||
| 131 | # Config | ||
| 132 | # ======================== | ||
| 133 | |||
| 134 | _attach git_config_open_default => [ 'opaque*' ] => 'int'; | ||
| 135 | _attach git_config_snapshot => [ 'opaque*', 'git_config' ] => 'int'; | ||
| 136 | _attach git_config_get_string => [ 'string*', 'git_config', 'string' ] => 'int'; | ||
| 137 | _attach git_config_get_bool => [ 'int*', 'git_config', 'string' ] => 'int'; | ||
| 138 | _attach git_config_set_string => [ 'git_config', 'string', 'string' ] => 'int'; | ||
| 139 | _attach git_config_free => [ 'git_config' ] => 'void'; | ||
| 140 | |||
| 141 | # ======================== | ||
| 142 | # OID | ||
| 143 | # ======================== | ||
| 144 | |||
| 145 | _attach git_oid_fromstr => [ 'opaque', 'string' ] => 'int'; | ||
| 146 | _attach git_oid_tostr => [ 'opaque', 'size_t', 'opaque' ] => 'string'; | ||
| 147 | _attach git_oid_cmp => [ 'opaque', 'opaque' ] => 'int'; | ||
| 148 | |||
| 149 | # ======================== | ||
| 150 | # Reference | ||
| 151 | # ======================== | ||
| 152 | |||
| 153 | _attach git_reference_lookup => [ 'opaque*', 'git_repository', 'string' ] => 'int'; | ||
| 154 | _attach git_reference_name_to_id => [ 'opaque', 'git_repository', 'string' ] => 'int'; | ||
| 155 | _attach git_reference_create => [ 'opaque*', 'git_repository', 'string', 'opaque', 'int', 'string' ] => 'int'; | ||
| 156 | _attach git_reference_create_matching => [ 'opaque*', 'git_repository', 'string', 'opaque', 'int', 'opaque', 'string' ] => 'int'; | ||
| 157 | _attach git_reference_delete => [ 'git_reference' ] => 'int'; | ||
| 158 | _attach git_reference_remove => [ 'git_repository', 'string' ] => 'int'; | ||
| 159 | _attach git_reference_target => [ 'git_reference' ] => 'opaque'; | ||
| 160 | _attach git_reference_name => [ 'git_reference' ] => 'string'; | ||
| 161 | _attach git_reference_type => [ 'git_reference' ] => 'int'; | ||
| 162 | _attach git_reference_free => [ 'git_reference' ] => 'void'; | ||
| 163 | _attach git_reference_iterator_new => [ 'opaque*', 'git_repository' ] => 'int'; | ||
| 164 | _attach git_reference_iterator_glob_new => [ 'opaque*', 'git_repository', 'string' ] => 'int'; | ||
| 165 | _attach git_reference_next => [ 'opaque*', 'git_reference_iterator' ] => 'int'; | ||
| 166 | _attach git_reference_next_name => [ 'string*', 'git_reference_iterator' ] => 'int'; | ||
| 167 | _attach git_reference_iterator_free => [ 'git_reference_iterator' ] => 'void'; | ||
| 168 | _attach git_reference_name_is_valid => [ 'int*', 'string' ] => 'int'; | ||
| 169 | _attach git_reference_peel => [ 'opaque*', 'git_reference', 'int' ] => 'int'; | ||
| 170 | _attach git_reference_symbolic_create => [ 'opaque*', 'git_repository', 'string', 'string', 'int', 'string' ] => 'int'; | ||
| 171 | _attach git_reference_symbolic_target => [ 'git_reference' ] => 'string'; | ||
| 172 | _attach git_reference_symbolic_set_target => [ 'opaque*', 'git_reference', 'string', 'string' ] => 'int'; | ||
| 173 | _attach git_reference_set_target => [ 'opaque*', 'git_reference', 'opaque', 'string' ] => 'int'; | ||
| 174 | _attach git_reference_resolve => [ 'opaque*', 'git_reference' ] => 'int'; | ||
| 175 | _attach git_reference_shorthand => [ 'git_reference' ] => 'string'; | ||
| 176 | _attach git_reference_is_branch => [ 'git_reference' ] => 'int'; | ||
| 177 | _attach git_reference_is_remote => [ 'git_reference' ] => 'int'; | ||
| 178 | _attach git_reference_is_tag => [ 'git_reference' ] => 'int'; | ||
| 179 | |||
| 180 | # ======================== | ||
| 181 | # Object | ||
| 182 | # ======================== | ||
| 183 | |||
| 184 | _attach git_object_lookup => [ 'opaque*', 'git_repository', 'opaque', 'int' ] => 'int'; | ||
| 185 | _attach git_object_lookup_prefix => [ 'opaque*', 'git_repository', 'opaque', 'size_t', 'int' ] => 'int'; | ||
| 186 | _attach git_object_id => [ 'git_object' ] => 'opaque'; | ||
| 187 | _attach git_object_type => [ 'git_object' ] => 'int'; | ||
| 188 | _attach git_object_free => [ 'git_object' ] => 'void'; | ||
| 189 | |||
| 190 | # ======================== | ||
| 191 | # Blob | ||
| 192 | # ======================== | ||
| 193 | |||
| 194 | _attach git_blob_create_from_buffer => [ 'opaque', 'git_repository', 'opaque', 'size_t' ] => 'int'; | ||
| 195 | _attach git_blob_lookup => [ 'opaque*', 'git_repository', 'opaque' ] => 'int'; | ||
| 196 | _attach git_blob_rawcontent => [ 'git_blob' ] => 'opaque'; | ||
| 197 | _attach git_blob_rawsize => [ 'git_blob' ] => 'sint64'; | ||
| 198 | _attach git_blob_is_binary => [ 'git_blob' ] => 'int'; | ||
| 199 | _attach git_blob_free => [ 'git_blob' ] => 'void'; | ||
| 200 | |||
| 201 | # ======================== | ||
| 202 | # Tree | ||
| 203 | # ======================== | ||
| 204 | |||
| 205 | _attach git_tree_lookup => [ 'opaque*', 'git_repository', 'opaque' ] => 'int'; | ||
| 206 | _attach git_tree_entrycount => [ 'git_tree' ] => 'size_t'; | ||
| 207 | _attach git_tree_entry_byindex => [ 'git_tree', 'size_t' ] => 'opaque'; | ||
| 208 | _attach git_tree_entry_byname => [ 'git_tree', 'string' ] => 'opaque'; | ||
| 209 | _attach git_tree_entry_name => [ 'opaque' ] => 'string'; | ||
| 210 | _attach git_tree_entry_id => [ 'opaque' ] => 'opaque'; | ||
| 211 | _attach git_tree_entry_filemode => [ 'opaque' ] => 'int'; | ||
| 212 | _attach git_tree_entry_type => [ 'opaque' ] => 'int'; | ||
| 213 | _attach git_tree_free => [ 'git_tree' ] => 'void'; | ||
| 214 | |||
| 215 | # ======================== | ||
| 216 | # TreeBuilder | ||
| 217 | # ======================== | ||
| 218 | |||
| 219 | _attach git_treebuilder_new => [ 'opaque*', 'git_repository', 'opaque' ] => 'int'; | ||
| 220 | _attach git_treebuilder_insert => [ 'opaque*', 'git_treebuilder', 'string', 'opaque', 'int' ] => 'int'; | ||
| 221 | _attach git_treebuilder_remove => [ 'git_treebuilder', 'string' ] => 'int'; | ||
| 222 | _attach git_treebuilder_write => [ 'opaque', 'git_treebuilder' ] => 'int'; | ||
| 223 | _attach git_treebuilder_free => [ 'git_treebuilder' ] => 'void'; | ||
| 224 | |||
| 225 | # ======================== | ||
| 226 | # Commit | ||
| 227 | # ======================== | ||
| 228 | |||
| 229 | _attach git_commit_lookup => [ 'opaque*', 'git_repository', 'opaque' ] => 'int'; | ||
| 230 | _attach git_commit_create => [ 'opaque', 'git_repository', 'string', 'git_signature', 'git_signature', | ||
| 231 | 'string', 'string', 'git_tree', 'size_t', 'opaque' ] => 'int'; | ||
| 232 | _attach git_commit_message => [ 'git_commit' ] => 'string'; | ||
| 233 | _attach git_commit_tree => [ 'opaque*', 'git_commit' ] => 'int'; | ||
| 234 | _attach git_commit_tree_id => [ 'git_commit' ] => 'opaque'; | ||
| 235 | _attach git_commit_parentcount => [ 'git_commit' ] => 'uint'; | ||
| 236 | _attach git_commit_parent_id => [ 'git_commit', 'uint' ] => 'opaque'; | ||
| 237 | _attach git_commit_author => [ 'git_commit' ] => 'opaque'; | ||
| 238 | _attach git_commit_committer => [ 'git_commit' ] => 'opaque'; | ||
| 239 | _attach git_commit_id => [ 'git_commit' ] => 'opaque'; | ||
| 240 | _attach git_commit_time => [ 'git_commit' ] => 'sint64'; | ||
| 241 | _attach git_commit_time_offset => [ 'git_commit' ] => 'int'; | ||
| 242 | _attach git_commit_summary => [ 'git_commit' ] => 'string'; | ||
| 243 | _attach git_commit_free => [ 'git_commit' ] => 'void'; | ||
| 244 | |||
| 245 | # ======================== | ||
| 246 | # Signature | ||
| 247 | # ======================== | ||
| 248 | |||
| 249 | _attach git_signature_new => [ 'opaque*', 'string', 'string', 'sint64', 'int' ] => 'int'; | ||
| 250 | _attach git_signature_now => [ 'opaque*', 'string', 'string' ] => 'int'; | ||
| 251 | _attach git_signature_default => [ 'opaque*', 'git_repository' ] => 'int'; | ||
| 252 | _attach git_signature_free => [ 'git_signature' ] => 'void'; | ||
| 253 | |||
| 254 | # ======================== | ||
| 255 | # Remote | ||
| 256 | # ======================== | ||
| 257 | |||
| 258 | _attach git_remote_lookup => [ 'opaque*', 'git_repository', 'string' ] => 'int'; | ||
| 259 | _attach git_remote_create => [ 'opaque*', 'git_repository', 'string', 'string' ] => 'int'; | ||
| 260 | _attach git_remote_create_anonymous => [ 'opaque*', 'git_repository', 'string' ] => 'int'; | ||
| 261 | _attach git_remote_url => [ 'git_remote' ] => 'string'; | ||
| 262 | _attach git_remote_name => [ 'git_remote' ] => 'string'; | ||
| 263 | _attach git_remote_init_callbacks => [ 'opaque', 'uint' ] => 'int'; | ||
| 264 | _attach git_fetch_options_init => [ 'opaque', 'uint' ] => 'int'; | ||
| 265 | _attach git_push_options_init => [ 'opaque', 'uint' ] => 'int'; | ||
| 266 | _attach git_remote_fetch => [ 'git_remote', 'opaque', 'opaque', 'string' ] => 'int'; | ||
| 267 | _attach git_remote_push => [ 'git_remote', 'opaque', 'opaque' ] => 'int'; | ||
| 268 | _attach git_remote_connect => [ 'git_remote', 'int', 'opaque', 'opaque', 'opaque' ] => 'int'; | ||
| 269 | _attach git_remote_ls => [ 'opaque*', 'size_t*', 'git_remote' ] => 'int'; | ||
| 270 | _attach git_remote_disconnect => [ 'git_remote' ] => 'int'; | ||
| 271 | _attach git_remote_free => [ 'git_remote' ] => 'void'; | ||
| 272 | |||
| 273 | # ======================== | ||
| 274 | # Credentials | ||
| 275 | # ======================== | ||
| 276 | |||
| 277 | _attach git_credential_userpass_plaintext_new => [ 'opaque*', 'string', 'string' ] => 'int'; | ||
| 278 | _attach git_credential_ssh_key_new => [ 'opaque*', 'string', 'string', 'string', 'string' ] => 'int'; | ||
| 279 | _attach git_credential_ssh_key_from_agent => [ 'opaque*', 'string' ] => 'int'; | ||
| 280 | _attach git_credential_default_new => [ 'opaque*' ] => 'int'; | ||
| 281 | _attach git_credential_username_new => [ 'opaque*', 'string' ] => 'int'; | ||
| 282 | _attach git_credential_free => [ 'git_credential' ] => 'void'; | ||
| 283 | |||
| 284 | # ======================== | ||
| 285 | # Clone | ||
| 286 | # ======================== | ||
| 287 | |||
| 288 | _attach git_clone_options_init => [ 'opaque', 'uint' ] => 'int'; | ||
| 289 | _attach git_clone => [ 'opaque*', 'string', 'string', 'opaque' ] => 'int'; | ||
| 290 | |||
| 291 | # ======================== | ||
| 292 | # Strarray | ||
| 293 | # ======================== | ||
| 294 | |||
| 295 | _attach git_strarray_free => [ 'opaque' ] => 'void'; | ||
| 296 | |||
| 297 | # ======================== | ||
| 298 | # Revwalk | ||
| 299 | # ======================== | ||
| 300 | |||
| 301 | _attach git_revwalk_new => [ 'opaque*', 'git_repository' ] => 'int'; | ||
| 302 | _attach git_revwalk_push => [ 'git_revwalk', 'opaque' ] => 'int'; | ||
| 303 | _attach git_revwalk_push_head => [ 'git_revwalk' ] => 'int'; | ||
| 304 | _attach git_revwalk_push_ref => [ 'git_revwalk', 'string' ] => 'int'; | ||
| 305 | _attach git_revwalk_push_glob => [ 'git_revwalk', 'string' ] => 'int'; | ||
| 306 | _attach git_revwalk_push_range => [ 'git_revwalk', 'string' ] => 'int'; | ||
| 307 | _attach git_revwalk_hide => [ 'git_revwalk', 'opaque' ] => 'int'; | ||
| 308 | _attach git_revwalk_hide_head => [ 'git_revwalk' ] => 'int'; | ||
| 309 | _attach git_revwalk_hide_ref => [ 'git_revwalk', 'string' ] => 'int'; | ||
| 310 | _attach git_revwalk_hide_glob => [ 'git_revwalk', 'string' ] => 'int'; | ||
| 311 | _attach git_revwalk_next => [ 'opaque', 'git_revwalk' ] => 'int'; | ||
| 312 | _attach git_revwalk_sorting => [ 'git_revwalk', 'uint' ] => 'int'; | ||
| 313 | _attach git_revwalk_reset => [ 'git_revwalk' ] => 'int'; | ||
| 314 | _attach git_revwalk_simplify_first_parent => [ 'git_revwalk' ] => 'int'; | ||
| 315 | _attach git_revwalk_free => [ 'git_revwalk' ] => 'void'; | ||
| 316 | |||
| 317 | # ======================== | ||
| 318 | # Branch | ||
| 319 | # ======================== | ||
| 320 | |||
| 321 | _attach git_branch_create => [ 'opaque*', 'git_repository', 'string', 'git_commit', 'int' ] => 'int'; | ||
| 322 | _attach git_branch_lookup => [ 'opaque*', 'git_repository', 'string', 'int' ] => 'int'; | ||
| 323 | _attach git_branch_delete => [ 'git_reference' ] => 'int'; | ||
| 324 | _attach git_branch_iterator_new => [ 'opaque*', 'git_repository', 'int' ] => 'int'; | ||
| 325 | _attach git_branch_next => [ 'opaque*', 'int*', 'git_branch_iterator' ] => 'int'; | ||
| 326 | _attach git_branch_iterator_free => [ 'git_branch_iterator' ] => 'void'; | ||
| 327 | _attach git_branch_name => [ 'string*', 'git_reference' ] => 'int'; | ||
| 328 | _attach git_branch_is_head => [ 'git_reference' ] => 'int'; | ||
| 329 | _attach git_branch_move => [ 'opaque*', 'git_reference', 'string', 'int' ] => 'int'; | ||
| 330 | |||
| 331 | # ======================== | ||
| 332 | # Status | ||
| 333 | # ======================== | ||
| 334 | |||
| 335 | $ffi->type( '(string, uint, opaque)->int' => 'git_status_cb' ); | ||
| 336 | _attach git_status_options_init => [ 'opaque', 'uint' ] => 'int'; | ||
| 337 | _attach git_status_foreach => [ 'git_repository', 'git_status_cb', 'opaque' ] => 'int'; | ||
| 338 | _attach git_status_foreach_ext => [ 'git_repository', 'opaque', 'git_status_cb', 'opaque' ] => 'int'; | ||
| 339 | _attach git_status_file => [ 'uint*', 'git_repository', 'string' ] => 'int'; | ||
| 340 | |||
| 341 | # ======================== | ||
| 342 | # Tag | ||
| 343 | # ======================== | ||
| 344 | |||
| 345 | # oid out-param is a caller-allocated git_oid buffer (opaque), not a | ||
| 346 | # pointer-to-pointer - same as the lightweight/from_buffer variants below. | ||
| 347 | _attach git_tag_create => [ 'opaque', 'git_repository', 'string', 'opaque', 'opaque', 'string', 'int' ] => 'int'; | ||
| 348 | _attach git_tag_create_from_buffer => [ 'opaque', 'git_repository', 'string', 'int' ] => 'int'; | ||
| 349 | _attach git_tag_create_lightweight => [ 'opaque', 'git_repository', 'string', 'git_object', 'int' ] => 'int'; | ||
| 350 | _attach git_tag_lookup => [ 'opaque*', 'git_repository', 'opaque' ] => 'int'; | ||
| 351 | _attach git_tag_delete => [ 'git_repository', 'string' ] => 'int'; | ||
| 352 | _attach git_tag_list => [ 'opaque', 'git_repository' ] => 'int'; | ||
| 353 | _attach git_tag_list_match => [ 'opaque', 'string', 'git_repository' ] => 'int'; | ||
| 354 | _attach git_tag_target => [ 'opaque*', 'git_tag' ] => 'int'; | ||
| 355 | _attach git_tag_target_id => [ 'git_tag' ] => 'opaque'; | ||
| 356 | _attach git_tag_message => [ 'git_tag' ] => 'string'; | ||
| 357 | _attach git_tag_name => [ 'git_tag' ] => 'string'; | ||
| 358 | _attach git_tag_tagger => [ 'git_tag' ] => 'opaque'; | ||
| 359 | _attach git_tag_free => [ 'git_tag' ] => 'void'; | ||
| 360 | |||
| 361 | # ======================== | ||
| 362 | # Diff | ||
| 363 | # ======================== | ||
| 364 | |||
| 365 | _attach git_diff_options_init => [ 'opaque', 'uint' ] => 'int'; | ||
| 366 | _attach git_diff_tree_to_tree => [ 'opaque*', 'git_repository', 'git_tree', 'git_tree', 'opaque' ] => 'int'; | ||
| 367 | _attach git_diff_tree_to_workdir => [ 'opaque*', 'git_repository', 'git_tree', 'opaque' ] => 'int'; | ||
| 368 | _attach git_diff_tree_to_index => [ 'opaque*', 'git_repository', 'git_tree', 'git_index', 'opaque' ] => 'int'; | ||
| 369 | _attach git_diff_index_to_workdir => [ 'opaque*', 'git_repository', 'git_index', 'opaque' ] => 'int'; | ||
| 370 | _attach git_diff_num_deltas => [ 'git_diff' ] => 'size_t'; | ||
| 371 | _attach git_diff_get_delta => [ 'git_diff', 'size_t' ] => 'opaque'; | ||
| 372 | _attach git_diff_free => [ 'git_diff' ] => 'void'; | ||
| 373 | |||
| 374 | # ======================== | ||
| 375 | # Index | ||
| 376 | # ======================== | ||
| 377 | |||
| 378 | _attach git_index_open => [ 'opaque*', 'string' ] => 'int'; | ||
| 379 | _attach git_index_read => [ 'git_index', 'int' ] => 'int'; | ||
| 380 | _attach git_index_write => [ 'git_index' ] => 'int'; | ||
| 381 | _attach git_index_read_tree => [ 'git_index', 'git_tree' ] => 'int'; | ||
| 382 | _attach git_index_write_tree => [ 'opaque', 'git_index' ] => 'int'; | ||
| 383 | _attach git_index_add_bypath => [ 'git_index', 'string' ] => 'int'; | ||
| 384 | _attach git_index_add_all => [ 'git_index', 'opaque', 'uint', 'opaque', 'opaque' ] => 'int'; | ||
| 385 | _attach git_index_remove_bypath => [ 'git_index', 'string' ] => 'int'; | ||
| 386 | _attach git_index_clear => [ 'git_index' ] => 'int'; | ||
| 387 | _attach git_index_entrycount => [ 'git_index' ] => 'size_t'; | ||
| 388 | _attach git_index_get_byindex => [ 'git_index', 'size_t' ] => 'opaque'; | ||
| 389 | _attach git_index_find => [ 'size_t*', 'git_index', 'string' ] => 'int'; | ||
| 390 | _attach git_index_find_prefix => [ 'size_t*', 'git_index', 'string' ] => 'int'; | ||
| 391 | _attach git_index_free => [ 'git_index' ] => 'void'; | ||
| 392 | |||
| 393 | # ======================== | ||
| 394 | # Checkout | ||
| 395 | # ======================== | ||
| 396 | |||
| 397 | _attach git_checkout_options_init => [ 'opaque', 'uint' ] => 'int'; | ||
| 398 | _attach git_checkout_head => [ 'git_repository', 'opaque' ] => 'int'; | ||
| 399 | _attach git_checkout_index => [ 'git_repository', 'git_index', 'opaque' ] => 'int'; | ||
| 400 | _attach git_checkout_tree => [ 'git_repository', 'git_object', 'opaque' ] => 'int'; | ||
| 401 | |||
| 402 | # ======================== | ||
| 403 | # Revparse | ||
| 404 | # ======================== | ||
| 405 | |||
| 406 | _attach git_revparse_single => [ 'opaque*', 'git_repository', 'string' ] => 'int'; | ||
| 407 | _attach git_revparse_ext => [ 'opaque*', 'opaque*', 'git_repository', 'string' ] => 'int'; | ||
| 408 | |||
| 409 | # ======================== | ||
| 410 | # Reset | ||
| 411 | # ======================== | ||
| 412 | |||
| 413 | _attach git_reset => [ 'git_repository', 'git_object', 'int', 'opaque' ] => 'int'; | ||
| 414 | _attach git_reset_default => [ 'git_repository', 'git_object', 'opaque' ] => 'int'; | ||
| 415 | |||
| 416 | # ======================== | ||
| 417 | # Merge | ||
| 418 | # ======================== | ||
| 419 | |||
| 420 | _attach git_annotated_commit_lookup => [ 'opaque*', 'git_repository', 'opaque' ] => 'int'; | ||
| 421 | _attach git_annotated_commit_from_ref => [ 'opaque*', 'git_repository', 'git_reference' ] => 'int'; | ||
| 422 | _attach git_annotated_commit_id => [ 'git_annotated_commit' ] => 'opaque'; | ||
| 423 | _attach git_annotated_commit_free => [ 'git_annotated_commit' ] => 'void'; | ||
| 424 | _attach git_merge_base => [ 'opaque', 'git_repository', 'opaque', 'opaque' ] => 'int'; | ||
| 425 | _attach git_merge_base_many => [ 'opaque', 'git_repository', 'size_t', 'opaque' ] => 'int'; | ||
| 426 | _attach git_merge_analysis => [ 'uint*', 'uint*', 'git_repository', 'opaque', 'size_t' ] => 'int'; | ||
| 427 | _attach git_merge_options_init => [ 'opaque', 'uint' ] => 'int'; | ||
| 428 | |||
| 429 | # ======================== | ||
| 430 | # Graph | ||
| 431 | # ======================== | ||
| 432 | |||
| 433 | _attach git_graph_ahead_behind => [ 'size_t*', 'size_t*', 'git_repository', 'opaque', 'opaque' ] => 'int'; | ||
| 434 | _attach git_graph_descendant_of => [ 'git_repository', 'opaque', 'opaque' ] => 'int'; | ||
| 435 | |||
| 436 | # ======================== | ||
| 437 | # Stash | ||
| 438 | # ======================== | ||
| 439 | |||
| 440 | _attach git_stash_save => [ 'opaque', 'git_repository', 'git_signature', 'string', 'uint' ] => 'int'; | ||
| 441 | _attach git_stash_apply => [ 'git_repository', 'size_t', 'opaque' ] => 'int'; | ||
| 442 | _attach git_stash_drop => [ 'git_repository', 'size_t' ] => 'int'; | ||
| 443 | |||
| 444 | # ======================== | ||
| 445 | # Reflog | ||
| 446 | # ======================== | ||
| 447 | |||
| 448 | _attach git_reflog_read => [ 'opaque*', 'git_repository', 'string' ] => 'int'; | ||
| 449 | _attach git_reflog_entrycount => [ 'git_reflog' ] => 'size_t'; | ||
| 450 | _attach git_reflog_entry_byindex => [ 'git_reflog', 'size_t' ] => 'opaque'; | ||
| 451 | _attach git_reflog_entry_id_new => [ 'git_reflog_entry' ] => 'opaque'; | ||
| 452 | _attach git_reflog_entry_message => [ 'git_reflog_entry' ] => 'string'; | ||
| 453 | _attach git_reflog_free => [ 'git_reflog' ] => 'void'; | ||
| 454 | |||
| 455 | # ======================== | ||
| 456 | # Rebase | ||
| 457 | # ======================== | ||
| 458 | |||
| 459 | _attach git_rebase_init => [ 'opaque*', 'git_repository', 'git_annotated_commit', 'git_annotated_commit', 'git_annotated_commit', 'opaque' ] => 'int'; | ||
| 460 | _attach git_rebase_open => [ 'opaque*', 'git_repository', 'opaque' ] => 'int'; | ||
| 461 | _attach git_rebase_next => [ 'opaque*', 'git_rebase' ] => 'int'; | ||
| 462 | _attach git_rebase_commit => [ 'opaque', 'git_rebase', 'git_signature', 'git_signature', 'string', 'string' ] => 'int'; | ||
| 463 | _attach git_rebase_abort => [ 'git_rebase' ] => 'int'; | ||
| 464 | _attach git_rebase_finish => [ 'git_rebase', 'git_signature' ] => 'int'; | ||
| 465 | _attach git_rebase_free => [ 'git_rebase' ] => 'void'; | ||
| 466 | _attach git_rebase_operation_entrycount => [ 'git_rebase' ] => 'size_t'; | ||
| 467 | _attach git_rebase_operation_current => [ 'git_rebase' ] => 'size_t'; | ||
| 468 | _attach git_rebase_operation_byindex => [ 'git_rebase', 'size_t' ] => 'opaque'; | ||
| 469 | _attach git_rebase_options_init => [ 'opaque', 'uint' ] => 'int'; | ||
| 470 | _attach git_rebase_orig_head_name => [ 'git_rebase' ] => 'string'; | ||
| 471 | _attach git_rebase_orig_head_id => [ 'git_rebase' ] => 'opaque'; | ||
| 472 | _attach git_rebase_onto_name => [ 'git_rebase' ] => 'string'; | ||
| 473 | _attach git_rebase_onto_id => [ 'git_rebase' ] => 'opaque'; | ||
| 474 | |||
| 475 | # ======================== | ||
| 476 | # Cherry-pick | ||
| 477 | # ======================== | ||
| 478 | |||
| 479 | _attach git_cherrypick => [ 'git_repository', 'git_commit', 'opaque' ] => 'int'; | ||
| 480 | _attach git_cherrypick_commit => [ 'opaque*', 'git_repository', 'git_commit', 'git_commit', 'uint', 'opaque' ] => 'int'; | ||
| 481 | _attach git_cherrypick_options_init => [ 'opaque', 'uint' ] => 'int'; | ||
| 482 | |||
| 483 | # ======================== | ||
| 484 | # Revert | ||
| 485 | # ======================== | ||
| 486 | |||
| 487 | _attach git_revert => [ 'git_repository', 'git_commit', 'opaque' ] => 'int'; | ||
| 488 | _attach git_revert_commit => [ 'opaque*', 'git_repository', 'git_commit', 'git_commit', 'uint', 'opaque' ] => 'int'; | ||
| 489 | _attach git_revert_options_init => [ 'opaque', 'uint' ] => 'int'; | ||
| 490 | |||
| 491 | # ======================== | ||
| 492 | # ODB | ||
| 493 | # ======================== | ||
| 494 | |||
| 495 | _attach git_odb_new => [ 'opaque*' ] => 'int'; | ||
| 496 | _attach git_odb_exists => [ 'git_odb', 'opaque' ] => 'int'; | ||
| 497 | _attach git_odb_free => [ 'git_odb' ] => 'void'; | ||
| 498 | } | ||
| 499 | |||
| 500 | 1; | ||
| 501 | |||
| 502 | __END__ | ||