Skip to content

Commit f59d15b

Browse files
jeffhostetlergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Matheus Tavares <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3e9e82c commit f59d15b

File tree

2 files changed

+52
-7
lines changed

2 files changed

+52
-7
lines changed

convert.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,13 +1954,7 @@ struct stream_filter *get_stream_filter_ca(const struct conv_attrs *ca,
19541954
{
19551955
struct stream_filter *filter = NULL;
19561956

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)
19641958
return NULL;
19651959

19661960
if (ca->ident)
@@ -2016,3 +2010,21 @@ void clone_checkout_metadata(struct checkout_metadata *dst,
20162010
if (blob)
20172011
oidcpy(&dst->blob, blob);
20182012
}
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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,37 @@ int stream_filter(struct stream_filter *,
200200
const char *input, size_t *isize_p,
201201
char *output, size_t *osize_p);
202202

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+
203236
#endif /* CONVERT_H */

0 commit comments

Comments
 (0)