summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2013-02-07 20:15:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-02-12 19:42:07 (GMT)
commitf192223447746a503bf664135a0e537d15876ebe (patch)
treeb8dc638c95c4e2b289f899cbad1d7e1a0323dd26 /diff.c
parent32b367e4441f8566f200459149d1aaee8fafc867 (diff)
downloadgit-f192223447746a503bf664135a0e537d15876ebe.zip
git-f192223447746a503bf664135a0e537d15876ebe.tar.gz
git-f192223447746a503bf664135a0e537d15876ebe.tar.bz2
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>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/diff.c b/diff.c
index e00fc90..b768b7d 100644
--- a/diff.c
+++ b/diff.c
@@ -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;