diff options
author | lhchavez <lhchavez@lhchavez.com> | 2021-08-29 18:50:49 -0700 |
---|---|---|
committer | lhchavez <lhchavez@lhchavez.com> | 2021-08-29 18:50:49 -0700 |
commit | 7d9ebdc840cf338bdd3d314504f1748ddc5c56d5 (patch) | |
tree | 73f6c34782f0d13f7b157dc344375f3260d64f9b /include | |
parent | 94008e6aae0b4f1b4fcaa2e772da99764072cd7f (diff) | |
parent | 2998a84ab644ad39b62553baf9c4b30269be7d75 (diff) | |
download | libgit2-7d9ebdc840cf338bdd3d314504f1748ddc5c56d5.tar.gz |
Merge remote-tracking branch 'origin/main' into cgraph-write
Diffstat (limited to 'include')
-rw-r--r-- | include/git2/checkout.h | 6 | ||||
-rw-r--r-- | include/git2/errors.h | 12 | ||||
-rw-r--r-- | include/git2/odb.h | 14 | ||||
-rw-r--r-- | include/git2/sys/midx.h | 74 | ||||
-rw-r--r-- | include/git2/sys/odb_backend.h | 7 | ||||
-rw-r--r-- | include/git2/types.h | 7 |
6 files changed, 112 insertions, 8 deletions
diff --git a/include/git2/checkout.h b/include/git2/checkout.h index ca6f17aa6..c7aeee431 100644 --- a/include/git2/checkout.h +++ b/include/git2/checkout.h @@ -178,6 +178,12 @@ typedef enum { GIT_CHECKOUT_DONT_WRITE_INDEX = (1u << 23), /** + * Show what would be done by a checkout. Stop after sending + * notifications; don't update the working directory or index. + */ + GIT_CHECKOUT_DRY_RUN = (1u << 24), + + /** * THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED */ diff --git a/include/git2/errors.h b/include/git2/errors.h index 8887b3299..de51582d5 100644 --- a/include/git2/errors.h +++ b/include/git2/errors.h @@ -42,14 +42,14 @@ typedef enum { GIT_ECONFLICT = -13, /**< Checkout conflicts prevented operation */ GIT_ELOCKED = -14, /**< Lock file prevented operation */ GIT_EMODIFIED = -15, /**< Reference value does not match expected */ - GIT_EAUTH = -16, /**< Authentication error */ - GIT_ECERTIFICATE = -17, /**< Server certificate is invalid */ + GIT_EAUTH = -16, /**< Authentication error */ + GIT_ECERTIFICATE = -17, /**< Server certificate is invalid */ GIT_EAPPLIED = -18, /**< Patch/merge has already been applied */ - GIT_EPEEL = -19, /**< The requested peel operation is not possible */ - GIT_EEOF = -20, /**< Unexpected EOF */ - GIT_EINVALID = -21, /**< Invalid operation or input */ + GIT_EPEEL = -19, /**< The requested peel operation is not possible */ + GIT_EEOF = -20, /**< Unexpected EOF */ + GIT_EINVALID = -21, /**< Invalid operation or input */ GIT_EUNCOMMITTED = -22, /**< Uncommitted changes in index prevented operation */ - GIT_EDIRECTORY = -23, /**< The operation is not valid for a directory */ + GIT_EDIRECTORY = -23, /**< The operation is not valid for a directory */ GIT_EMERGECONFLICT = -24, /**< A merge conflict exists and cannot continue */ GIT_PASSTHROUGH = -30, /**< A user-configured callback refused to act */ diff --git a/include/git2/odb.h b/include/git2/odb.h index 702e1bd30..dd484553f 100644 --- a/include/git2/odb.h +++ b/include/git2/odb.h @@ -391,6 +391,20 @@ GIT_EXTERN(int) git_odb_write_pack( void *progress_payload); /** + * Write a `multi-pack-index` file from all the `.pack` files in the ODB. + * + * If the ODB layer understands pack files, then this will create a file called + * `multi-pack-index` next to the `.pack` and `.idx` files, which will contain + * an index of all objects stored in `.pack` files. This will allow for + * O(log n) lookup for n objects (regardless of how many packfiles there + * exist). + * + * @param db object database where the `multi-pack-index` file will be written. + */ +GIT_EXTERN(int) git_odb_write_multi_pack_index( + git_odb *db); + +/** * 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/sys/midx.h b/include/git2/sys/midx.h new file mode 100644 index 000000000..e3d749829 --- /dev/null +++ b/include/git2/sys/midx.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_sys_git_midx_h__ +#define INCLUDE_sys_git_midx_h__ + +#include "git2/common.h" +#include "git2/types.h" + +/** + * @file git2/midx.h + * @brief Git multi-pack-index routines + * @defgroup git_midx Git multi-pack-index routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Create a new writer for `multi-pack-index` files. + * + * @param out location to store the writer pointer. + * @param pack_dir the directory where the `.pack` and `.idx` files are. The + * `multi-pack-index` file will be written in this directory, too. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_midx_writer_new( + git_midx_writer **out, + const char *pack_dir); + +/** + * Free the multi-pack-index writer and its resources. + * + * @param w the writer to free. If NULL no action is taken. + */ +GIT_EXTERN(void) git_midx_writer_free(git_midx_writer *w); + +/** + * Add an `.idx` file to the writer. + * + * @param w the writer + * @param idx_path the path of an `.idx` file. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_midx_writer_add( + git_midx_writer *w, + const char *idx_path); + +/** + * Write a `multi-pack-index` file to a file. + * + * @param w the writer + * @return 0 or an error code + */ +GIT_EXTERN(int) git_midx_writer_commit( + git_midx_writer *w); + +/** + * Dump the contents of the `multi-pack-index` to an in-memory buffer. + * + * @param midx Buffer where to store the contents of the `multi-pack-index`. + * @param w the writer + * @return 0 or an error code + */ +GIT_EXTERN(int) git_midx_writer_dump( + git_buf *midx, + git_midx_writer *w); + +/** @} */ +GIT_END_DECL +#endif diff --git a/include/git2/sys/odb_backend.h b/include/git2/sys/odb_backend.h index 4dba460af..9ae0ed9b3 100644 --- a/include/git2/sys/odb_backend.h +++ b/include/git2/sys/odb_backend.h @@ -85,6 +85,13 @@ struct git_odb_backend { git_indexer_progress_cb progress_cb, void *progress_payload); /** + * If the backend supports pack files, this will create a + * `multi-pack-index` file which will contain an index of all objects + * across all the `.pack` files. + */ + int GIT_CALLBACK(writemidx)(git_odb_backend *); + + /** * "Freshens" an already existing object, updating its last-used * time. This occurs when `git_odb_write` was called, but the * object already existed (and will not be re-written). The diff --git a/include/git2/types.h b/include/git2/types.h index 4d5c72324..aac8e42e2 100644 --- a/include/git2/types.h +++ b/include/git2/types.h @@ -96,8 +96,8 @@ 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; -/** a writer for commit-graph files. */ -typedef struct git_commit_graph_writer git_commit_graph_writer; +/** a writer for multi-pack-index files. */ +typedef struct git_midx_writer git_midx_writer; /** An open refs database handle. */ typedef struct git_refdb git_refdb; @@ -108,6 +108,9 @@ typedef struct git_refdb_backend git_refdb_backend; /** A git commit-graph */ typedef struct git_commit_graph git_commit_graph; +/** a writer for commit-graph files. */ +typedef struct git_commit_graph_writer git_commit_graph_writer; + /** * Representation of an existing git repository, * including all its object contents |