Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/filter.c')
-rw-r--r--src/filter.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/filter.c b/src/filter.c
index 9f866fe88..b9e4f9ec8 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -23,6 +23,7 @@ struct git_filter_source {
git_oid oid; /* zero if unknown (which is likely) */
uint16_t filemode; /* zero if unknown */
git_filter_mode_t mode;
+ uint32_t options;
};
typedef struct {
@@ -69,7 +70,7 @@ static void filter_registry_shutdown(void)
return;
git_vector_foreach(&reg->filters, pos, fdef) {
- if (fdef->initialized && fdef->filter && fdef->filter->shutdown) {
+ if (fdef->filter && fdef->filter->shutdown) {
fdef->filter->shutdown(fdef->filter);
fdef->initialized = false;
}
@@ -358,6 +359,11 @@ git_filter_mode_t git_filter_source_mode(const git_filter_source *src)
return src->mode;
}
+uint32_t git_filter_source_options(const git_filter_source *src)
+{
+ return src->options;
+}
+
static int filter_list_new(
git_filter_list **out, const git_filter_source *src)
{
@@ -372,6 +378,7 @@ static int filter_list_new(
fl->source.repo = src->repo;
fl->source.path = fl->path;
fl->source.mode = src->mode;
+ fl->source.options = src->options;
*out = fl;
return 0;
@@ -419,12 +426,16 @@ static int filter_list_check_attributes(
}
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,
+ uint32_t options)
{
git_filter_source src = { 0 };
src.repo = repo;
src.path = NULL;
src.mode = mode;
+ src.options = options;
return filter_list_new(out, &src);
}
@@ -433,7 +444,8 @@ 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,
+ uint32_t options)
{
int error = 0;
git_filter_list *fl = NULL;
@@ -448,6 +460,7 @@ int git_filter_list_load(
src.repo = repo;
src.path = path;
src.mode = mode;
+ src.options = options;
if (blob)
git_oid_cpy(&src.oid, git_blob_id(blob));
@@ -578,6 +591,9 @@ int git_filter_list_apply_to_data(
git_buf *dbuffer[2], local = GIT_BUF_INIT;
unsigned int si = 0;
+ git_buf_sanitize(tgt);
+ git_buf_sanitize(src);
+
if (!fl)
return filter_list_out_buffer_from_raw(tgt, src->ptr, src->size);
@@ -613,11 +629,11 @@ int git_filter_list_apply_to_data(
/* PASSTHROUGH means filter decided not to process the buffer */
error = 0;
} else if (!error) {
- git_buf_shorten(dbuffer[di], 0); /* force NUL termination */
+ git_buf_sanitize(dbuffer[di]); /* force NUL termination */
si = di; /* swap buffers */
} else {
tgt->size = 0;
- return error;
+ goto cleanup;
}
}
@@ -625,9 +641,10 @@ int git_filter_list_apply_to_data(
if (si != 1)
git_buf_swap(dbuffer[0], dbuffer[1]);
+cleanup:
git_buf_free(&local); /* don't leak if we allocated locally */
- return 0;
+ return error;
}
int git_filter_list_apply_to_file(