Merge branch 'jk/output-prefix-cleanup'

Code clean-up.

* jk/output-prefix-cleanup:
  diff: store graph prefix buf in git_graph struct
  diff: return line_prefix directly when possible
  diff: return const char from output_prefix callback
  diff: drop line_prefix_length field
  line-log: use diff_line_prefix() instead of custom helper
This commit is contained in:
Junio C Hamano
2024-10-10 14:22:29 -07:00
7 changed files with 28 additions and 43 deletions

View File

@ -900,16 +900,6 @@ static void print_line(const char *prefix, char first,
fputs("\\ No newline at end of file\n", file);
}
static const char *output_prefix(struct diff_options *opt)
{
if (opt->output_prefix) {
struct strbuf *sb = opt->output_prefix(opt, opt->output_prefix_data);
return sb->buf;
} else {
return "";
}
}
static void dump_diff_hacky_one(struct rev_info *rev, struct line_log_data *range)
{
unsigned int i, j = 0;
@ -919,7 +909,7 @@ static void dump_diff_hacky_one(struct rev_info *rev, struct line_log_data *rang
struct diff_ranges *diff = &range->diff;
struct diff_options *opt = &rev->diffopt;
const char *prefix = output_prefix(opt);
const char *prefix = diff_line_prefix(opt);
const char *c_reset = diff_get_color(opt->use_color, DIFF_RESET);
const char *c_frag = diff_get_color(opt->use_color, DIFF_FRAGINFO);
const char *c_meta = diff_get_color(opt->use_color, DIFF_METAINFO);
@ -1014,7 +1004,7 @@ out:
*/
static void dump_diff_hacky(struct rev_info *rev, struct line_log_data *range)
{
const char *prefix = output_prefix(&rev->diffopt);
const char *prefix = diff_line_prefix(&rev->diffopt);
fprintf(rev->diffopt.file, "%s\n", prefix);