Subject: [PATCH 3/7] diff --color-words: another special diff case

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Thu, 31 Dec 2015 19:37:33 +0700

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 diff.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/diff.c b/diff.c
index 8af1df1..1354368 100644
--- a/diff.c
+++ b/diff.c
@@ -1037,6 +1037,16 @@ static void diff_words_show(struct diff_words_data *diff_words)
 		diff_words->minus.text.size = 0;
 		return;
 	}
+	/* special case: only addition */
+	if (!diff_words->minus.text.size) {
+		fputs(line_prefix, diff_words->opt->file);
+		fn_out_diff_words_write_helper(diff_words->opt->file,
+			&style->new, style->newline,
+			diff_words->plus.text.size,
+			diff_words->plus.text.ptr, line_prefix);
+		diff_words->plus.text.size = 0;
+		return;
+	}
 
 	diff_words->current_plus = diff_words->plus.text.ptr;
 	diff_words->last_minus = 0;
-- 
2.3.0.rc1.137.g477eb31