git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.

Previous: Linus Torvalds
Message 13 of 13 in “Fix ptrdiff_t vs. int”
  1. Fix ptrdiff_t vs. intMarkus F.X.J. Oberhumer, May 27, 2005
  2. Danjel McGouganMay 27, 2005
  3. Morten WelinderMay 27, 2005
  4. H. Peter AnvinMay 27, 2005
  5. Linus TorvaldsMay 27, 2005
  6. Linus TorvaldsMay 27, 2005
  7. Markus F.X.J. OberhumerMay 27, 2005
  8. H. Peter AnvinMay 27, 2005
  9. Linus TorvaldsMay 27, 2005
  10. Junio C HamanoMay 27, 2005
  11. Adjust diff-helper to diff-tree -v -z changes.Junio C Hamano, May 28, 2005
  12. Linus TorvaldsMay 29, 2005
  13. Junio C HamanoMay 29, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.