summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2017-06-30 00:06:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-30 20:13:01 (GMT)
commitb9cbfde6b12f1a8f5341a5be624bd41e12e5dea3 (patch)
tree2181bdaf8a97b52f521cf2bb37d669bda38d23e1 /diff.c
parent68abc6f1c744cd287423eb451925fe86d1230e12 (diff)
downloadgit-b9cbfde6b12f1a8f5341a5be624bd41e12e5dea3.zip
git-b9cbfde6b12f1a8f5341a5be624bd41e12e5dea3.tar.gz
git-b9cbfde6b12f1a8f5341a5be624bd41e12e5dea3.tar.bz2
diff.c: emit_diff_symbol learns DIFF_SYMBOL_NO_LF_EOF
Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/diff.c b/diff.c
index 6e48a12..488096b 100644
--- a/diff.c
+++ b/diff.c
@@ -561,6 +561,7 @@ static void emit_line(struct diff_options *o, const char *set, const char *reset
}
enum diff_symbol {
+ DIFF_SYMBOL_NO_LF_EOF,
DIFF_SYMBOL_CONTEXT_FRAGINFO,
DIFF_SYMBOL_CONTEXT_MARKER,
DIFF_SYMBOL_SEPARATOR
@@ -569,8 +570,16 @@ enum diff_symbol {
static void emit_diff_symbol(struct diff_options *o, enum diff_symbol s,
const char *line, int len)
{
+ static const char *nneof = " No newline at end of file\n";
const char *context, *reset;
switch (s) {
+ case DIFF_SYMBOL_NO_LF_EOF:
+ context = diff_get_color_opt(o, DIFF_CONTEXT);
+ reset = diff_get_color_opt(o, DIFF_RESET);
+ putc('\n', o->file);
+ emit_line_0(o, context, reset, '\\',
+ nneof, strlen(nneof));
+ break;
case DIFF_SYMBOL_CONTEXT_FRAGINFO:
emit_line(o, "", "", line, len);
break;
@@ -751,7 +760,6 @@ static void emit_rewrite_lines(struct emit_callback *ecb,
int prefix, const char *data, int size)
{
const char *endp = NULL;
- static const char *nneof = " No newline at end of file\n";
const char *reset = diff_get_color(ecb->color_diff, DIFF_RESET);
while (0 < size) {
@@ -769,13 +777,8 @@ static void emit_rewrite_lines(struct emit_callback *ecb,
size -= len;
data += len;
}
- if (!endp) {
- const char *context = diff_get_color(ecb->color_diff,
- DIFF_CONTEXT);
- putc('\n', ecb->opt->file);
- emit_line_0(ecb->opt, context, reset, '\\',
- nneof, strlen(nneof));
- }
+ if (!endp)
+ emit_diff_symbol(ecb->opt, DIFF_SYMBOL_NO_LF_EOF, NULL, 0);
}
static void emit_rewrite_diff(const char *name_a,