convert: drop len parameter from conversion checks
We've already extracted the useful information into our text_stat struct, so the length is no longer needed. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jan 24, 2019 at 08:12 UTC
129beeee9a6ad95153bc4ebce0cfb447e1451522
1 file changed
+7
-7
convert.c
+7
-7
@@ -92,7 +92,7 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *
92
* The same heuristics as diff.c::mmfile_is_binary()
93
* We treat files with bare CR as binary
94
*/
95
-static int convert_is_binary(unsigned long size, const struct text_stat *stats)
95
+static int convert_is_binary(const struct text_stat *stats)
96
{
97
if (stats->lonecr)
98
return 1;
@@ -110,7 +110,7 @@ static unsigned int gather_convert_stats(const char *data, unsigned long size)
110
if (!data || !size)
111
return 0;
112
gather_stats(data, size, &stats);
113
- if (convert_is_binary(size, &stats))
113
+ if (convert_is_binary(&stats))
114
ret |= CONVERT_STAT_BITS_BIN;
115
if (stats.crlf)
116
ret |= CONVERT_STAT_BITS_TXT_CRLF;
@@ -245,7 +245,7 @@ static int has_crlf_in_index(const struct index_state *istate, const char *path)
245
return has_crlf;
246
}
247
248
-static int will_convert_lf_to_crlf(size_t len, struct text_stat *stats,
248
+static int will_convert_lf_to_crlf(struct text_stat *stats,
249
enum crlf_action crlf_action)
250
{
251
if (output_eol(crlf_action) != EOL_CRLF)
@@ -260,7 +260,7 @@ static int will_convert_lf_to_crlf(size_t len, struct text_stat *stats,
260
if (stats->lonecr || stats->crlf)
261
return 0;
262
263
- if (convert_is_binary(len, stats))
263
+ if (convert_is_binary(stats))
264
return 0;
265
}
266
return 1;
@@ -527,7 +527,7 @@ static int crlf_to_git(const struct index_state *istate,
527
convert_crlf_into_lf = !!stats.crlf;
528
529
if (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {
530
- if (convert_is_binary(len, &stats))
530
+ if (convert_is_binary(&stats))
531
return 0;
532
/*
533
* If the file in the index has any CR in it, do not
@@ -549,7 +549,7 @@ static int crlf_to_git(const struct index_state *istate,
549
new_stats.crlf = 0;
550
}
551
/* simulate "git checkout" */
552
- if (will_convert_lf_to_crlf(len, &new_stats, crlf_action)) {
552
+ if (will_convert_lf_to_crlf(&new_stats, crlf_action)) {
553
new_stats.crlf += new_stats.lonelf;
554
new_stats.lonelf = 0;
555
}
@@ -601,7 +601,7 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,
601
return 0;
602
603
gather_stats(src, len, &stats);
604
- if (!will_convert_lf_to_crlf(len, &stats, crlf_action))
604
+ if (!will_convert_lf_to_crlf(&stats, crlf_action))
605
return 0;
606
607
/* are we "faking" in place editing ? */