diff: retire sane_truncate_fn

Long time ago, 23707811 ("diff: do not chomp hunk-header in the middle of a character", 2008-01-02) introduced sane_truncate_line() helper function to trim the "function header" line that is shown at the end of the hunk header line, in order to avoid chomping it in the middle of a single UTF-8 character. It also added a facility to define a custom callback function to make it possible to extend it to non UTF-8 encodings. During the following 8 1/2 years, nobody found need for this custom callback facility. A custom callback function is a wrong design to use here anyway---if your contents need support for non UTF-8 encoding, you shouldn't have to write a custom function and recompile Git to plumb it in. A better approach would be to extend sane_truncate_line() function and have a new member in emit_callback to conditionally trigger it. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 17, 2017 at 10:27 UTC 08a8509e50e560e3d14adb05698efe9ff063bbd3
1 file changed -5
diff.c
-5
@@ -406,8 +406,6 @@ static struct diff_tempfile {
406 struct tempfile tempfile;
407 } diff_temp[2];
408
409 -typedef unsigned long (*sane_truncate_fn)(char *line, unsigned long len);
410 -
409 struct emit_callback {
410 int color_diff;
411 unsigned ws_rule;
@@ -415,7 +413,6 @@ struct emit_callback {
413 int blank_at_eof_in_postimage;
414 int lno_in_preimage;
415 int lno_in_postimage;
418 - sane_truncate_fn truncate;
416 const char **label_path;
417 struct diff_words_data *diff_words;
418 struct diff_options *opt;
@@ -1243,8 +1240,6 @@ static unsigned long sane_truncate_line(struct emit_callback *ecb, char *line, u
1240 unsigned long allot;
1241 size_t l = len;
1242
1246 - if (ecb->truncate)
1247 - return ecb->truncate(line, len);
1243 cp = line;
1244 allot = l;
1245 while (0 < l) {