Re: [PATCH] Adjust diff-helper to diff-tree -v -z changes.
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:41:58
quoted
quoted
quoted
quoted
"LT" == Linus Torvalds [off-list ref] writes:
LT> I think this is really a bug in your "read_line()" interface.
LT> You should include the terminating character in the line count.
What the patch changed:
You give me a non diff-raw material "foo\nbar\n" when you
are not doing -z. I read that without -z. read_line()
drops the EOL so I get "foo" and "bar" on separate lines,
both of which I spit out with my own '\n' using "%s\n".
You give me "foo\nbar\n\0" to express the same under -z, and
I read that with -z. I get "foo\nbar\n" after read_line()
drops the EOL. I should spit it out without my own '\n',
i.e. not using "%s\n" but "%s".
If read_line() interface changes to include EOL, then...
You give me "foo\nbar\n" without -z. I read that without
-z. Fixed read_line() retains the EOL and I get "foo\n" and
"bar\n", and I do not have to add my own '\n' anymore; I
just do fputs().
You give me "foo\nbar\n\0" under -z, and I read that with
-z. Fixed read_line() retains the EOL so I get
"foo\nbar\n\0". I just do fputs() and it would drop the
'\0'.
What the last sentence does feels a bit hacky, but does the
right thing. It's a good fix.
Please discard the patch you are responding to unless you
already have applied it.