diff options
Diffstat (limited to 'include/git2')
-rw-r--r-- | include/git2/odb.h | 21 | ||||
-rw-r--r-- | include/git2/odb_backend.h | 26 | ||||
-rw-r--r-- | include/git2/types.h | 3 |
3 files changed, 45 insertions, 5 deletions
diff --git a/include/git2/odb.h b/include/git2/odb.h index c6e73571b..4afa3b788 100644 --- a/include/git2/odb.h +++ b/include/git2/odb.h @@ -11,6 +11,7 @@ #include "types.h" #include "oid.h" #include "odb_backend.h" +#include "indexer.h" /** * @file git2/odb.h @@ -263,6 +264,26 @@ GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **stream, git_odb *db, size_ GIT_EXTERN(int) git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oid); /** + * Open a stream for writing a pack file to the ODB. + * + * If the ODB layer understands pack files, then the given + * packfile will likely be streamed directly to disk (and a + * corresponding index created). If the ODB layer does not + * understand pack files, the objects will be stored in whatever + * format the ODB layer uses. + * + * @see git_odb_writepack + * + * @param writepack pointer to the writepack functions + * @param db object database where the stream will read from + * @param progress_cb function to call with progress information. + * Be aware that this is called inline with network and indexing operations, + * so performance may be affected. + * @param progress_payload payload for the progress callback + */ +GIT_EXTERN(int) git_odb_write_pack(git_odb_writepack **writepack, git_odb *db, git_transfer_progress_callback progress_cb, void *progress_payload); + +/** * Determine the object-ID (sha1 hash) of a data buffer * * The resulting SHA-1 OID will be the identifier for the data diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h index cb8069787..4df48d77e 100644 --- a/include/git2/odb_backend.h +++ b/include/git2/odb_backend.h @@ -10,6 +10,7 @@ #include "common.h" #include "types.h" #include "oid.h" +#include "indexer.h" /** * @file git2/backend.h @@ -21,6 +22,7 @@ GIT_BEGIN_DECL struct git_odb_stream; +struct git_odb_writepack; /** An instance for a custom backend */ struct git_odb_backend { @@ -75,11 +77,16 @@ struct git_odb_backend { struct git_odb_backend *, const git_oid *); - int (*foreach)( - struct git_odb_backend *, - int (*cb)(git_oid *oid, void *data), - void *data - ); + int (* foreach)( + struct git_odb_backend *, + int (*cb)(git_oid *oid, void *data), + void *data); + + int (* writepack)( + struct git_odb_writepack **, + struct git_odb_backend *, + git_transfer_progress_callback progress_cb, + void *progress_payload); void (* free)(struct git_odb_backend *); }; @@ -102,6 +109,15 @@ struct git_odb_stream { void (*free)(struct git_odb_stream *stream); }; +/** A stream to write a pack file to the ODB */ +struct git_odb_writepack { + struct git_odb_backend *backend; + + int (*add)(struct git_odb_writepack *writepack, const void *data, size_t size, git_transfer_progress *stats); + int (*commit)(struct git_odb_writepack *writepack, git_transfer_progress *stats); + void (*free)(struct git_odb_writepack *writepack); +}; + GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir); GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend **backend_out, const char *objects_dir, int compression_level, int do_fsync); GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **backend_out, const char *index_file); diff --git a/include/git2/types.h b/include/git2/types.h index 01ddbf3d6..58cbaecc5 100644 --- a/include/git2/types.h +++ b/include/git2/types.h @@ -89,6 +89,9 @@ typedef struct git_odb_object git_odb_object; /** A stream to read/write from the ODB */ typedef struct git_odb_stream git_odb_stream; +/** A stream to write a packfile to the ODB */ +typedef struct git_odb_writepack git_odb_writepack; + /** * Representation of an existing git repository, * including all its object contents |