author | Junio C Hamano <gitster@pobox.com> | |
Wed, 18 Jan 2012 23:16:19 +0000 (15:16 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 18 Jan 2012 23:16:19 +0000 (15:16 -0800) |
* tr/maint-word-diff-incomplete-line:
word-diff: ignore '\ No newline at eof' marker
word-diff: ignore '\ No newline at eof' marker
diff.c | patch | blob | history | |
t/t4034-diff-words.sh | patch | blob | history |
index 374ecf3b486e218c52f94ba14481a715c19b80db..7e154265f778c645192cbf17c65b9bea2a507402 100644 (file)
--- a/diff.c
+++ b/diff.c
diff_words_append(line, len,
&ecbdata->diff_words->plus);
return;
+ } else if (!prefixcmp(line, "\\ ")) {
+ /*
+ * Eat the "no newline at eof" marker as if we
+ * saw a "+" or "-" line with nothing on it,
+ * and return without diff_words_flush() to
+ * defer processing. If this is the end of
+ * preimage, more "+" lines may come after it.
+ */
+ return;
}
diff_words_flush(ecbdata);
if (ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN) {
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index 6f1e5a2a15f0215e4ed7c19437f5d000edbbd255..5c2012111c28d338ad979fb7bcca871e744184fe 100755 (executable)
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
word_diff --word-diff=plain
'
+test_expect_success 'word-diff with no newline at EOF' '
+ cat >expect <<-\EOF &&
+ diff --git a/pre b/post
+ index 7bf316e..3dd0303 100644
+ --- a/pre
+ +++ b/post
+ @@ -1 +1 @@
+ a a [-a-]{+ab+} a a
+ EOF
+ printf "%s" "a a a a a" >pre &&
+ printf "%s" "a a ab a a" >post &&
+ word_diff --word-diff=plain
+'
+
test_done