Commit 9c9aa1bad3b364f7dfdccd5f6abe880f7e18c499

Edward Thomson 2015-02-19T11:32:55

filter: take `temp_buf` in `git_filter_options`

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(