Skip to content

Commit 3e9e82c

Browse files
jeffhostetlergitster
authored andcommitted
convert: add get_stream_filter_ca() variant
Like the previous patch, we will also need to call get_stream_filter() with a precomputed `struct conv_attrs`, when we add support for parallel checkout workers. So add the _ca() variant which takes the conversion attributes struct as a parameter. Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Matheus Tavares <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 55b4ad0 commit 3e9e82c

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

convert.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,41 +1942,47 @@ static struct stream_filter *ident_filter(const struct object_id *oid)
19421942
}
19431943

19441944
/*
1945-
* Return an appropriately constructed filter for the path, or NULL if
1945+
* Return an appropriately constructed filter for the given ca, or NULL if
19461946
* the contents cannot be filtered without reading the whole thing
19471947
* in-core.
19481948
*
19491949
* Note that you would be crazy to set CRLF, smudge/clean or ident to a
19501950
* large binary blob you would want us not to slurp into the memory!
19511951
*/
1952-
struct stream_filter *get_stream_filter(const struct index_state *istate,
1953-
const char *path,
1954-
const struct object_id *oid)
1952+
struct stream_filter *get_stream_filter_ca(const struct conv_attrs *ca,
1953+
const struct object_id *oid)
19551954
{
1956-
struct conv_attrs ca;
19571955
struct stream_filter *filter = NULL;
19581956

1959-
convert_attrs(istate, &ca, path);
1960-
if (ca.drv && (ca.drv->process || ca.drv->smudge || ca.drv->clean))
1957+
if (ca->drv && (ca->drv->process || ca->drv->smudge || ca->drv->clean))
19611958
return NULL;
19621959

1963-
if (ca.working_tree_encoding)
1960+
if (ca->working_tree_encoding)
19641961
return NULL;
19651962

1966-
if (ca.crlf_action == CRLF_AUTO || ca.crlf_action == CRLF_AUTO_CRLF)
1963+
if (ca->crlf_action == CRLF_AUTO || ca->crlf_action == CRLF_AUTO_CRLF)
19671964
return NULL;
19681965

1969-
if (ca.ident)
1966+
if (ca->ident)
19701967
filter = ident_filter(oid);
19711968

1972-
if (output_eol(ca.crlf_action) == EOL_CRLF)
1969+
if (output_eol(ca->crlf_action) == EOL_CRLF)
19731970
filter = cascade_filter(filter, lf_to_crlf_filter());
19741971
else
19751972
filter = cascade_filter(filter, &null_filter_singleton);
19761973

19771974
return filter;
19781975
}
19791976

1977+
struct stream_filter *get_stream_filter(const struct index_state *istate,
1978+
const char *path,
1979+
const struct object_id *oid)
1980+
{
1981+
struct conv_attrs ca;
1982+
convert_attrs(istate, &ca, path);
1983+
return get_stream_filter_ca(&ca, oid);
1984+
}
1985+
19801986
void free_stream_filter(struct stream_filter *filter)
19811987
{
19821988
filter->vtbl->free(filter);

convert.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ struct stream_filter; /* opaque */
179179
struct stream_filter *get_stream_filter(const struct index_state *istate,
180180
const char *path,
181181
const struct object_id *);
182+
struct stream_filter *get_stream_filter_ca(const struct conv_attrs *ca,
183+
const struct object_id *oid);
182184
void free_stream_filter(struct stream_filter *);
183185
int is_null_stream_filter(struct stream_filter *);
184186

0 commit comments

Comments
 (0)