-
Notifications
You must be signed in to change notification settings - Fork 413
/
Copy pathlib.rs
4237 lines (3900 loc) · 136 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#![doc(html_root_url = "https://docs.rs/libgit2-sys/0.13")]
#![allow(non_camel_case_types, unused_extern_crates)]
// This is required to link libz when libssh2-sys is not included.
extern crate libz_sys as libz;
use libc::{c_char, c_int, c_uchar, c_uint, c_void, size_t};
#[cfg(feature = "ssh")]
use libssh2_sys as libssh2;
use std::ffi::CStr;
use std::os::raw::c_ushort;
pub const GIT_OID_RAWSZ: usize = 20;
pub const GIT_OID_HEXSZ: usize = GIT_OID_RAWSZ * 2;
pub const GIT_CLONE_OPTIONS_VERSION: c_uint = 1;
pub const GIT_STASH_APPLY_OPTIONS_VERSION: c_uint = 1;
pub const GIT_CHECKOUT_OPTIONS_VERSION: c_uint = 1;
pub const GIT_MERGE_OPTIONS_VERSION: c_uint = 1;
pub const GIT_REMOTE_CALLBACKS_VERSION: c_uint = 1;
pub const GIT_STATUS_OPTIONS_VERSION: c_uint = 1;
pub const GIT_BLAME_OPTIONS_VERSION: c_uint = 1;
pub const GIT_PROXY_OPTIONS_VERSION: c_uint = 1;
pub const GIT_SUBMODULE_UPDATE_OPTIONS_VERSION: c_uint = 1;
pub const GIT_ODB_BACKEND_VERSION: c_uint = 1;
pub const GIT_REFDB_BACKEND_VERSION: c_uint = 1;
pub const GIT_CHERRYPICK_OPTIONS_VERSION: c_uint = 1;
pub const GIT_APPLY_OPTIONS_VERSION: c_uint = 1;
pub const GIT_REVERT_OPTIONS_VERSION: c_uint = 1;
macro_rules! git_enum {
(pub enum $name:ident { $($variants:tt)* }) => {
#[cfg(target_env = "msvc")]
pub type $name = i32;
#[cfg(not(target_env = "msvc"))]
pub type $name = u32;
git_enum!(gen, $name, 0, $($variants)*);
};
(pub enum $name:ident: $t:ty { $($variants:tt)* }) => {
pub type $name = $t;
git_enum!(gen, $name, 0, $($variants)*);
};
(gen, $name:ident, $val:expr, $variant:ident, $($rest:tt)*) => {
pub const $variant: $name = $val;
git_enum!(gen, $name, $val+1, $($rest)*);
};
(gen, $name:ident, $val:expr, $variant:ident = $e:expr, $($rest:tt)*) => {
pub const $variant: $name = $e;
git_enum!(gen, $name, $e+1, $($rest)*);
};
(gen, $name:ident, $val:expr, ) => {}
}
pub enum git_blob {}
pub enum git_branch_iterator {}
pub enum git_blame {}
pub enum git_commit {}
pub enum git_config {}
pub enum git_config_iterator {}
pub enum git_index {}
pub enum git_index_conflict_iterator {}
pub enum git_object {}
pub enum git_reference {}
pub enum git_reference_iterator {}
pub enum git_annotated_commit {}
pub enum git_refdb {}
pub enum git_refspec {}
pub enum git_remote {}
pub enum git_repository {}
pub enum git_revwalk {}
pub enum git_submodule {}
pub enum git_tag {}
pub enum git_tree {}
pub enum git_tree_entry {}
pub enum git_treebuilder {}
pub enum git_push {}
pub enum git_note {}
pub enum git_note_iterator {}
pub enum git_status_list {}
pub enum git_pathspec {}
pub enum git_pathspec_match_list {}
pub enum git_diff {}
pub enum git_diff_stats {}
pub enum git_patch {}
pub enum git_rebase {}
pub enum git_reflog {}
pub enum git_reflog_entry {}
pub enum git_describe_result {}
pub enum git_packbuilder {}
pub enum git_odb {}
pub enum git_odb_stream {}
pub enum git_odb_object {}
pub enum git_worktree {}
pub enum git_transaction {}
pub enum git_mailmap {}
#[repr(C)]
pub struct git_revspec {
pub from: *mut git_object,
pub to: *mut git_object,
pub flags: c_uint,
}
#[repr(C)]
pub struct git_error {
pub message: *mut c_char,
pub klass: c_int,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct git_oid {
pub id: [u8; GIT_OID_RAWSZ],
}
#[repr(C)]
#[derive(Copy)]
pub struct git_strarray {
pub strings: *mut *mut c_char,
pub count: size_t,
}
impl Clone for git_strarray {
fn clone(&self) -> git_strarray {
*self
}
}
#[repr(C)]
#[derive(Copy)]
pub struct git_oidarray {
pub ids: *mut git_oid,
pub count: size_t,
}
impl Clone for git_oidarray {
fn clone(&self) -> git_oidarray {
*self
}
}
#[repr(C)]
pub struct git_signature {
pub name: *mut c_char,
pub email: *mut c_char,
pub when: git_time,
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct git_time {
pub time: git_time_t,
pub offset: c_int,
pub sign: c_char,
}
pub type git_off_t = i64;
pub type git_time_t = i64;
pub type git_object_size_t = u64;
git_enum! {
pub enum git_revparse_mode_t {
GIT_REVPARSE_SINGLE = 1 << 0,
GIT_REVPARSE_RANGE = 1 << 1,
GIT_REVPARSE_MERGE_BASE = 1 << 2,
}
}
git_enum! {
pub enum git_error_code: c_int {
GIT_OK = 0,
GIT_ERROR = -1,
GIT_ENOTFOUND = -3,
GIT_EEXISTS = -4,
GIT_EAMBIGUOUS = -5,
GIT_EBUFS = -6,
GIT_EUSER = -7,
GIT_EBAREREPO = -8,
GIT_EUNBORNBRANCH = -9,
GIT_EUNMERGED = -10,
GIT_ENONFASTFORWARD = -11,
GIT_EINVALIDSPEC = -12,
GIT_ECONFLICT = -13,
GIT_ELOCKED = -14,
GIT_EMODIFIED = -15,
GIT_EAUTH = -16,
GIT_ECERTIFICATE = -17,
GIT_EAPPLIED = -18,
GIT_EPEEL = -19,
GIT_EEOF = -20,
GIT_EINVALID = -21,
GIT_EUNCOMMITTED = -22,
GIT_EDIRECTORY = -23,
GIT_EMERGECONFLICT = -24,
GIT_PASSTHROUGH = -30,
GIT_ITEROVER = -31,
GIT_RETRY = -32,
GIT_EMISMATCH = -33,
GIT_EINDEXDIRTY = -34,
GIT_EAPPLYFAIL = -35,
}
}
git_enum! {
pub enum git_error_t {
GIT_ERROR_NONE = 0,
GIT_ERROR_NOMEMORY,
GIT_ERROR_OS,
GIT_ERROR_INVALID,
GIT_ERROR_REFERENCE,
GIT_ERROR_ZLIB,
GIT_ERROR_REPOSITORY,
GIT_ERROR_CONFIG,
GIT_ERROR_REGEX,
GIT_ERROR_ODB,
GIT_ERROR_INDEX,
GIT_ERROR_OBJECT,
GIT_ERROR_NET,
GIT_ERROR_TAG,
GIT_ERROR_TREE,
GIT_ERROR_INDEXER,
GIT_ERROR_SSL,
GIT_ERROR_SUBMODULE,
GIT_ERROR_THREAD,
GIT_ERROR_STASH,
GIT_ERROR_CHECKOUT,
GIT_ERROR_FETCHHEAD,
GIT_ERROR_MERGE,
GIT_ERROR_SSH,
GIT_ERROR_FILTER,
GIT_ERROR_REVERT,
GIT_ERROR_CALLBACK,
GIT_ERROR_CHERRYPICK,
GIT_ERROR_DESCRIBE,
GIT_ERROR_REBASE,
GIT_ERROR_FILESYSTEM,
GIT_ERROR_PATCH,
GIT_ERROR_WORKTREE,
GIT_ERROR_SHA1,
GIT_ERROR_HTTP,
}
}
git_enum! {
pub enum git_repository_state_t {
GIT_REPOSITORY_STATE_NONE,
GIT_REPOSITORY_STATE_MERGE,
GIT_REPOSITORY_STATE_REVERT,
GIT_REPOSITORY_STATE_REVERT_SEQUENCE,
GIT_REPOSITORY_STATE_CHERRYPICK,
GIT_REPOSITORY_STATE_CHERRYPICK_SEQUENCE,
GIT_REPOSITORY_STATE_BISECT,
GIT_REPOSITORY_STATE_REBASE,
GIT_REPOSITORY_STATE_REBASE_INTERACTIVE,
GIT_REPOSITORY_STATE_REBASE_MERGE,
GIT_REPOSITORY_STATE_APPLY_MAILBOX,
GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE,
}
}
git_enum! {
pub enum git_direction {
GIT_DIRECTION_FETCH,
GIT_DIRECTION_PUSH,
}
}
#[repr(C)]
pub struct git_clone_options {
pub version: c_uint,
pub checkout_opts: git_checkout_options,
pub fetch_opts: git_fetch_options,
pub bare: c_int,
pub local: git_clone_local_t,
pub checkout_branch: *const c_char,
pub repository_cb: git_repository_create_cb,
pub repository_cb_payload: *mut c_void,
pub remote_cb: git_remote_create_cb,
pub remote_cb_payload: *mut c_void,
}
git_enum! {
pub enum git_clone_local_t {
GIT_CLONE_LOCAL_AUTO,
GIT_CLONE_LOCAL,
GIT_CLONE_NO_LOCAL,
GIT_CLONE_LOCAL_NO_LINKS,
}
}
#[repr(C)]
pub struct git_checkout_options {
pub version: c_uint,
pub checkout_strategy: c_uint,
pub disable_filters: c_int,
pub dir_mode: c_uint,
pub file_mode: c_uint,
pub file_open_flags: c_int,
pub notify_flags: c_uint,
pub notify_cb: git_checkout_notify_cb,
pub notify_payload: *mut c_void,
pub progress_cb: git_checkout_progress_cb,
pub progress_payload: *mut c_void,
pub paths: git_strarray,
pub baseline: *mut git_tree,
pub baseline_index: *mut git_index,
pub target_directory: *const c_char,
pub ancestor_label: *const c_char,
pub our_label: *const c_char,
pub their_label: *const c_char,
pub perfdata_cb: git_checkout_perfdata_cb,
pub perfdata_payload: *mut c_void,
}
pub type git_checkout_notify_cb = Option<
extern "C" fn(
git_checkout_notify_t,
*const c_char,
*const git_diff_file,
*const git_diff_file,
*const git_diff_file,
*mut c_void,
) -> c_int,
>;
pub type git_checkout_progress_cb =
Option<extern "C" fn(*const c_char, size_t, size_t, *mut c_void)>;
pub type git_checkout_perfdata_cb =
Option<extern "C" fn(*const git_checkout_perfdata, *mut c_void)>;
#[repr(C)]
pub struct git_checkout_perfdata {
pub mkdir_calls: size_t,
pub stat_calls: size_t,
pub chmod_calls: size_t,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct git_indexer_progress {
pub total_objects: c_uint,
pub indexed_objects: c_uint,
pub received_objects: c_uint,
pub local_objects: c_uint,
pub total_deltas: c_uint,
pub indexed_deltas: c_uint,
pub received_bytes: size_t,
}
pub type git_indexer_progress_cb =
Option<extern "C" fn(*const git_indexer_progress, *mut c_void) -> c_int>;
#[deprecated(
since = "0.10.0",
note = "renamed to `git_indexer_progress` to match upstream"
)]
pub type git_transfer_progress = git_indexer_progress;
pub type git_remote_ready_cb = Option<extern "C" fn(*mut git_remote, c_int, *mut c_void) -> c_int>;
#[repr(C)]
pub struct git_remote_callbacks {
pub version: c_uint,
pub sideband_progress: git_transport_message_cb,
pub completion: Option<extern "C" fn(git_remote_completion_type, *mut c_void) -> c_int>,
pub credentials: git_cred_acquire_cb,
pub certificate_check: git_transport_certificate_check_cb,
pub transfer_progress: git_indexer_progress_cb,
pub update_tips:
Option<extern "C" fn(*const c_char, *const git_oid, *const git_oid, *mut c_void) -> c_int>,
pub pack_progress: git_packbuilder_progress,
pub push_transfer_progress: git_push_transfer_progress,
pub push_update_reference: git_push_update_reference_cb,
pub push_negotiation: git_push_negotiation,
pub transport: git_transport_cb,
pub remote_ready: git_remote_ready_cb,
pub payload: *mut c_void,
pub resolve_url: git_url_resolve_cb,
}
#[repr(C)]
pub struct git_fetch_options {
pub version: c_int,
pub callbacks: git_remote_callbacks,
pub prune: git_fetch_prune_t,
pub update_fetchhead: c_int,
pub download_tags: git_remote_autotag_option_t,
pub proxy_opts: git_proxy_options,
pub follow_redirects: git_remote_redirect_t,
pub custom_headers: git_strarray,
}
git_enum! {
pub enum git_remote_autotag_option_t {
GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED,
GIT_REMOTE_DOWNLOAD_TAGS_AUTO,
GIT_REMOTE_DOWNLOAD_TAGS_NONE,
GIT_REMOTE_DOWNLOAD_TAGS_ALL,
}
}
git_enum! {
pub enum git_fetch_prune_t {
GIT_FETCH_PRUNE_UNSPECIFIED,
GIT_FETCH_PRUNE,
GIT_FETCH_NO_PRUNE,
}
}
git_enum! {
pub enum git_remote_completion_type {
GIT_REMOTE_COMPLETION_DOWNLOAD,
GIT_REMOTE_COMPLETION_INDEXING,
GIT_REMOTE_COMPLETION_ERROR,
}
}
pub type git_transport_message_cb =
Option<extern "C" fn(*const c_char, c_int, *mut c_void) -> c_int>;
pub type git_cred_acquire_cb = Option<
extern "C" fn(*mut *mut git_cred, *const c_char, *const c_char, c_uint, *mut c_void) -> c_int,
>;
pub type git_transfer_progress_cb =
Option<extern "C" fn(*const git_indexer_progress, *mut c_void) -> c_int>;
pub type git_packbuilder_progress =
Option<extern "C" fn(git_packbuilder_stage_t, c_uint, c_uint, *mut c_void) -> c_int>;
pub type git_push_transfer_progress =
Option<extern "C" fn(c_uint, c_uint, size_t, *mut c_void) -> c_int>;
pub type git_transport_certificate_check_cb =
Option<extern "C" fn(*mut git_cert, c_int, *const c_char, *mut c_void) -> c_int>;
pub type git_push_negotiation =
Option<extern "C" fn(*mut *const git_push_update, size_t, *mut c_void) -> c_int>;
pub type git_push_update_reference_cb =
Option<extern "C" fn(*const c_char, *const c_char, *mut c_void) -> c_int>;
pub type git_url_resolve_cb =
Option<extern "C" fn(*mut git_buf, *const c_char, c_int, *mut c_void) -> c_int>;
#[repr(C)]
pub struct git_push_update {
pub src_refname: *mut c_char,
pub dst_refname: *mut c_char,
pub src: git_oid,
pub dst: git_oid,
}
git_enum! {
pub enum git_cert_t {
GIT_CERT_NONE,
GIT_CERT_X509,
GIT_CERT_HOSTKEY_LIBSSH2,
GIT_CERT_STRARRAY,
}
}
#[repr(C)]
pub struct git_cert {
pub cert_type: git_cert_t,
}
#[repr(C)]
pub struct git_cert_hostkey {
pub parent: git_cert,
pub kind: git_cert_ssh_t,
pub hash_md5: [u8; 16],
pub hash_sha1: [u8; 20],
pub hash_sha256: [u8; 32],
pub raw_type: git_cert_ssh_raw_type_t,
pub hostkey: *const c_char,
pub hostkey_len: size_t,
}
#[repr(C)]
pub struct git_cert_x509 {
pub parent: git_cert,
pub data: *mut c_void,
pub len: size_t,
}
git_enum! {
pub enum git_cert_ssh_t {
GIT_CERT_SSH_MD5 = 1 << 0,
GIT_CERT_SSH_SHA1 = 1 << 1,
GIT_CERT_SSH_SHA256 = 1 << 2,
GIT_CERT_SSH_RAW = 1 << 3,
}
}
git_enum! {
pub enum git_cert_ssh_raw_type_t {
GIT_CERT_SSH_RAW_TYPE_UNKNOWN = 0,
GIT_CERT_SSH_RAW_TYPE_RSA = 1,
GIT_CERT_SSH_RAW_TYPE_DSS = 2,
}
}
git_enum! {
pub enum git_diff_flag_t {
GIT_DIFF_FLAG_BINARY = 1 << 0,
GIT_DIFF_FLAG_NOT_BINARY = 1 << 1,
GIT_DIFF_FLAG_VALID_ID = 1 << 2,
GIT_DIFF_FLAG_EXISTS = 1 << 3,
}
}
#[repr(C)]
pub struct git_diff_file {
pub id: git_oid,
pub path: *const c_char,
pub size: git_object_size_t,
pub flags: u32,
pub mode: u16,
pub id_abbrev: u16,
}
pub type git_repository_create_cb =
Option<extern "C" fn(*mut *mut git_repository, *const c_char, c_int, *mut c_void) -> c_int>;
pub type git_remote_create_cb = Option<
extern "C" fn(
*mut *mut git_remote,
*mut git_repository,
*const c_char,
*const c_char,
*mut c_void,
) -> c_int,
>;
git_enum! {
pub enum git_checkout_notify_t {
GIT_CHECKOUT_NOTIFY_NONE = 0,
GIT_CHECKOUT_NOTIFY_CONFLICT = 1 << 0,
GIT_CHECKOUT_NOTIFY_DIRTY = 1 << 1,
GIT_CHECKOUT_NOTIFY_UPDATED = 1 << 2,
GIT_CHECKOUT_NOTIFY_UNTRACKED = 1 << 3,
GIT_CHECKOUT_NOTIFY_IGNORED = 1 << 4,
GIT_CHECKOUT_NOTIFY_ALL = 0x0FFFF,
}
}
git_enum! {
pub enum git_status_t {
GIT_STATUS_CURRENT = 0,
GIT_STATUS_INDEX_NEW = 1 << 0,
GIT_STATUS_INDEX_MODIFIED = 1 << 1,
GIT_STATUS_INDEX_DELETED = 1 << 2,
GIT_STATUS_INDEX_RENAMED = 1 << 3,
GIT_STATUS_INDEX_TYPECHANGE = 1 << 4,
GIT_STATUS_WT_NEW = 1 << 7,
GIT_STATUS_WT_MODIFIED = 1 << 8,
GIT_STATUS_WT_DELETED = 1 << 9,
GIT_STATUS_WT_TYPECHANGE = 1 << 10,
GIT_STATUS_WT_RENAMED = 1 << 11,
GIT_STATUS_WT_UNREADABLE = 1 << 12,
GIT_STATUS_IGNORED = 1 << 14,
GIT_STATUS_CONFLICTED = 1 << 15,
}
}
git_enum! {
pub enum git_status_opt_t {
GIT_STATUS_OPT_INCLUDE_UNTRACKED = 1 << 0,
GIT_STATUS_OPT_INCLUDE_IGNORED = 1 << 1,
GIT_STATUS_OPT_INCLUDE_UNMODIFIED = 1 << 2,
GIT_STATUS_OPT_EXCLUDE_SUBMODULES = 1 << 3,
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = 1 << 4,
GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH = 1 << 5,
GIT_STATUS_OPT_RECURSE_IGNORED_DIRS = 1 << 6,
GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX = 1 << 7,
GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR = 1 << 8,
GIT_STATUS_OPT_SORT_CASE_SENSITIVELY = 1 << 9,
GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY = 1 << 10,
GIT_STATUS_OPT_RENAMES_FROM_REWRITES = 1 << 11,
GIT_STATUS_OPT_NO_REFRESH = 1 << 12,
GIT_STATUS_OPT_UPDATE_INDEX = 1 << 13,
GIT_STATUS_OPT_INCLUDE_UNREADABLE = 1 << 14,
GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED = 1 << 15,
}
}
git_enum! {
pub enum git_status_show_t {
GIT_STATUS_SHOW_INDEX_AND_WORKDIR = 0,
GIT_STATUS_SHOW_INDEX_ONLY = 1,
GIT_STATUS_SHOW_WORKDIR_ONLY = 2,
}
}
git_enum! {
pub enum git_delta_t {
GIT_DELTA_UNMODIFIED,
GIT_DELTA_ADDED,
GIT_DELTA_DELETED,
GIT_DELTA_MODIFIED,
GIT_DELTA_RENAMED,
GIT_DELTA_COPIED,
GIT_DELTA_IGNORED,
GIT_DELTA_UNTRACKED,
GIT_DELTA_TYPECHANGE,
GIT_DELTA_UNREADABLE,
GIT_DELTA_CONFLICTED,
}
}
#[repr(C)]
pub struct git_status_options {
pub version: c_uint,
pub show: git_status_show_t,
pub flags: c_uint,
pub pathspec: git_strarray,
pub baseline: *mut git_tree,
pub rename_threshold: u16,
}
#[repr(C)]
pub struct git_diff_delta {
pub status: git_delta_t,
pub flags: u32,
pub similarity: u16,
pub nfiles: u16,
pub old_file: git_diff_file,
pub new_file: git_diff_file,
}
#[repr(C)]
pub struct git_status_entry {
pub status: git_status_t,
pub head_to_index: *mut git_diff_delta,
pub index_to_workdir: *mut git_diff_delta,
}
git_enum! {
pub enum git_checkout_strategy_t {
GIT_CHECKOUT_NONE = 0,
GIT_CHECKOUT_SAFE = 1 << 0,
GIT_CHECKOUT_FORCE = 1 << 1,
GIT_CHECKOUT_RECREATE_MISSING = 1 << 2,
GIT_CHECKOUT_ALLOW_CONFLICTS = 1 << 4,
GIT_CHECKOUT_REMOVE_UNTRACKED = 1 << 5,
GIT_CHECKOUT_REMOVE_IGNORED = 1 << 6,
GIT_CHECKOUT_UPDATE_ONLY = 1 << 7,
GIT_CHECKOUT_DONT_UPDATE_INDEX = 1 << 8,
GIT_CHECKOUT_NO_REFRESH = 1 << 9,
GIT_CHECKOUT_SKIP_UNMERGED = 1 << 10,
GIT_CHECKOUT_USE_OURS = 1 << 11,
GIT_CHECKOUT_USE_THEIRS = 1 << 12,
GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH = 1 << 13,
GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES = 1 << 18,
GIT_CHECKOUT_DONT_OVERWRITE_IGNORED = 1 << 19,
GIT_CHECKOUT_CONFLICT_STYLE_MERGE = 1 << 20,
GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 = 1 << 21,
GIT_CHECKOUT_UPDATE_SUBMODULES = 1 << 16,
GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = 1 << 17,
}
}
git_enum! {
pub enum git_reset_t {
GIT_RESET_SOFT = 1,
GIT_RESET_MIXED = 2,
GIT_RESET_HARD = 3,
}
}
git_enum! {
pub enum git_object_t: c_int {
GIT_OBJECT_ANY = -2,
GIT_OBJECT_INVALID = -1,
GIT_OBJECT_COMMIT = 1,
GIT_OBJECT_TREE = 2,
GIT_OBJECT_BLOB = 3,
GIT_OBJECT_TAG = 4,
GIT_OBJECT_OFS_DELTA = 6,
GIT_OBJECT_REF_DELTA = 7,
}
}
git_enum! {
pub enum git_reference_t {
GIT_REFERENCE_INVALID = 0,
GIT_REFERENCE_DIRECT = 1,
GIT_REFERENCE_SYMBOLIC = 2,
GIT_REFERENCE_ALL = GIT_REFERENCE_DIRECT | GIT_REFERENCE_SYMBOLIC,
}
}
git_enum! {
pub enum git_filemode_t {
GIT_FILEMODE_UNREADABLE = 0o000000,
GIT_FILEMODE_TREE = 0o040000,
GIT_FILEMODE_BLOB = 0o100644,
GIT_FILEMODE_BLOB_EXECUTABLE = 0o100755,
GIT_FILEMODE_LINK = 0o120000,
GIT_FILEMODE_COMMIT = 0o160000,
}
}
git_enum! {
pub enum git_treewalk_mode {
GIT_TREEWALK_PRE = 0,
GIT_TREEWALK_POST = 1,
}
}
pub type git_treewalk_cb =
Option<extern "C" fn(*const c_char, *const git_tree_entry, *mut c_void) -> c_int>;
pub type git_treebuilder_filter_cb =
Option<extern "C" fn(*const git_tree_entry, *mut c_void) -> c_int>;
pub type git_revwalk_hide_cb = Option<extern "C" fn(*const git_oid, *mut c_void) -> c_int>;
git_enum! {
pub enum git_tree_update_t {
GIT_TREE_UPDATE_UPSERT = 0,
GIT_TREE_UPDATE_REMOVE = 1,
}
}
#[repr(C)]
pub struct git_tree_update {
pub action: git_tree_update_t,
pub id: git_oid,
pub filemode: git_filemode_t,
pub path: *const c_char,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct git_buf {
pub ptr: *mut c_char,
pub reserved: size_t,
pub size: size_t,
}
git_enum! {
pub enum git_branch_t {
GIT_BRANCH_LOCAL = 1,
GIT_BRANCH_REMOTE = 2,
GIT_BRANCH_ALL = GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE,
}
}
pub const GIT_BLAME_NORMAL: u32 = 0;
pub const GIT_BLAME_TRACK_COPIES_SAME_FILE: u32 = 1 << 0;
pub const GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES: u32 = 1 << 1;
pub const GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES: u32 = 1 << 2;
pub const GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES: u32 = 1 << 3;
pub const GIT_BLAME_FIRST_PARENT: u32 = 1 << 4;
pub const GIT_BLAME_USE_MAILMAP: u32 = 1 << 5;
pub const GIT_BLAME_IGNORE_WHITESPACE: u32 = 1 << 6;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct git_blame_options {
pub version: c_uint,
pub flags: u32,
pub min_match_characters: u16,
pub newest_commit: git_oid,
pub oldest_commit: git_oid,
pub min_line: usize,
pub max_line: usize,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct git_blame_hunk {
pub lines_in_hunk: usize,
pub final_commit_id: git_oid,
pub final_start_line_number: usize,
pub final_signature: *mut git_signature,
pub orig_commit_id: git_oid,
pub orig_path: *const c_char,
pub orig_start_line_number: usize,
pub orig_signature: *mut git_signature,
pub boundary: c_char,
}
pub type git_index_matched_path_cb =
Option<extern "C" fn(*const c_char, *const c_char, *mut c_void) -> c_int>;
git_enum! {
pub enum git_index_entry_extended_flag_t {
GIT_INDEX_ENTRY_INTENT_TO_ADD = 1 << 13,
GIT_INDEX_ENTRY_SKIP_WORKTREE = 1 << 14,
GIT_INDEX_ENTRY_UPTODATE = 1 << 2,
}
}
git_enum! {
pub enum git_index_entry_flag_t {
GIT_INDEX_ENTRY_EXTENDED = 0x4000,
GIT_INDEX_ENTRY_VALID = 0x8000,
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct git_index_entry {
pub ctime: git_index_time,
pub mtime: git_index_time,
pub dev: u32,
pub ino: u32,
pub mode: u32,
pub uid: u32,
pub gid: u32,
pub file_size: u32,
pub id: git_oid,
pub flags: u16,
pub flags_extended: u16,
pub path: *const c_char,
}
pub const GIT_INDEX_ENTRY_NAMEMASK: u16 = 0xfff;
pub const GIT_INDEX_ENTRY_STAGEMASK: u16 = 0x3000;
pub const GIT_INDEX_ENTRY_STAGESHIFT: u16 = 12;
#[repr(C)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct git_index_time {
pub seconds: i32,
pub nanoseconds: u32,
}
#[repr(C)]
pub struct git_config_entry {
pub name: *const c_char,
pub value: *const c_char,
pub include_depth: c_uint,
pub level: git_config_level_t,
pub free: Option<extern "C" fn(*mut git_config_entry)>,
pub payload: *mut c_void,
}
git_enum! {
pub enum git_config_level_t: c_int {
GIT_CONFIG_LEVEL_PROGRAMDATA = 1,
GIT_CONFIG_LEVEL_SYSTEM = 2,
GIT_CONFIG_LEVEL_XDG = 3,
GIT_CONFIG_LEVEL_GLOBAL = 4,
GIT_CONFIG_LEVEL_LOCAL = 5,
GIT_CONFIG_LEVEL_APP = 6,
GIT_CONFIG_HIGHEST_LEVEL = -1,
}
}
git_enum! {
pub enum git_submodule_update_t {
GIT_SUBMODULE_UPDATE_CHECKOUT = 1,
GIT_SUBMODULE_UPDATE_REBASE = 2,
GIT_SUBMODULE_UPDATE_MERGE = 3,
GIT_SUBMODULE_UPDATE_NONE = 4,
GIT_SUBMODULE_UPDATE_DEFAULT = 0,
}
}
git_enum! {
pub enum git_submodule_ignore_t: c_int {
GIT_SUBMODULE_IGNORE_UNSPECIFIED = -1,
GIT_SUBMODULE_IGNORE_NONE = 1,
GIT_SUBMODULE_IGNORE_UNTRACKED = 2,
GIT_SUBMODULE_IGNORE_DIRTY = 3,
GIT_SUBMODULE_IGNORE_ALL = 4,
}
}
pub type git_submodule_cb =
Option<extern "C" fn(*mut git_submodule, *const c_char, *mut c_void) -> c_int>;
#[repr(C)]
pub struct git_submodule_update_options {
pub version: c_uint,
pub checkout_opts: git_checkout_options,
pub fetch_opts: git_fetch_options,
pub allow_fetch: c_int,
}
#[repr(C)]
pub struct git_writestream {
pub write: Option<extern "C" fn(*mut git_writestream, *const c_char, size_t) -> c_int>,
pub close: Option<extern "C" fn(*mut git_writestream) -> c_int>,
pub free: Option<extern "C" fn(*mut git_writestream)>,
}
git_enum! {
pub enum git_attr_value_t {
GIT_ATTR_VALUE_UNSPECIFIED = 0,
GIT_ATTR_VALUE_TRUE,
GIT_ATTR_VALUE_FALSE,
GIT_ATTR_VALUE_STRING,
}
}
pub const GIT_ATTR_CHECK_FILE_THEN_INDEX: u32 = 0;
pub const GIT_ATTR_CHECK_INDEX_THEN_FILE: u32 = 1;
pub const GIT_ATTR_CHECK_INDEX_ONLY: u32 = 2;
pub const GIT_ATTR_CHECK_NO_SYSTEM: u32 = 1 << 2;
pub const GIT_ATTR_CHECK_INCLUDE_HEAD: u32 = 1 << 3;
#[repr(C)]
pub struct git_cred {
pub credtype: git_credtype_t,
pub free: Option<extern "C" fn(*mut git_cred)>,
}
git_enum! {
pub enum git_credtype_t {
GIT_CREDTYPE_USERPASS_PLAINTEXT = 1 << 0,
GIT_CREDTYPE_SSH_KEY = 1 << 1,
GIT_CREDTYPE_SSH_CUSTOM = 1 << 2,
GIT_CREDTYPE_DEFAULT = 1 << 3,
GIT_CREDTYPE_SSH_INTERACTIVE = 1 << 4,
GIT_CREDTYPE_USERNAME = 1 << 5,
GIT_CREDTYPE_SSH_MEMORY = 1 << 6,
}
}
pub type git_cred_ssh_interactive_callback = Option<
extern "C" fn(
name: *const c_char,
name_len: c_int,
instruction: *const c_char,
instruction_len: c_int,
num_prompts: c_int,
prompts: *const LIBSSH2_USERAUTH_KBDINT_PROMPT,
responses: *mut LIBSSH2_USERAUTH_KBDINT_RESPONSE,
abstrakt: *mut *mut c_void,
),
>;
pub type git_cred_sign_callback = Option<
extern "C" fn(
session: *mut LIBSSH2_SESSION,
sig: *mut *mut c_uchar,
sig_len: *mut size_t,
data: *const c_uchar,
data_len: size_t,
abstrakt: *mut *mut c_void,
),
>;
pub enum LIBSSH2_SESSION {}
pub enum LIBSSH2_USERAUTH_KBDINT_PROMPT {}
pub enum LIBSSH2_USERAUTH_KBDINT_RESPONSE {}
#[repr(C)]
pub struct git_push_options {
pub version: c_uint,
pub pb_parallelism: c_uint,
pub callbacks: git_remote_callbacks,
pub proxy_opts: git_proxy_options,
pub follow_redirects: git_remote_redirect_t,
pub custom_headers: git_strarray,
}
pub type git_tag_foreach_cb =
Option<extern "C" fn(name: *const c_char, oid: *mut git_oid, payload: *mut c_void) -> c_int>;
git_enum! {
pub enum git_index_add_option_t {
GIT_INDEX_ADD_DEFAULT = 0,
GIT_INDEX_ADD_FORCE = 1 << 0,
GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH = 1 << 1,
GIT_INDEX_ADD_CHECK_PATHSPEC = 1 << 2,
}
}
git_enum! {
pub enum git_repository_open_flag_t {
GIT_REPOSITORY_OPEN_NO_SEARCH = 1 << 0,
GIT_REPOSITORY_OPEN_CROSS_FS = 1 << 1,
GIT_REPOSITORY_OPEN_BARE = 1 << 2,
GIT_REPOSITORY_OPEN_NO_DOTGIT = 1 << 3,
GIT_REPOSITORY_OPEN_FROM_ENV = 1 << 4,
}
}
#[repr(C)]
pub struct git_repository_init_options {
pub version: c_uint,
pub flags: u32,
pub mode: u32,
pub workdir_path: *const c_char,
pub description: *const c_char,
pub template_path: *const c_char,
pub initial_head: *const c_char,
pub origin_url: *const c_char,
}
pub const GIT_REPOSITORY_INIT_OPTIONS_VERSION: c_uint = 1;
git_enum! {
pub enum git_repository_init_flag_t {
GIT_REPOSITORY_INIT_BARE = 1 << 0,
GIT_REPOSITORY_INIT_NO_REINIT = 1 << 1,