summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorlmcglash <lmcglash@mathworks.com>2023-03-10 08:51:43 +0000
committerlmcglash <lmcglash@mathworks.com>2023-03-10 08:51:43 +0000
commit570ef74a07f80d8890a2bf0125d72ee42f83187e (patch)
treec3106ddd08967e3f071f1eec872a1d6db01dec37 /include
parenta9793ac643a0cd82b00970d0d6e0b67681ec3112 (diff)
parentd066d0d95c43e97df6624292f3f527f9372ca8fe (diff)
downloadlibgit2-570ef74a07f80d8890a2bf0125d72ee42f83187e.tar.gz
Merge commit 'd066d0d95c43e97df6624292f3f527f9372ca8fe'
Diffstat (limited to 'include')
-rw-r--r--include/git2/common.h12
-rw-r--r--include/git2/experimental.h20
-rw-r--r--include/git2/indexer.h29
-rw-r--r--include/git2/object.h30
-rw-r--r--include/git2/odb_backend.h68
-rw-r--r--include/git2/repository.h21
-rw-r--r--include/git2/stash.h66
-rw-r--r--include/git2/strarray.h13
-rw-r--r--include/git2/sys/transport.h12
-rw-r--r--include/git2/version.h6
10 files changed, 238 insertions, 39 deletions
diff --git a/include/git2/common.h b/include/git2/common.h
index defa24a6a..b09b078a1 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -223,6 +223,8 @@ typedef enum {
GIT_OPT_SET_EXTENSIONS,
GIT_OPT_GET_OWNER_VALIDATION,
GIT_OPT_SET_OWNER_VALIDATION,
+ GIT_OPT_GET_HOMEDIR,
+ GIT_OPT_SET_HOMEDIR,
GIT_OPT_ENABLE_SHALLOW
} git_libgit2_opt_t;
@@ -472,6 +474,16 @@ typedef enum {
* > Set that repository directories should be owned by the current
* > user. The default is to validate ownership.
*
+ * opts(GIT_OPT_GET_HOMEDIR, git_buf *out)
+ * > Gets the current user's home directory, as it will be used
+ * > for file lookups. The path is written to the `out` buffer.
+ *
+ * opts(GIT_OPT_SET_HOMEDIR, const char *path)
+ * > Sets the directory used as the current user's home directory,
+ * > for file lookups.
+ * >
+ * > - `path` directory of home directory.
+ *
* @param option Option key
* @param ... value to set the option
* @return 0 on success, <0 on failure
diff --git a/include/git2/experimental.h b/include/git2/experimental.h
new file mode 100644
index 000000000..06435f9a7
--- /dev/null
+++ b/include/git2/experimental.h
@@ -0,0 +1,20 @@
+/*
+ * 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_experimental_h__
+#define INCLUDE_experimental_h__
+
+/*
+ * This file exists to support users who build libgit2 with a bespoke
+ * build system and do not use our cmake configuration. Normally, cmake
+ * will create `experimental.h` from the `experimental.h.in` file and
+ * will include the generated file instead of this one. For non-cmake
+ * users, we bundle this `experimental.h` file which will be used
+ * instead.
+ */
+
+#endif
diff --git a/include/git2/indexer.h b/include/git2/indexer.h
index ffe9bf366..630eef934 100644
--- a/include/git2/indexer.h
+++ b/include/git2/indexer.h
@@ -62,6 +62,19 @@ typedef int GIT_CALLBACK(git_indexer_progress_cb)(const git_indexer_progress *st
typedef struct git_indexer_options {
unsigned int version;
+#ifdef GIT_EXPERIMENTAL_SHA256
+ /** permissions to use creating packfile or 0 for defaults */
+ unsigned int mode;
+
+ /**
+ * object database from which to read base objects when
+ * fixing thin packs. This can be NULL if there are no thin
+ * packs; if a thin pack is encountered, an error will be
+ * returned if there are bases missing.
+ */
+ git_odb *odb;
+#endif
+
/** progress_cb function to call with progress information */
git_indexer_progress_cb progress_cb;
@@ -87,6 +100,21 @@ GIT_EXTERN(int) git_indexer_options_init(
git_indexer_options *opts,
unsigned int version);
+#ifdef GIT_EXPERIMENTAL_SHA256
+/**
+ * Create a new indexer instance
+ *
+ * @param out where to store the indexer instance
+ * @param path to the directory where the packfile should be stored
+ * @param oid_type the oid type to use for objects
+ * @return 0 or an error code.
+ */
+GIT_EXTERN(int) git_indexer_new(
+ git_indexer **out,
+ const char *path,
+ git_oid_t oid_type,
+ git_indexer_options *opts);
+#else
/**
* Create a new indexer instance
*
@@ -106,6 +134,7 @@ GIT_EXTERN(int) git_indexer_new(
unsigned int mode,
git_odb *odb,
git_indexer_options *opts);
+#endif
/**
* Add data to the indexer
diff --git a/include/git2/object.h b/include/git2/object.h
index 5610a476f..6384aaa6e 100644
--- a/include/git2/object.h
+++ b/include/git2/object.h
@@ -225,6 +225,7 @@ GIT_EXTERN(int) git_object_peel(
*/
GIT_EXTERN(int) git_object_dup(git_object **dest, git_object *source);
+#ifdef GIT_EXPERIMENTAL_SHA256
/**
* Analyzes a buffer of raw object content and determines its validity.
* Tree, commit, and tag objects will be parsed and ensured that they
@@ -238,14 +239,39 @@ GIT_EXTERN(int) git_object_dup(git_object **dest, git_object *source);
* @param valid Output pointer to set with validity of the object content
* @param buf The contents to validate
* @param len The length of the buffer
- * @param type The type of the object in the buffer
+ * @param object_type The type of the object in the buffer
+ * @param oid_type The object ID type for the OIDs in the given buffer
* @return 0 on success or an error code
*/
GIT_EXTERN(int) git_object_rawcontent_is_valid(
int *valid,
const char *buf,
size_t len,
- git_object_t type);
+ git_object_t object_type,
+ git_oid_t oid_type);
+#else
+/**
+ * Analyzes a buffer of raw object content and determines its validity.
+ * Tree, commit, and tag objects will be parsed and ensured that they
+ * are valid, parseable content. (Blobs are always valid by definition.)
+ * An error message will be set with an informative message if the object
+ * is not valid.
+ *
+ * @warning This function is experimental and its signature may change in
+ * the future.
+ *
+ * @param valid Output pointer to set with validity of the object content
+ * @param buf The contents to validate
+ * @param len The length of the buffer
+ * @param object_type The type of the object in the buffer
+ * @return 0 on success or an error code
+ */
+GIT_EXTERN(int) git_object_rawcontent_is_valid(
+ int *valid,
+ const char *buf,
+ size_t len,
+ git_object_t object_type);
+#endif
/** @} */
GIT_END_DECL
diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h
index a31d1b782..12dd0fd38 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),
@@ -133,7 +171,9 @@ struct git_odb_stream {
unsigned int mode;
void *hash_ctx;
+#ifdef GIT_EXPERIMENTAL_SHA256
git_oid_t oid_type;
+#endif
git_object_size_t declared_size;
git_object_size_t received_bytes;
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 258b9ac00..0de4d7557 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -352,6 +352,15 @@ typedef struct {
* pointing to this URL.
*/
const char *origin_url;
+
+#ifdef GIT_EXPERIMENTAL_SHA256
+ /**
+ *
+ * Type of object IDs to use for this repository, or 0 for
+ * default (currently SHA1).
+ */
+ git_oid_t oid_type;
+#endif
} git_repository_init_options;
#define GIT_REPOSITORY_INIT_OPTIONS_VERSION 1
@@ -457,7 +466,9 @@ GIT_EXTERN(int) git_repository_head_unborn(git_repository *repo);
* Check if a repository is empty
*
* An empty repository has just been initialized and contains no references
- * apart from HEAD, which must be pointing to the unborn master branch.
+ * apart from HEAD, which must be pointing to the unborn master branch,
+ * or the branch specified for the repository in the `init.defaultBranch`
+ * configuration variable.
*
* @param repo Repo to test
* @return 1 if the repository is empty, 0 if it isn't, error code
@@ -950,6 +961,14 @@ GIT_EXTERN(int) git_repository_ident(const char **name, const char **email, cons
*/
GIT_EXTERN(int) git_repository_set_ident(git_repository *repo, const char *name, const char *email);
+/**
+ * Gets the object type used by this repository.
+ *
+ * @param repo the repository
+ * @return the object id type
+ */
+GIT_EXTERN(git_oid_t) git_repository_oid_type(git_repository *repo);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/stash.h b/include/git2/stash.h
index 32e6f9576..dcfc013dc 100644
--- a/include/git2/stash.h
+++ b/include/git2/stash.h
@@ -44,7 +44,12 @@ typedef enum {
* All ignored files are also stashed and then cleaned up from
* the working directory
*/
- GIT_STASH_INCLUDE_IGNORED = (1 << 2)
+ GIT_STASH_INCLUDE_IGNORED = (1 << 2),
+
+ /**
+ * All changes in the index and working directory are left intact
+ */
+ GIT_STASH_KEEP_ALL = (1 << 3)
} git_stash_flags;
/**
@@ -52,15 +57,10 @@ typedef enum {
*
* @param out Object id of the commit containing the stashed state.
* This commit is also the target of the direct reference refs/stash.
- *
* @param repo The owning repository.
- *
* @param stasher The identity of the person performing the stashing.
- *
* @param message Optional description along with the stashed state.
- *
* @param flags Flags to control the stashing process. (see GIT_STASH_* above)
- *
* @return 0 on success, GIT_ENOTFOUND where there's nothing to stash,
* or error code.
*/
@@ -71,6 +71,60 @@ GIT_EXTERN(int) git_stash_save(
const char *message,
uint32_t flags);
+/**
+ * Stash save options structure
+ *
+ * Initialize with `GIT_STASH_SAVE_OPTIONS_INIT`. Alternatively, you can
+ * use `git_stash_save_options_init`.
+ *
+ */
+typedef struct git_stash_save_options {
+ unsigned int version;
+
+ /** Flags to control the stashing process. (see GIT_STASH_* above) */
+ uint32_t flags;
+
+ /** The identity of the person performing the stashing. */
+ const git_signature *stasher;
+
+ /** Optional description along with the stashed state. */
+ const char *message;
+
+ /** Optional paths that control which files are stashed. */
+ git_strarray paths;
+} git_stash_save_options;
+
+#define GIT_STASH_SAVE_OPTIONS_VERSION 1
+#define GIT_STASH_SAVE_OPTIONS_INIT { GIT_STASH_SAVE_OPTIONS_VERSION }
+
+/**
+ * Initialize git_stash_save_options structure
+ *
+ * Initializes a `git_stash_save_options` with default values. Equivalent to
+ * creating an instance with `GIT_STASH_SAVE_OPTIONS_INIT`.
+ *
+ * @param opts The `git_stash_save_options` struct to initialize.
+ * @param version The struct version; pass `GIT_STASH_SAVE_OPTIONS_VERSION`.
+ * @return Zero on success; -1 on failure.
+ */
+GIT_EXTERN(int) git_stash_save_options_init(
+ git_stash_save_options *opts, unsigned int version);
+
+/**
+ * Save the local modifications to a new stash, with options.
+ *
+ * @param out Object id of the commit containing the stashed state.
+ * This commit is also the target of the direct reference refs/stash.
+ * @param repo The owning repository.
+ * @param opts The stash options.
+ * @return 0 on success, GIT_ENOTFOUND where there's nothing to stash,
+ * or error code.
+ */
+GIT_EXTERN(int) git_stash_save_with_opts(
+ git_oid *out,
+ git_repository *repo,
+ const git_stash_save_options *opts);
+
/** Stash application flags. */
typedef enum {
GIT_STASH_APPLY_DEFAULT = 0,
diff --git a/include/git2/strarray.h b/include/git2/strarray.h
index 0f657e6c5..03d93f8fb 100644
--- a/include/git2/strarray.h
+++ b/include/git2/strarray.h
@@ -36,19 +36,6 @@ typedef struct git_strarray {
*/
GIT_EXTERN(void) git_strarray_dispose(git_strarray *array);
-/**
- * Copy a string array object from source to target.
- *
- * Note: target is overwritten and hence should be empty, otherwise its
- * contents are leaked. Call git_strarray_free() if necessary.
- *
- * @param tgt target
- * @param src source
- * @return 0 on success, < 0 on allocation failure
- */
-GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
-
-
/** @} */
GIT_END_DECL
diff --git a/include/git2/sys/transport.h b/include/git2/sys/transport.h
index 391765b77..8a8451592 100644
--- a/include/git2/sys/transport.h
+++ b/include/git2/sys/transport.h
@@ -75,6 +75,18 @@ struct git_transport {
unsigned int *capabilities,
git_transport *transport);
+#ifdef GIT_EXPERIMENTAL_SHA256
+ /**
+ * Gets the object type for the remote repository.
+ *
+ * This function may be called after a successful call to
+ * `connect()`.
+ */
+ int GIT_CALLBACK(oid_type)(
+ git_oid_t *object_type,
+ git_transport *transport);
+#endif
+
/**
* Get the list of available references in the remote repository.
*
diff --git a/include/git2/version.h b/include/git2/version.h
index 09f4ae3e4..8b5eb3138 100644
--- a/include/git2/version.h
+++ b/include/git2/version.h
@@ -11,7 +11,7 @@
* The version string for libgit2. This string follows semantic
* versioning (v2) guidelines.
*/
-#define LIBGIT2_VERSION "1.6.0-alpha"
+#define LIBGIT2_VERSION "1.6.2"
/** The major version number for this version of libgit2. */
#define LIBGIT2_VER_MAJOR 1
@@ -20,7 +20,7 @@
#define LIBGIT2_VER_MINOR 6
/** The revision ("teeny") version number for this version of libgit2. */
-#define LIBGIT2_VER_REVISION 0
+#define LIBGIT2_VER_REVISION 2
/** The Windows DLL patch number for this version of libgit2. */
#define LIBGIT2_VER_PATCH 0
@@ -31,7 +31,7 @@
* a prerelease name like "beta" or "rc1". For final releases, this will
* be `NULL`.
*/
-#define LIBGIT2_VER_PRERELEASE "alpha"
+#define LIBGIT2_VER_PRERELEASE NULL
/** The library ABI soversion for this version of libgit2. */
#define LIBGIT2_SOVERSION "1.6"