summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/filter.h8
-rw-r--r--include/git2/repository.h5
-rw-r--r--include/git2/sys/filter.h12
3 files changed, 22 insertions, 3 deletions
diff --git a/include/git2/filter.h b/include/git2/filter.h
index f96b6766b..7fd9b7e59 100644
--- a/include/git2/filter.h
+++ b/include/git2/filter.h
@@ -35,6 +35,11 @@ typedef enum {
GIT_FILTER_CLEAN = GIT_FILTER_TO_ODB,
} git_filter_mode_t;
+typedef enum {
+ GIT_FILTER_OPT_DEFAULT = 0u,
+ GIT_FILTER_OPT_ALLOW_UNSAFE = (1u << 0),
+} git_filter_opt_t;
+
/**
* A filter that can transform file data
*
@@ -83,7 +88,8 @@ GIT_EXTERN(int) git_filter_list_load(
git_repository *repo,
git_blob *blob, /* can be NULL */
const char *path,
- git_filter_mode_t mode);
+ git_filter_mode_t mode,
+ git_filter_opt_t options);
/**
* Apply filter list to a data buffer.
diff --git a/include/git2/repository.h b/include/git2/repository.h
index e3f687a29..04df25fd3 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -546,6 +546,10 @@ GIT_EXTERN(int) git_repository_mergehead_foreach(
* hash a file in the repository and you want to apply filtering rules (e.g.
* crlf filters) before generating the SHA, then use this function.
*
+ * Note: if the repository has `core.safecrlf` set to fail and the
+ * filtering triggers that failure, then this function will return an
+ * error and not calculate the hash of the file.
+ *
* @param out Output value of calculated SHA
* @param repo Repository pointer
* @param path Path to file on disk whose contents should be hashed. If the
@@ -555,6 +559,7 @@ GIT_EXTERN(int) git_repository_mergehead_foreach(
* NULL, then the `path` parameter will be used instead. If
* this is passed as the empty string, then no filters will be
* applied when calculating the hash.
+ * @return 0 on success, or an error code
*/
GIT_EXTERN(int) git_repository_hashfile(
git_oid *out,
diff --git a/include/git2/sys/filter.h b/include/git2/sys/filter.h
index 8fe21c9c0..1b21a9d30 100644
--- a/include/git2/sys/filter.h
+++ b/include/git2/sys/filter.h
@@ -55,7 +55,10 @@ GIT_EXTERN(git_filter *) git_filter_lookup(const char *name);
* your own chains of filters.
*/
GIT_EXTERN(int) git_filter_list_new(
- git_filter_list **out, git_repository *repo, git_filter_mode_t mode);
+ git_filter_list **out,
+ git_repository *repo,
+ git_filter_mode_t mode,
+ git_filter_opt_t options);
/**
* Add a filter to a filter list with the given payload.
@@ -115,10 +118,15 @@ GIT_EXTERN(uint16_t) git_filter_source_filemode(const git_filter_source *src);
GIT_EXTERN(const git_oid *) git_filter_source_id(const git_filter_source *src);
/**
- * Get the git_filter_mode_t to be applied
+ * Get the git_filter_mode_t to be used
*/
GIT_EXTERN(git_filter_mode_t) git_filter_source_mode(const git_filter_source *src);
+/**
+ * Get the git_filter_opt_t options to be applied
+ */
+GIT_EXTERN(git_filter_opt_t) git_filter_source_options(const git_filter_source *src);
+
/*
* struct git_filter
*