Re: [PATCH] Adjust diff-helper to diff-tree -v -z changes.
- From
Junio C Hamano <junkio@cox.net>
- Date
- May 29, 2005, 20:21 UTC
- Message-ID
- <7vmzqdlr4v.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <Pine.LNX.4.58.0505291129520.10545@ppc970.osdl.org>
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> 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.