diff: add diff_line_prefix function
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 <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
32b367e444
commit
f192223447
10
diff.c
10
diff.c
@@ -1105,6 +1105,16 @@ const char *diff_get_color(int diff_use_color, enum color_diff ix)
|
|||||||
return "";
|
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)
|
static unsigned long sane_truncate_line(struct emit_callback *ecb, char *line, unsigned long len)
|
||||||
{
|
{
|
||||||
const char *cp;
|
const char *cp;
|
||||||
|
|||||||
3
diff.h
3
diff.h
@@ -174,6 +174,9 @@ const char *diff_get_color(int diff_use_color, enum color_diff ix);
|
|||||||
diff_get_color((o)->use_color, ix)
|
diff_get_color((o)->use_color, ix)
|
||||||
|
|
||||||
|
|
||||||
|
const char *diff_line_prefix(struct diff_options *);
|
||||||
|
|
||||||
|
|
||||||
extern const char mime_boundary_leader[];
|
extern const char mime_boundary_leader[];
|
||||||
|
|
||||||
extern void diff_tree_setup_paths(const char **paths, struct diff_options *);
|
extern void diff_tree_setup_paths(const char **paths, struct diff_options *);
|
||||||
|
|||||||
Reference in New Issue
Block a user