@@ -23,18 +23,45 @@ const
23
23
type
24
24
git_odb_foreach_cb = function(id: Pgit_oid; payload: Pointer): Integer; cdecl;
25
25
26
+ (* * Options for configuring a loose object backend. *)
27
+ git_odb_options = record
28
+ version: cardinal; (* *< version for the struct *)
29
+
30
+ (* *
31
+ * Type of object IDs to use for this object database, or
32
+ * 0 for default (currently SHA1).
33
+ *)
34
+ oid_type: git_oid_t;
35
+ end ;
36
+ Pgit_odb_options = ^git_odb_options;
37
+
38
+ const
39
+ (* The current version of the diff options structure *)
40
+ GIT_ODB_OPTIONS_VERSION = 1 ;
41
+
42
+ (* Stack initializer for odb options. Alternatively use
43
+ * `git_odb_options_init` programmatic initialization.
44
+ *)
45
+ // #define GIT_ODB_OPTIONS_INIT { GIT_ODB_OPTIONS_VERSION }
46
+
26
47
(* *
27
- * Create a new object database with no backends.
28
- *
29
- * Before the ODB can be used for read/writing, a custom database
30
- * backend must be manually added using `git_odb_add_backend()`
31
- *
32
- * @param out location to store the database pointer, if opened.
33
- * Set to NULL if the open failed.
34
- * @return 0 or an error code
35
- *)
48
+ * Create a new object database with no backends.
49
+ *
50
+ * Before the ODB can be used for read/writing, a custom database
51
+ * backend must be manually added using `git_odb_add_backend()`
52
+ *
53
+ * @param out location to store the database pointer, if opened.
54
+ * Set to NULL if the open failed.
55
+ * @param opts the options for this object database or NULL for defaults
56
+ * @return 0 or an error code
57
+ *)
58
+
59
+ { $IFDEF GIT_EXPERIMENTAL_SHA256}
60
+ function git_odb_new (out_: PPgit_odb; opts: Pgit_odb_options): Integer; cdecl; external libgit2_dll;
36
61
62
+ { $ELSE}
37
63
function git_odb_new (out_: PPgit_odb): Integer; cdecl; external libgit2_dll;
64
+ { $ENDIF}
38
65
39
66
(* *
40
67
* Create a new object database and automatically add
@@ -50,11 +77,16 @@ function git_odb_new(out_: PPgit_odb): Integer; cdecl; external libgit2_dll;
50
77
* @param out location to store the database pointer, if opened.
51
78
* Set to NULL if the open failed.
52
79
* @param objects_dir path of the backends' "objects" directory.
80
+ * @param opts the options for this object database or NULL for defaults
53
81
* @return 0 or an error code
54
82
*)
55
83
56
- function git_odb_open (out_: PPgit_odb; objects_dir: PAnsiChar): Integer; cdecl; external libgit2_dll;
84
+ { $IFDEF GIT_EXPERIMENTAL_SHA256}
85
+ function git_odb_open (out_: PPgit_odb; objects_dir: PAnsiChar; opts: Pgit_odb_options): Integer; cdecl; external libgit2_dll;
57
86
87
+ { $ELSE}
88
+ function git_odb_open (out_: PPgit_odb; objects_dir: PAnsiChar): Integer; cdecl; external libgit2_dll;
89
+ { $ENDIF}
58
90
(* *
59
91
* Add an on-disk alternate to an existing Object DB.
60
92
*
@@ -107,7 +139,7 @@ function git_odb_read(out_: PPgit_odb_object; db: Pgit_odb; id: Pgit_oid): Integ
107
139
* This method queries all available ODB backends
108
140
* trying to match the 'len' first hexadecimal
109
141
* characters of the 'short_id'.
110
- * The remaining (GIT_OID_HEXSZ -len)*4 bits of
142
+ * The remaining (GIT_OID_SHA1_HEXSIZE -len)*4 bits of
111
143
* 'short_id' must be 0s.
112
144
* 'len' must be at least GIT_OID_MINPREFIXLEN,
113
145
* and the prefix must be long enough to identify
217
249
*
218
250
* The given array will be updated in place: for each abbreviated ID that is
219
251
* unique in the database, and of the given type (if specified),
220
- * the full object ID, object ID length (`GIT_OID_HEXSZ `) and type will be
252
+ * the full object ID, object ID length (`GIT_OID_SHA1_HEXSIZE `) and type will be
221
253
* written back to the array. For IDs that are not found (or are ambiguous),
222
254
* the array entry will be zeroed.
223
255
*
@@ -440,19 +472,26 @@ function git_odb_write_pack(out_: PPgit_odb_writepack; db: Pgit_odb; progress_cb
440
472
function git_odb_write_multi_pack_index (db: Pgit_odb): Integer; cdecl; external libgit2_dll;
441
473
442
474
(* *
443
- * Determine the object-ID (sha1 hash) of a data buffer
475
+ * Determine the object-ID (sha1 or sha256 hash) of a data buffer
444
476
*
445
- * The resulting SHA-1 OID will be the identifier for the data
446
- * buffer as if the data buffer it were to written to the ODB.
477
+ * The resulting OID will be the identifier for the data buffer as if
478
+ * the data buffer it were to written to the ODB.
447
479
*
448
480
* @param out the resulting object-ID.
449
481
* @param data data to hash
450
482
* @param len size of the data
451
- * @param type of the data to hash
483
+ * @param object_type of the data to hash
484
+ * @param oid_type the oid type to hash to
452
485
* @return 0 or an error code
453
486
*)
454
487
488
+ { $IFDEF GIT_EXPERIMENTAL_SHA256}
489
+ function git_odb_hash (out_: Pgit_oid; data: Pointer; len: size_t; type_: git_object_t;
490
+ oid_type: git_oid_t): Integer; cdecl; external libgit2_dll;
491
+
492
+ { $ELSE}
455
493
function git_odb_hash (out_: Pgit_oid; data: Pointer; len: size_t; type_: git_object_t): Integer; cdecl; external libgit2_dll;
494
+ { $ENDIF}
456
495
457
496
(* *
458
497
* Read a file from disk and fill a git_oid with the object id
@@ -464,11 +503,18 @@ function git_odb_hash(out_: Pgit_oid; data: Pointer; len: size_t; type_: git_obj
464
503
*
465
504
* @param out oid structure the result is written into.
466
505
* @param path file to read and determine object id for
467
- * @param type the type of the object that will be hashed
506
+ * @param object_type of the data to hash
507
+ * @param oid_type the oid type to hash to
468
508
* @return 0 or an error code
469
509
*)
470
510
511
+ { $IFDEF GIT_EXPERIMENTAL_SHA256}
512
+ function git_odb_hashfile (out_: Pgit_oid; path: PAnsiChar; type_: git_object_t;
513
+ oid_type: git_oid_t): Integer; cdecl; external libgit2_dll;
514
+
515
+ { $ELSE}
471
516
function git_odb_hashfile (out_: Pgit_oid; path: PAnsiChar; type_: git_object_t): Integer; cdecl; external libgit2_dll;
517
+ { $ENDIF}
472
518
473
519
(* *
474
520
* Create a copy of an odb_object
@@ -618,5 +664,3 @@ function git_odb_set_commit_graph(odb: Pgit_odb; cgraph: Pgit_commit_graph): Int
618
664
619
665
(* * @} *)
620
666
621
-
622
-
0 commit comments