summaryrefslogtreecommitdiff
path: root/color.c
diff options
context:
space:
mode:
authorThomas Rast <trast@student.ethz.ch>2010-04-14 17:59:06 +0200
committerJunio C Hamano <gitster@pobox.com>2010-04-14 10:56:53 -0700
commit882749a04f828fccd795deec4d0bf10ba09ae549 (patch)
tree3a0f2416464fd69565c29e701ad02cad83f4f89d /color.c
parent6555b196f00128f13ab8f719ee1e156238f16bb3 (diff)
downloadgit-882749a04f828fccd795deec4d0bf10ba09ae549.tar.gz
diff: add --word-diff option that generalizes --color-words
This teaches the --color-words engine a more general interface that supports two new modes: * --word-diff=plain, inspired by the 'wdiff' utility (most similar to 'wdiff -n <old> <new>'): uses delimiters [-removed-] and {+added+} * --word-diff=porcelain, which generates an ad-hoc machine readable format: - each diff unit is prefixed by [-+ ] and terminated by newline as in unified diff - newlines in the input are output as a line consisting only of a tilde '~' Both of these formats still support color if it is enabled, using it to highlight the differences. --color-words becomes a synonym for --word-diff=color, which is the color-only format. Also adds some compatibility/convenience options. Thanks to Junio C Hamano and Miles Bader for good ideas. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'color.c')
-rw-r--r--color.c28
1 files changed, 0 insertions, 28 deletions
diff --git a/color.c b/color.c
index bcf4e2c192..1b00554dd5 100644
--- a/color.c
+++ b/color.c
@@ -211,31 +211,3 @@ int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...)
va_end(args);
return r;
}
-
-/*
- * This function splits the buffer by newlines and colors the lines individually.
- *
- * Returns 0 on success.
- */
-int color_fwrite_lines(FILE *fp, const char *color,
- size_t count, const char *buf)
-{
- if (!*color)
- return fwrite(buf, count, 1, fp) != 1;
- while (count) {
- char *p = memchr(buf, '\n', count);
- if (p != buf && (fputs(color, fp) < 0 ||
- fwrite(buf, p ? p - buf : count, 1, fp) != 1 ||
- fputs(GIT_COLOR_RESET, fp) < 0))
- return -1;
- if (!p)
- return 0;
- if (fputc('\n', fp) < 0)
- return -1;
- count -= p + 1 - buf;
- buf = p + 1;
- }
- return 0;
-}
-
-