convert: add classification for conv_attrs struct
Create `enum conv_attrs_classification` to express the different ways that attributes are handled for a blob during checkout. This will be used in a later commit when deciding whether to add a file to the parallel or delayed queue during checkout. For now, we can also use it in get_stream_filter_ca() to simplify the function (as the classifying logic is the same). Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff Hostetler committed
Dec 16, 2020 at 11:50 UTC
f59d15bb420b649a6ee3163a3418aac6b813d331
2 files changed
+52
-7
convert.c
+19
-7
@@ -1954,13 +1954,7 @@ struct stream_filter *get_stream_filter_ca(const struct conv_attrs *ca,
1954
{
1955
struct stream_filter *filter = NULL;
1956
1957
- if (ca->drv && (ca->drv->process || ca->drv->smudge || ca->drv->clean))
1958
- return NULL;
1959
-
1960
- if (ca->working_tree_encoding)
1961
- return NULL;
1962
-
1963
- if (ca->crlf_action == CRLF_AUTO || ca->crlf_action == CRLF_AUTO_CRLF)
1957
+ if (classify_conv_attrs(ca) != CA_CLASS_STREAMABLE)
1958
return NULL;
1959
1960
if (ca->ident)
@@ -2016,3 +2010,21 @@ void clone_checkout_metadata(struct checkout_metadata *dst,
2010
if (blob)
2011
oidcpy(&dst->blob, blob);
2012
}
2013
+
2014
+enum conv_attrs_classification classify_conv_attrs(const struct conv_attrs *ca)
2015
+{
2016
+ if (ca->drv) {
2017
+ if (ca->drv->process)
2018
+ return CA_CLASS_INCORE_PROCESS;
2019
+ if (ca->drv->smudge || ca->drv->clean)
2020
+ return CA_CLASS_INCORE_FILTER;
2021
+ }
2022
+
2023
+ if (ca->working_tree_encoding)
2024
+ return CA_CLASS_INCORE;
2025
+
2026
+ if (ca->crlf_action == CRLF_AUTO || ca->crlf_action == CRLF_AUTO_CRLF)
2027
+ return CA_CLASS_INCORE;
2028
+
2029
+ return CA_CLASS_STREAMABLE;
2030
+}
convert.h
+33
@@ -200,4 +200,37 @@ int stream_filter(struct stream_filter *,
200
const char *input, size_t *isize_p,
201
char *output, size_t *osize_p);
202
203
+enum conv_attrs_classification {
204
+ /*
205
+ * The blob must be loaded into a buffer before it can be
206
+ * smudged. All smudging is done in-proc.
207
+ */
208
+ CA_CLASS_INCORE,
209
+
210
+ /*
211
+ * The blob must be loaded into a buffer, but uses a
212
+ * single-file driver filter, such as rot13.
213
+ */
214
+ CA_CLASS_INCORE_FILTER,
215
+
216
+ /*
217
+ * The blob must be loaded into a buffer, but uses a
218
+ * long-running driver process, such as LFS. This might or
219
+ * might not use delayed operations. (The important thing is
220
+ * that there is a single subordinate long-running process
221
+ * handling all associated blobs and in case of delayed
222
+ * operations, may hold per-blob state.)
223
+ */
224
+ CA_CLASS_INCORE_PROCESS,
225
+
226
+ /*
227
+ * The blob can be streamed and smudged without needing to
228
+ * completely read it into a buffer.
229
+ */
230
+ CA_CLASS_STREAMABLE,
231
+};
232
+
233
+enum conv_attrs_classification classify_conv_attrs(
234
+ const struct conv_attrs *ca);
235
+
236
#endif /* CONVERT_H */