Skip to content

Commit

Permalink
diff: add diff_line_prefix function
Browse files Browse the repository at this point in the history
This is a helper function to call the diff output_prefix function and
return its value as a C string, allowing us to greatly simplify
everywhere that needs to get the output prefix.

Signed-off-by: John Keeping <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
johnkeeping authored and gitster committed Feb 12, 2013
1 parent 32b367e commit f192223
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,16 @@ const char *diff_get_color(int diff_use_color, enum color_diff ix)
return "";
}

const char *diff_line_prefix(struct diff_options *opt)
{
struct strbuf *msgbuf;
if (!opt->output_prefix)
return "";

msgbuf = opt->output_prefix(opt, opt->output_prefix_data);
return msgbuf->buf;
}

static unsigned long sane_truncate_line(struct emit_callback *ecb, char *line, unsigned long len)
{
const char *cp;
Expand Down
3 changes: 3 additions & 0 deletions diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ const char *diff_get_color(int diff_use_color, enum color_diff ix);
diff_get_color((o)->use_color, ix)


const char *diff_line_prefix(struct diff_options *);


extern const char mime_boundary_leader[];

extern void diff_tree_setup_paths(const char **paths, struct diff_options *);
Expand Down

0 comments on commit f192223

Please sign in to comment.