filter: take `temp_buf` in `git_filter_options`
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
diff --git a/src/checkout.c b/src/checkout.c
index 2c47147..f71be26 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -1440,6 +1440,7 @@ static int blob_content_to_file(
}
filter_opts.attr_session = &data->attr_session;
+ filter_opts.temp_buf = &data->tmp;
if (!data->opts.disable_filters &&
(error = git_filter_list__load_ext(
@@ -1447,9 +1448,6 @@ static int blob_content_to_file(
GIT_FILTER_TO_WORKTREE, &filter_opts)))
return error;
- if (fl)
- git_filter_list__set_temp_buf(fl, &data->tmp);
-
/* setup the writer */
memset(&writer, 0, sizeof(struct checkout_stream));
writer.base.write = checkout_stream_write;
@@ -2057,6 +2055,7 @@ static int checkout_write_merge(
in_data.size = result.len;
filter_opts.attr_session = &data->attr_session;
+ filter_opts.temp_buf = &data->tmp;
if ((error = git_filter_list__load_ext(
&fl, data->repo, NULL, git_buf_cstr(&path_workdir),
diff --git a/src/filter.c b/src/filter.c
index 646f1bc..4fbf84f 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -517,8 +517,12 @@ int git_filter_list__load_ext(
else if (error < 0)
break;
else {
- if (!fl && (error = filter_list_new(&fl, &src)) < 0)
- return error;
+ if (!fl) {
+ if ((error = filter_list_new(&fl, &src)) < 0)
+ return error;
+
+ fl->temp_buf = filter_opts->temp_buf;
+ }
fe = git_array_alloc(fl->filters);
GITERR_CHECK_ALLOC(fe);
@@ -553,11 +557,6 @@ int git_filter_list_load(
filters, repo, blob, path, mode, &filter_opts);
}
-void git_filter_list__set_temp_buf(git_filter_list *fl, git_buf *temp_buf)
-{
- fl->temp_buf = temp_buf;
-}
-
void git_filter_list_free(git_filter_list *fl)
{
uint32_t i;
diff --git a/src/filter.h b/src/filter.h
index 85ef4a6..5062afb 100644
--- a/src/filter.h
+++ b/src/filter.h
@@ -26,14 +26,12 @@ typedef enum {
typedef struct {
git_attr_session *attr_session;
+ git_buf *temp_buf;
uint32_t flags;
} git_filter_options;
#define GIT_FILTER_OPTIONS_INIT {0}
-extern void git_filter_list__set_temp_buf(
- git_filter_list *fl, git_buf *temp_buf);
-
extern void git_filter_free(git_filter *filter);
extern int git_filter_list__load_ext(