Re: [PATCH] diff --color-words -U0: fix the location of hunk headers
From: Markus Heidelberg <hidden>
Date: 2016-06-15 22:47:38
Johannes Schindelin, 29.10.2009:
Hi, On Thu, 29 Oct 2009, Markus Heidelberg wrote:quoted
Indeed my initial fix was in the same fashion:@@ -772,6 +772,15 @@ static void fn_out_consume(void *priv, char *line, unsigned long len) } if (line[0] == '@') { + if (ecbdata->diff_words) { + /* + * The content of the previous hunk, necessary for + * 0-context. + */ + if (ecbdata->diff_words->minus.text.size || + ecbdata->diff_words->plus.text.size) + diff_words_show(ecbdata->diff_words); + } len = sane_truncate_line(ecbdata, line, len); find_lno(line, ecbdata); emit_line(ecbdata->file,But then I thought I should not put the diff output from --color-words into the block that deals with the hunk header, but save another place where diff_words_show() is called.I found this paragraph, as well as the patches 2/3 and 3/3, hard to follow.
I try to reword:
With 2/3 and 3/3 I wanted to keep --color-words specific code in the
block starting with
if (ecbdata->diff_words) {
and didn't want to contaminate the block starting with
if (line[0] == '@') {
with non-hunk-header content.
But I'm not sure what's the better way and am content with either.
And besides, flushing in that block is the correct thing to do. The function diff_words_show() is a function for that exact purpose.
Yes, 2/3 and 3/3 just don't introduce a new invocation of this function at another place in the code. Markus