-
Notifications
You must be signed in to change notification settings - Fork 8
/
libgit2.vapi
7566 lines (7110 loc) · 238 KB
/
libgit2.vapi
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
/*
* libgit2 Vala binding
*
* Homepage: http://libgit2.github.com/
* VAPI Homepage: https://github.com/apmasell/vapis/blob/master/libgit2.vapi
* VAPI Maintainer: Andre Masella <[email protected]>
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
/**
* Library to access the contents of git repositories
*
* libgit2 can access and manipulate the contents of git repositories. To begin, create an instance of a {@link Git.Repository} like so:
* {{{
* Git.Repository? repo;
* if (Git.Repository.open(out repo, "/path/to/repo") != Git.Error.OK) {
* stderr.printf("Could not open repository because: %s\n", Git.ErrorInfo.get_last().message);
* return false;
* }
* }}}
* Then use the methods of //repo// to access the repository.
*/
[CCode (cheader_filename = "git2.h")]
namespace Git {
namespace Configuration {
/**
* Generic backend that implements the interface to
* access a configuration file
*/
[CCode (cname = "git_config_backend", has_type_id = false, default_value = "GIT_CONFIG_BACKEND_INIT")]
public struct backend {
[CCode (cname = "GIT_CONFIG_BACKEND_VERSION")]
public const uint VERSION;
public uint version;
public unowned Config cfg;
public Delete @delete;
[CCode (cname = "foreach")]
public ForEach for_each;
public Free free;
public Get @get;
[CCode (cname = "get_multivar")]
public GetMulti get_multi;
[CCode (cname = "refersh")]
public Refresh refresh;
public Open open;
public Set @set;
public SetMulti set_multi;
}
[CCode (cname = "git_config_file_delete_cb", has_type_id = false, has_target = false)]
public delegate int Delete (backend backend, string key);
[CCode (cname = "git_config_file_foreach_cb", has_type_id = false, has_target = false)]
public delegate int ForEach (backend backend, string regex, ConfigForEach config_for_each);
[CCode (cname = "git_config_file_free_cb", has_type_id = false, has_target = false)]
public delegate void Free (backend backend);
[CCode (cname = "git_config_file_get_cb", has_type_id = false, has_target = false)]
public delegate int Get (backend backend, string key, out string value);
[CCode (cname = "git_config_file_get_mulivar_cb", has_type_id = false, has_target = false)]
public delegate int GetMulti (backend backend, string key, string? regexp, Setter func);
[CCode (cname = "git_config_file_refresh", has_type_id = false, has_target = false)]
public delegate Error Refresh (backend backend);
[CCode (cname = "git_config_file_set_cb", has_type_id = false, has_target = false)]
public delegate int Setter (string val);
[CCode (cname = "git_config_file_open_cb", has_type_id = false, has_target = false)]
public delegate int Open (backend backend);
[CCode (cname = "git_config_file_set_cb", has_type_id = false, has_target = false)]
public delegate int Set (backend backend, string key, string value);
[CCode (cname = "git_config_file_set_multivar_cb", has_type_id = false, has_target = false)]
public delegate int SetMulti (backend backend, string name, string regexp, string val);
}
namespace Database {
/**
* An open object database handle
*/
[CCode (cname = "git_odb", free_function = "git_odb_close", has_type_id = false)]
[Compact]
public class Handle {
/**
* Create a new object database with no backends.
*
* Before the ODB can be used for read/writing, a custom database
* backend must be manually added using {@link Handle.add_backend}.
*
* @param db location to store the database pointer, if opened. Set to null if the open failed.
*/
[CCode (cname = "git_odb_new")]
public static Error create (out Handle? db);
/**
* Create a new object database and automatically add
* the two default backends.
*
* Automatically added are:
* - {@link backend.create_loose}: read and write loose object files
* from disk, assuming //objects_dir// as the Objects folder
*
* - {@link backend.create_pack}: read objects from packfiles,
* assuming //objects_dir// as the Objects folder which
* contains a //pack// folder with the corresponding data
*
* @param db location to store the database pointer, if opened.
* Set to null if the open failed.
* @param objects_dir path of the backends' //objects// directory.
*/
[CCode (cname = "git_odb_open")]
public static Error open (out Handle db, string objects_dir);
/**
* Add a custom backend to an existing Object DB; this
* backend will work as an alternate.
*
* Alternate backends are always checked for objects ''after''
* all the main backends have been exhausted.
*
* The backends are checked in relative ordering, based on the
* value of the //priority// parameter.
*
* Writing is disabled on alternate backends.
*
* @param backend the backend instance
* @param priority Value for ordering the backends queue
*/
[CCode (cname = "git_odb_add_alternate")]
public Error add_alternate (backend backend, int priority);
/**
* Add a custom backend to an existing Object DB
*
* The backends are checked in relative ordering, based on the
* value of the //priority// parameter.
* @param backend the backend instance
* @param priority Value for ordering the backends queue
*/
[CCode (cname = "git_odb_add_backend")]
public Error add_backend (backend backend, int priority);
/**
* Determine if the given object can be found in the object database.
*
* @param id the object to search for.
*/
[CCode (cname = "git_odb_exists")]
public bool contains (object_id id);
/**
* Create a "fake" repository to wrap an object database
*
* Create a repository object to wrap an object database to be used with
* the API when all you have is an object database. This doesn't have any
* paths associated with it, so use with care.
*/
[CCode (cname = "git_repository_wrap_odb", instance_pos = -1)]
public Error create_repository (out Repository? repository);
/**
* List all objects available in the database
*
* The callback will be called for each object available in the
* database. Note that the objects are likely to be returned in the index
* order, which would make accessing the objects in that order inefficient.
*/
[CCode (cname = "git_odb_foreach")]
public Error for_each (ObjectIdForEach object_for_each);
/**
* Read an object from the database.
*
* This method queries all available ODB backends
* trying to read the given id.
*
* @param obj pointer where to store the read object
* @param id identity of the object to read.
*/
[CCode (cname = "git_odb_read", instance_pos = 1.2)]
public Error read (out Object obj, object_id id);
/**
* Read an object from the database, given a prefix
* of its identifier.
*
* This method queries all available ODB backends
* trying to match the //len// first hexadecimal
* characters of the //short_id//.
* The remaining //({@link object_id.HEX_SIZE}-len)*4// bits of
* //short_id// must be 0s.
* //len// must be at least {@link object_id.MIN_PREFIX_LENGTH},
* and the prefix must be long enough to identify
* a unique object in all the backends; the
* method will fail otherwise.
*
* The returned object is reference counted and
* internally cached, so it should be closed
* by the user once it's no longer in use.
*
* @param obj pointer where to store the read object
* @param short_id a prefix of the id of the object to read.
* @param len the length of the prefix
*/
[CCode (cname = "git_odb_read_prefix", instance_pos = 1.2)]
public Error read_by_prefix (out Object obj, object_id short_id, size_t len);
/**
* Read the header of an object from the database, without
* reading its full contents.
*
* The header includes the length and the type of an object.
*
* Note that most backends do not support reading only the header
* of an object, so the whole object will be read and then the
* header will be returned.
*
* @param len the length of the object
* @param type the type of the object
* @param id identity of the object to read.
*/
[CCode (cname = "git_odb_read_header", instance_pos = 2.3)]
public Error read_header (out size_t len, out ObjectType type, object_id id);
/**
* Refresh the object database to load newly added files.
*
* If the object databases have changed on disk while the library is
* running, this function will force a reload of the underlying indexes.
*
* Use this function when you're confident that an external application
* has tampered with the ODB.
*
* Note that it is not necessary to call this function at all. The
* library will automatically attempt to refresh the ODB when a lookup
* fails, to see if the looked up object exists on disk but hasn't been
* loaded yet.
*/
[CCode (cname = "git_odb_refresh")]
public Error refresh ();
/**
* Open a stream to write an object into the ODB
*
* The type and final length of the object must be specified
* when opening the stream.
*
* The returned stream will be of type {@link StreamMode.WRONLY} and
* will have the following methods:
*
* * {@link stream.write}: write //n// bytes into the stream
* * {@link stream.finalize_write}: close the stream and store the object in the ODB
*
* The streaming write won't be effective until {@link stream.finalize_write}
* is called and returns without an error
*
* @param stream where to store the stream
* @param size final size of the object that will be written
* @param type type of the object that will be written
*/
[CCode (cname = "git_odb_open_wstream", instance_pos = 1.2)]
public Error open_write_stream (out stream stream, size_t size, ObjectType type);
/**
* Open a stream to read an object from the ODB
*
* Note that most backends do ''not'' support streaming reads
* because they store their objects as compressed/delta'ed blobs.
*
* It's recommended to use {@link Handle.read} instead, which is
* assured to work on all backends.
*
* The returned stream will be of type {@link StreamMode.RDONLY} and
* will have the following methods:
*
* * {@link stream.read}: read //n// bytes from the stream
*
* @param stream where to store the stream
* @param id id of the object the stream will read from
*/
[CCode (cname = "git_odb_open_rstream")]
public Error open_read_stream (out stream stream, object_id id);
/**
* Write an object directly into the ODB
*
* This method writes a full object straight into the ODB.
* For most cases, it is preferred to write objects through a write
* stream, which is both faster and less memory intensive, specially
* for big objects.
*
* This method is provided for compatibility with custom backends
* which are not able to support streaming writes
*
* @param id pointer to store the id result of the write
* @param data buffer with the data to store
* @param type type of the data to store
*/
[CCode (cname = "git_odb_write", instance_pos = 1.2)]
public Error write (object_id id, [CCode (array_length_Type = "size_t")] uint8[] data, ObjectType type);
}
/**
* An object read from the database
*/
[CCode (cname = "git_odb_object", free_function = "git_odb_object_free", has_type_id = false)]
[Compact]
public class Object {
/**
* The data of an ODB object
*
* This is the uncompressed, raw data as read from the ODB,
* without the leading header.
*/
public uint8[] data {
[CCode (cname = "git_odb_object_data", array_length_cexpr = "git_odb_object_size")]
get;
}
/**
* The id of an ODB object
*/
public object_id? id {
[CCode (cname = "git_odb_object_id")]
get;
}
/**
* The type of an ODB object
*/
public ObjectType type {
[CCode (cname = "git_odb_object_type")]
get;
}
}
/**
* A custom backend in an ODB
*/
[CCode (cname = "git_odb_backend", has_type_id = false, default_value = "GIT_ODB_BACKEND_INIT")]
public struct backend {
[CCode (cname = "GIT_ODB_BACKEND_VERSION")]
public const uint VERSION;
public uint version;
public unowned Handle odb;
public BackendExists exists;
public BackendFree free;
[CCode (cname = "foreach")]
public BackendForEach for_each;
public BackendRead read;
public BackendReadHeader read_header;
public BackendReadPrefix read_prefix;
[CCode (cname = "readstream")]
public BackendReadStream read_stream;
public BackendWrite write;
public BackendWritePack write_pack;
[CCode (cname = "writestream")]
public BackendWriteStream write_stream;
[CCode (cname = "git_odb_backend_loose")]
public static Error create_loose (out backend backend, string objects_dir);
[CCode (cname = "git_odb_backend_one_pack")]
public static Error create_one_pack (out backend backend, string index_file);
[CCode (cname = "git_odb_backend_pack")]
public static Error create_pack (out backend backend, string objects_dir);
[CCode (cname = "git_odb_backend_malloc", simple_generics = true)]
public T malloc<T> (size_t len);
}
/**
* A stream to read/write from the ODB
*/
[CCode (cname = "git_odb_stream", has_type_id = false)]
public struct stream {
public unowned backend? backend;
public StreamMode mode;
public StreamFinalizeWrite finalize_write;
public StreamFree free;
public StreamRead read;
public StreamWrite write;
}
/**
* A stream to write a pack file to the ODB
*/
[CCode (cname = "git_odb_writepack", has_type_id = false)]
public struct write_pack {
public unowned backend? backend;
[CCode (cname = "add")]
public WritePackAdd add;
[CCode (cname = "commit")]
public WritePackCommit commit;
[CCode (cname = "free")]
public WritePackFree free;
}
/**
* Streaming mode
*/
[CCode (cname = "git_odb_streammode", cprefix = "GIT_STREAM_", has_type_id = false)]
public enum StreamMode {
RDONLY,
WRONLY,
RW
}
[CCode (has_target = false, has_type_id = false)]
public delegate bool BackendExists (backend self, object_id id);
[CCode (has_target = false, has_type_id = false)]
public delegate void BackendFree (backend self);
[CCode (has_target = false, has_type_id = false)]
public delegate Error BackendForEach (backend self, ObjectIdForEach cb);
/**
* Read each return to libgit2 a buffer which will be freed later.
*
* The buffer should be allocated using the function {@link backend.malloc} to
* ensure that it can be safely freed later.
*/
[CCode (has_target = false, has_type_id = false)]
public delegate Error BackendRead ([CCode (array_length_type = "size_t")] out uint8[] data, out ObjectType type, backend self, object_id id);
/**
* Find a unique object given a prefix
*
* The id given must be so that the remaining
* ({@link object_id.HEX_SIZE} - len)*4 bits are 0s.
*/
[CCode (has_target = false, has_type_id = false)]
public delegate Error BackendReadHeader (out size_t size, out ObjectType type, backend self, object_id id);
[CCode (has_target = false, has_type_id = false)]
public delegate Error BackendReadPrefix (out object_id id, [CCode (array_length_type = "size_t")] out uint8[] data, out ObjectType type, backend self, object_id id_prefix, size_t len);
[CCode (has_target = false, has_type_id = false)]
public delegate Error BackendReadStream (out stream stream, backend self, object_id id);
[CCode (has_target = false, has_type_id = false)]
public delegate Error BackendWrite (out object_id id, backend self, [CCode (array_length_type = "size_t")] out uint8[] data, ObjectType type);
[CCode (has_target = false, has_type_id = false)]
public delegate Error BackendWriteStream (out stream stream, backend self, size_t size, ObjectType type);
[CCode (has_target = false, has_type_id = false)]
public delegate int BackendWritePack (out write_pack write_pack, backend self, TransferProgress progress);
[CCode (has_target = false, has_type_id = false)]
public delegate Error StreamFinalizeWrite (out object_id id, stream stream);
[CCode (has_target = false, has_type_id = false)]
public delegate void StreamFree (stream stream);
[CCode (has_target = false, has_type_id = false)]
public delegate int StreamRead (stream stream, [CCode (array_length_type = "size_t")] uint8[] buffer);
[CCode (has_target = false, has_type_id = false)]
public delegate int StreamWrite (stream stream, [CCode (array_length_type = "size_t")] uint8[] buffer);
[CCode (has_target = false)]
public delegate int WritePackAdd (write_pack write_pack, [CCode (array_length_type = "size_t")] uint8[] data, transfer_progress stats);
[CCode (has_target = false)]
public delegate int WritePackCommit (write_pack write_pack, transfer_progress stats);
[CCode (has_target = false)]
public delegate void WritePackFree (write_pack write_pack);
}
namespace Threads {
/**
* Init the threading system.
*
* If libgit2 has been built with GIT_THREADS
* on, this function must be called once before
* any other library functions.
*
* If libgit2 has been built without GIT_THREADS
* support, this function is a no-op.
*/
[CCode (cname = "git_threads_init")]
public Error init ();
/**
* Shutdown the threading system.
*
* If libgit2 has been built with GIT_THREADS
* on, this function must be called before shutting
* down the library.
*
* If libgit2 has been built without GIT_THREADS
* support, this function is a no-op.
*/
[CCode (cname = "git_threads_shutdown")]
public void shutdown ();
}
namespace Version {
[CCode (cname = "LIBGIT2_VERSION")]
public const string VERSION;
[CCode (cname = "LIBGIT2_VER_MAJOR")]
public const int MAJOR;
[CCode (cname = "LIBGIT2_VER_MINOR")]
public const int MINOR;
[CCode (cname = "LIBGIT2_VER_REVISION")]
public const int REVISION;
/**
* Return the version of the libgit2 library
* being currently used.
*
* @param major Store the major version number
* @param minor Store the minor version number
* @param rev Store the revision (patch) number
*/
[CCode (cname = "git_libgit2_version")]
public void get_version (out int major, out int minor, out int rev);
}
/*
* Attribute management routines
*/
[CCode (cname = "git_repository", cheader_filename = "git2/attr.h", has_type_id = false)]
public class Attr {
[CCode (cname = "git_attr_t", cprefix = "GIT_ATTR_", has_type_id = false)]
public enum AttrType {
[CCode (cname = "GIT_ATTR_UNSPECIFIED_T")]
UNSPECIFIED,
[CCode (cname = "GIT_ATTR_TRUE_T")]
TRUE,
[CCode (cname = "GIT_ATTR_FALSE_T")]
FALSE,
[CCode (cname = "GIT_ATTR_VALUE_T")]
VALUE;
/**
* Return the value type for a given attribute.
*
* This can be either {@link TRUE}, {@link FALSE}, {@link UNSPECIFIED}
* (if the attribute was not set at all), or {@link VALUE}, if the
* attribute was set to an actual string.
*
* If the attribute has a {@link VALUE} string, it can be accessed
* normally as a string.
*/
[CCode (cname = "git_attr_value")]
public static AttrType from (string attr);
}
/**
* Checks if an attribute is set on.
*
* In core git parlance, this the value for "Set" attributes.
*/
[CCode (cname = "GIT_ATTR_TRUE")]
public static bool is_true (string? attr);
/**
* Checks if an attribute is set off.
*
* In core git parlance, this is the value for attributes that are "Unset"
* (not to be confused with values that a "Unspecified").
*/
[CCode (cname = "GIT_ATTR_FALSE")]
public static bool is_false (string? attr);
/**
* Checks if an attribute is set to a value (as opposied to TRUE, FALSE or
* UNSPECIFIED).
*/
[CCode (cname = "GIT_ATTR_SET_TO_VALUE")]
public static bool is_set (string? attr);
/*
* Checks if an attribute is unspecified. This may be due to the attribute
* not being mentioned at all or because the attribute was explicitly set
* unspecified via the `!` operator.
*/
[CCode (cname = "GIT_ATTR_UNSPECIFIED")]
public static bool is_unspecified (string? attr);
/**
* Add a macro definition.
*
* Macros will automatically be loaded from the top level .gitattributes
* file of the repository (plus the build-in "binary" macro). This
* function allows you to add others. For example, to add the default
* macro, you would call:
* {{{
* repo.attributes.add_macro("binary", "-diff -crlf");
* }}}
*/
[CCode (cname = "git_attr_add_macro")]
public Error add_macro (string name, string val);
/**
* Lookup attribute for path returning string caller must free
*/
[CCode (cname = "git_attr_get")]
public Error lookup (AttrCheck flags, string path, string name, out unowned string? val);
/**
* Lookup list of attributes for path, populating array of strings
*
* Use this if you have a known list of attributes that you want to
* look up in a single call. This is somewhat more efficient than
* calling {@link lookup} multiple times.
*
* For example, you might write:
* {{{
* string attrs[] = { "crlf", "diff", "foo" };
* string results[];
* repo.attributes.lookup_many(AttrCheck.FILE_THEN_INDEX, "my/fun/file.c", attrs, out values);
* }}}
* Then you could loop through the 3 values to get the settings for
* the three attributes you asked about.
*
* @param path The path inside the repo to check attributes. This does not
* have to exist, but if it does not, then it will be treated as a plain
* file (i.e. not a directory).
* @param names The attribute names.
* @param values The values of the attributes.
*/
[CCode (cname = "_vala_git_attr_get_many")]
public Error lookup_many (AttrCheck flags, string path, string[] names, out string[] values) {
unstr[] temp = new unstr[names.length];
var e = _lookup_many (flags, path, names, temp);
values = new string[names.length];
for (var it = 0; it < temp.length; it++) {
values[it] = temp[it].dup ();
}
return e;
}
[CCode (cname = "git_attr_get_many")]
private Error _lookup_many (AttrCheck flags, string path, [CCode (array_length_pos = 2.1, array_length_type = "size_t")] string[] names, void* values);
/**
* Perform an operation on each attribute of a path.
* @param path The path inside the repo to check attributes. This does not
* have to exist, but if it does not, then it will be treated as a plain
* file (i.e. not a directory).
* @param attribute_for_each The function that will be invoked on each
* attribute and attribute value. The name parameter will be the name of
* the attribute and the value will be the value it is set to, including
* possibly null if the attribute is explicitly set to UNSPECIFIED using
* the ! sign. This will be invoked only once per attribute name, even if
* there are multiple rules for a given file. The highest priority rule
* will be used.
*/
[CCode (cname = "git_attr_foreach")]
public Error for_each (AttrCheck flags, string path, AttributeForEach attribute_for_each);
/**
* Flush the gitattributes cache.
*
* Call this if you have reason to believe that the attributes files
* on disk no longer match the cached contents of memory. This will cause
* the attributes files to be reloaded the next time that an attribute
* access function is called.
*/
[CCode (cname = "git_attr_cache_flush")]
public void flush ();
}
/**
* In-memory representation of a blob object.
*/
[CCode (cname = "git_blob", free_function = "git_blob_free", has_type_id = false)]
[Compact]
public class Blob : Object {
[CCode (array_length = false, cname = "git_blob_rawcontent")]
private unowned uint8[]? _get_content ();
/**
* Get a read-only buffer with the raw content of a blob.
*
* A pointer to the raw content of a blob is returned.
* The pointer may be invalidated at a later time.
*/
public uint8[]? content {
get {
unowned uint8[]? content = _get_content ();
if (content != null) {
content.length = (int) size;
}
return content;
}
}
/**
* The id of a blob.
*/
public object_id? id {
[CCode (cname = "git_blob_id")]
get;
}
/**
* Determine if the blob content is most certainly binary or not.
*
* The heuristic used to guess if a file is binary is taken from core git:
* Searching for NUL bytes and looking for a reasonable ratio of printable
* to non-printable characters among the first 4000 bytes.
*/
public bool is_binary {
[CCode (cname = "git_blob_is_binary")]
get;
}
public Repository owner {
[CCode (cname = "git_blob_owner")]
get;
}
/**
* Get the size in bytes of the contents of a blob
*/
public size_t size {
[CCode (cname = "git_blob_rawsize")]
get;
}
/**
* Directly run a text diff on two blobs.
*
* Compared to a file, a blob lacks some contextual information. As such, the
* {@link diff_file} parameters of the callbacks will be filled accordingly to the following:
* mode will be set to 0, path will be null. When dealing with a null blob, object id
* will be set to 0.
*
* When at least one of the blobs being dealt with is binary, the {@link diff_delta} binary
* attribute will be set to true and no call to the hunk nor line will be made.
*
* We do run a binary content check on the two blobs and if either of the
* blobs looks like binary data, {@link diff_delta.flags} will {@link DiffFlag.BINARY}
* and no call to the {@link DiffHunk} nor {@link DiffData} will be made
* (unless you pass {@link DiffFlags.FORCE_TEXT} of course).
*/
[CCode (cname = "git_diff_blobs", simple_generics = true)]
public Error diff<T> (string? old_path, Blob new_blob, string? new_path, diff_options? options, DiffFile<T>? file, DiffHunk<T>? hunk, DiffData<T>? line, T context);
/**
* Directly run a diff between a blob and a buffer.
*
* As with {@link diff}, comparing a blob and buffer lacks some context, so
* the {@link diff_file} parameters to the callbacks will be faked.
*/
[CCode (cname = "git_diff_blob_to_buffer", simple_generics = true)]
public Error diff_buffer<T> (string? old_path, [CCode (array_length_type = "size_t")] uint8[] buffer, string? buffer_path, diff_options? options, DiffFile<T>? file, DiffHunk<T>? hunk, DiffData<T>? line, T context);
/**
* Directly generate a patch from the difference between two blobs.
*
* This is just like {@link diff} except it generates a patch object for
* the difference instead of directly making callbacks.
*/
[CCode (cname = "git_diff_patch_from_blobs", instance_pos = 1.1)]
public Error diff_patch (out Patch? patch, string? old_path, Blob new_blob, string? new_path, diff_options? options = null);
/**
* Directly generate a patch from the difference between a blob and a
* buffer.
*
* This is just like {@link diff_buffer} except it generates a patch object
* for the difference instead of directly making callbacks.
*/
[CCode (cname = "git_diff_patch_from_blob_and_buffer")]
public Error diff_patch_buffer (out Patch? patch, string? old_path, [CCode (array_length_type = "size_t")] uint8[] buffer, string? new_path, diff_options? options = null);
}
/**
* Parsed representation of a commit object.
*/
[CCode (cname = "git_commit", free_function = "git_commit_free", has_type_id = false)]
[Compact]
public class Commit : Object {
/**
* The author of a commit.
*/
public Signature author {
[CCode (cname = "git_commit_author")]
get;
}
/**
* The committer of a commit.
*/
public Signature committer {
[CCode (cname = "git_commit_committer")]
get;
}
/**
* The id of a commit.
*/
public object_id? id {
[CCode (cname = "git_commit_id")]
get;
}
/**
* The full message of a commit.
*/
public string message {
[CCode (cname = "git_commit_message")]
get;
}
/**
* The encoding for the message of a commit, as a string representing a
* standard encoding name.
*
* The encoding may be null if the encoding header in the commit is
* missing; in that case UTF-8 is assumed.
*/
public string? message_encoding {
[CCode (cname = "git_commit_message_encoding")]
get;
}
/**
* Get the repository that contains the commit.
*
* @param commit A previously loaded commit.
* @return Repository that contains this commit.
*/
public Repository owner {
[CCode (cname = "git_commit_owner")]
get;
}
/**
* The parent(s) of this commit
*
* Typically, commits have a single parent, but merges can have many.
*/
public Parents parents {
[CCode (cname = "")]
get;
}
/**
* Get the commit time (i.e., committer time) of a commit.
*/
public int64 time {
[CCode (cname = "git_commit_time")]
get;
}
/**
* Get the commit timezone offset (i.e., committer's preferred timezone) in minutes from UTC of a commit.
*/
public int time_offset {
[CCode (cname = "git_commit_time_offset")]
get;
}
/**
* Get the id of the tree pointed to by a commit.
*
* This differs from {@link lookup_tree} in that no attempts
* are made to fetch an object from the ODB.
*/
public object_id? tree_id {
[CCode (cname = "git_commit_tree_oid")]
get;
}
/**
* Get the commit object that is an ancestor of the named commit object,
* following only the first parents.
*
* @param ancestor the ancestor received, if any
* @param n the requested generation, or 0 for a copy of the commit.
*/
[CCode (cname = "git_commit_nth_gen_ancestor", instance_pos = 1.2)]
public Error get_ancestor (out Commit? ancestor, uint n);
/**
* The message of a commit converted to UTF-8.
*/
public string get_message_utf8 () throws GLib.ConvertError {
return this.message_encoding == null ? this.message : GLib.convert (this.message, this.message.length, "utf-8", this.message_encoding);
}
/**
* Get the tree pointed to by a commit.
*/
[CCode (cname = "git_commit_tree", instance_pos = -1)]
public Error lookup_tree (out Tree tree);
}
/**
* Memory representation of a set of config files
*/
[CCode (cname = "git_config", free_function = "git_config_free", has_type_id = false)]
[Compact]
public class Config {
/**
* Allocate a new configuration object
*
* This object is empty, so you have to add a file to it before you can do
* anything with it.
*
* @param config the new configuration
*/
[CCode (cname = "git_config_new")]
public static Error create (out Config config);
/**
* Locate the path to the global configuration file
*
* The user or global configuration file is usually located in
* //$HOME/.gitconfig//.
*
* This method will try to guess the full path to that file, if the file
* exists. The returned path may be used on any call to load the global
* configuration file.
*
* @param config_path Buffer store the path
* @return {@link Error.OK} if a global configuration file has been found.
*/
[CCode (cname = "git_config_find_global")]
public static Error find_global ([CCode (array_length_type = "size_t")] char[] config_path);
/**
* Locate the path to the global xdg compatible configuration file
*
* The xdg compatible configuration file is usually located in
* //$HOME/.config/git/config//.
*
* This method will try to guess the full path to that file, if the file
* exists.
* @param config_path Buffer store the path
* @return {@link Error.OK} if an XDG configuration file has been found.
*/
[CCode (cname = "git_config_find_xdg")]
public static Error find_xdg ([CCode (array_length_type = "size_t")] char[] config_path);
/**
* Locate the path to the system configuration file
*
* If /etc/gitconfig doesn't exist, it will look for
* %PROGRAMFILES%\Git\etc\gitconfig.
* @param config_path Buffer of {@link PATH_MAX} length to store the path
* @return {@link Error.OK} if a system configuration file has been found. Its path will be stored in //buffer//.
*/
[CCode (cname = "git_config_find_system")]
public static Error find_system ([CCode (array_length_type = "size_t")] char[] config_path);
/**
* Maps a string value to an integer constant
*/
[CCode (cname = "git_config_lookup_map_value")]
public static Error lookup_map_value (out int result, [CCode (array_length_type = "size_t")] config_var_map[] map, string name);
/**
* Create a new config instance containing a single on-disk file
*
* This method is a simple utility wrapper for the following sequence of
* calls:
* * {@link create}
* * {@link add_filename}
*
* @param cfg the configuration instance to create
* @param path path to the on-disk file to open
*/
[CCode (cname = "git_config_open_ondisk")]
public static Error open (out Config? cfg, string path);
/**
* Open the global and system configuration files
*
* Utility wrapper that calls {@link find_global}, {@link find_xdg}, and
* {@link find_system} and opens the located file, if it exists.
*
* @param config where to store the config instance
*/
[CCode (cname = "git_config_open_default")]
public static Error open_default (out Config? config);
/**
* Build a single-level focused config object from a multi-level one.
*
* The returned config object can be used to perform get/set/delete
* operations on a single specific level.
*
* Getting several times the same level from the same parent multi-level
* config will return different config instances, but containing the same
* config_file instance.
*
* @param parent Multi-level config to search for the given level
* @param level Configuration level to search for
*/
[CCode (cname = "git_config_open_level")]
public static Error open_level (out Config? config, Config parent, ConfigLevel level);
/**
* Parse a string value as a bool.
*
* Valid values for true are: 'true', 'yes', 'on', 1 or any number
* different from 0
*
* Valid values for false are: 'false', 'no', 'off', 0
*/
[CCode (cname = "git_config_parse_bool")]
public static Error bool(out bool result, string @value);
/**
* Parse a string value as an int32.
*
* An optional value suffix of 'k', 'm', or 'g' will cause the value to be
* multiplied by 1024, 1048576, or 1073741824 prior to output.
*/
[CCode (cname = "git_config_parse_int32")]
public static Error parse_int32 (out int32 result, string @value);
/**
* Parse a string value as an int64.
*
* An optional value suffix of 'k', 'm', or 'g' will cause the value to be
* multiplied by 1024, 1048576, or 1073741824 prior to output.
*/
[CCode (cname = "git_config_parse_int64")]
public static Error parse_int64 (out int64 result, string @value);
/**
* Add an on-disk config file instance to an existing config
*
* The on-disk file pointed at by path will be opened and parsed; it's
* expected to be a native Git config file following the default Git config
* syntax (see man git-config).
*