diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2022-07-08 17:17:09 -0400 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2023-02-12 21:26:12 +0000 |
| commit | 479c8c8c14f83491f31fb9b23388ae17070c9549 (patch) | |
| tree | 9847977931b5c77325c11cc4ed79163db870fe56 /include | |
| parent | e89e2e0102300af1faf0ab892e598a700692718a (diff) | |
| download | libgit2-479c8c8c14f83491f31fb9b23388ae17070c9549.tar.gz | |
packfile: handle sha256 packfiles
Teach the packfile machinery to cope with SHA256.
Diffstat (limited to 'include')
| -rw-r--r-- | include/git2/odb_backend.h | 66 |
1 files changed, 52 insertions, 14 deletions
diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h index a31d1b782..4d0559ec0 100644 --- a/include/git2/odb_backend.h +++ b/include/git2/odb_backend.h @@ -24,6 +24,26 @@ GIT_BEGIN_DECL * Constructors for in-box ODB backends. */ +/** Options for configuring a packfile object backend. */ +typedef struct { + unsigned int version; /**< version for the struct */ + + /** + * Type of object IDs to use for this object database, or + * 0 for default (currently SHA1). + */ + git_oid_t oid_type; +} git_odb_backend_pack_options; + +/* The current version of the diff options structure */ +#define GIT_ODB_BACKEND_PACK_OPTIONS_VERSION 1 + +/* Stack initializer for odb pack backend options. Alternatively use + * `git_odb_backend_pack_options_init` programmatic initialization. + */ +#define GIT_ODB_BACKEND_PACK_OPTIONS_INIT \ + { GIT_ODB_BACKEND_PACK_OPTIONS_VERSION } + /** * Create a backend for the packfiles. * @@ -32,7 +52,38 @@ GIT_BEGIN_DECL * * @return 0 or an error code */ -GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **out, const char *objects_dir); +#ifdef GIT_EXPERIMENTAL_SHA256 +GIT_EXTERN(int) git_odb_backend_pack( + git_odb_backend **out, + const char *objects_dir, + const git_odb_backend_pack_options *opts); +#else +GIT_EXTERN(int) git_odb_backend_pack( + git_odb_backend **out, + const char *objects_dir); +#endif + +/** + * Create a backend out of a single packfile + * + * This can be useful for inspecting the contents of a single + * packfile. + * + * @param out location to store the odb backend pointer + * @param index_file path to the packfile's .idx file + * + * @return 0 or an error code + */ +#ifdef GIT_EXPERIMENTAL_SHA256 +GIT_EXTERN(int) git_odb_backend_one_pack( + git_odb_backend **out, + const char *index_file, + const git_odb_backend_pack_options *opts); +#else +GIT_EXTERN(int) git_odb_backend_one_pack( + git_odb_backend **out, + const char *index_file); +#endif typedef enum { GIT_ODB_BACKEND_LOOSE_FSYNC = (1 << 0) @@ -100,19 +151,6 @@ GIT_EXTERN(int) git_odb_backend_loose( unsigned int file_mode); #endif -/** - * Create a backend out of a single packfile - * - * This can be useful for inspecting the contents of a single - * packfile. - * - * @param out location to store the odb backend pointer - * @param index_file path to the packfile's .idx file - * - * @return 0 or an error code - */ -GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **out, const char *index_file); - /** Streaming mode */ typedef enum { GIT_STREAM_RDONLY = (1 << 1), |
