Re: [PATCH 06/10] diff.c: emit_line_0 can handle no color
On Mon, Sep 12, 2016 at 5:11 PM, Junio C Hamanowrote: > Stefan Beller writes: > >> From: Stefan Beller >> >> --- > > "X can do Y" can be taken as a statement of fact (to which "so > what?" is an appropriate response), a desire (to which "then please > say 'make X do Y' instead" is an appropriate response), or a report > of a bug (to which "please explain why X should be forbidden from > doing Y" is an appropriate response). > > This is way under-explained. I think this is "make X do Y" kind, > and if so, please say so and possibly why it is a good idea to teach > X how to do Y. > > Thanks. Ok, I see the general pattern of your answers: Add more explanations. Answering for patch 01/10 as well as this one here: I want to propose an option to detect moved lines in a patch, which cannot be done in a one-pass over the diff. Instead we need to go over the whole diff twice, because we cannot detect the first line of a line pair that got moved in the first pass. So I aim for * collecting all output into a buffer as a first pass, * as the second pass output the buffer. So in a later patch I will split up the emit_line_* machinery to either emitting to options->file or buffering if we do the 2 pass thing. To make sure the 2 passes work correctly, we need to make sure all output is routed through the emit_line functions, and there will be no direct writes. Now that we will be using the emit_lines functions for non colored output as well, we want to pass in "no color" which I think is best done via NULL and then not calling the output of the color writes.
Re: [PATCH 06/10] diff.c: emit_line_0 can handle no color
Stefan Bellerwrites: > From: Stefan Beller > > --- "X can do Y" can be taken as a statement of fact (to which "so what?" is an appropriate response), a desire (to which "then please say 'make X do Y' instead" is an appropriate response), or a report of a bug (to which "please explain why X should be forbidden from doing Y" is an appropriate response). This is way under-explained. I think this is "make X do Y" kind, and if so, please say so and possibly why it is a good idea to teach X how to do Y. Thanks. > diff.c | 6 -- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/diff.c b/diff.c > index 87b1bb2..2aefd0f 100644 > --- a/diff.c > +++ b/diff.c > @@ -473,11 +473,13 @@ static void emit_line_0(struct diff_options *o, const > char *set, const char *res > } > > if (len || !nofirst) { > - fputs(set, file); > + if (set) > + fputs(set, file); > if (!nofirst) > fputc(first, file); > fwrite(line, len, 1, file); > - fputs(reset, file); > + if (reset) > + fputs(reset, file); > } > if (has_trailing_carriage_return) > fputc('\r', file);
[PATCH 06/10] diff.c: emit_line_0 can handle no color
From: Stefan Beller--- diff.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/diff.c b/diff.c index 87b1bb2..2aefd0f 100644 --- a/diff.c +++ b/diff.c @@ -473,11 +473,13 @@ static void emit_line_0(struct diff_options *o, const char *set, const char *res } if (len || !nofirst) { - fputs(set, file); + if (set) + fputs(set, file); if (!nofirst) fputc(first, file); fwrite(line, len, 1, file); - fputs(reset, file); + if (reset) + fputs(reset, file); } if (has_trailing_carriage_return) fputc('\r', file); -- 2.7.4