Skip to content

Commit

Permalink
Merge branch 'tr/maint-word-diff-incomplete-line'
Browse files Browse the repository at this point in the history
* tr/maint-word-diff-incomplete-line:
  word-diff: ignore '\ No newline at eof' marker
  • Loading branch information
Junio C Hamano committed Jan 18, 2012
2 parents b63103e + c7c2bc0 commit 05c65cb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,15 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
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) {
Expand Down
14 changes: 14 additions & 0 deletions t/t4034-diff-words.sh
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,18 @@ test_expect_success 'word-diff with diff.sbe' '
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

0 comments on commit 05c65cb

Please sign in to comment.