@@ -23,18 +23,45 @@ const
2323type
2424 git_odb_foreach_cb = function(id: Pgit_oid; payload: Pointer): Integer; cdecl;
2525
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+
2647 (* *
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;
3661
62+ { $ELSE}
3763function git_odb_new (out_: PPgit_odb): Integer; cdecl; external libgit2_dll;
64+ { $ENDIF}
3865
3966(* *
4067 * Create a new object database and automatically add
@@ -50,11 +77,16 @@ function git_odb_new(out_: PPgit_odb): Integer; cdecl; external libgit2_dll;
5077 * @param out location to store the database pointer, if opened.
5178 * Set to NULL if the open failed.
5279 * @param objects_dir path of the backends' "objects" directory.
80+ * @param opts the options for this object database or NULL for defaults
5381 * @return 0 or an error code
5482 *)
5583
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;
5786
87+ { $ELSE}
88+ function git_odb_open (out_: PPgit_odb; objects_dir: PAnsiChar): Integer; cdecl; external libgit2_dll;
89+ { $ENDIF}
5890(* *
5991 * Add an on-disk alternate to an existing Object DB.
6092 *
@@ -107,7 +139,7 @@ function git_odb_read(out_: PPgit_odb_object; db: Pgit_odb; id: Pgit_oid): Integ
107139 * This method queries all available ODB backends
108140 * trying to match the 'len' first hexadecimal
109141 * 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
111143 * 'short_id' must be 0s.
112144 * 'len' must be at least GIT_OID_MINPREFIXLEN,
113145 * and the prefix must be long enough to identify
217249 *
218250 * The given array will be updated in place: for each abbreviated ID that is
219251 * 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
221253 * written back to the array. For IDs that are not found (or are ambiguous),
222254 * the array entry will be zeroed.
223255 *
@@ -440,19 +472,26 @@ function git_odb_write_pack(out_: PPgit_odb_writepack; db: Pgit_odb; progress_cb
440472function git_odb_write_multi_pack_index (db: Pgit_odb): Integer; cdecl; external libgit2_dll;
441473
442474(* *
443- * Determine the object-ID (sha1 hash) of a data buffer
475+ * Determine the object-ID (sha1 or sha256 hash) of a data buffer
444476 *
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.
447479 *
448480 * @param out the resulting object-ID.
449481 * @param data data to hash
450482 * @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
452485 * @return 0 or an error code
453486 *)
454487
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}
455493function git_odb_hash (out_: Pgit_oid; data: Pointer; len: size_t; type_: git_object_t): Integer; cdecl; external libgit2_dll;
494+ { $ENDIF}
456495
457496(* *
458497 * 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
464503 *
465504 * @param out oid structure the result is written into.
466505 * @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
468508 * @return 0 or an error code
469509 *)
470510
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}
471516function git_odb_hashfile (out_: Pgit_oid; path: PAnsiChar; type_: git_object_t): Integer; cdecl; external libgit2_dll;
517+ { $ENDIF}
472518
473519(* *
474520 * 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
618664
619665(* * @} *)
620666
621-
622-
0 commit comments