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

Re: bug: transform a binary file into a symlink in one commit => invalid binary patch

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 26, 2009, 07:37 UTC
Message-ID
<7vy6wy8qmm.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20090126003556.GA19368@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 12 quoted lines
> On Fri, Jan 23, 2009 at 01:25:30PM +0100, Pixel wrote:
>
>> i hit a bug (git 1.6.1): when you transform a binary file into a
>> symlink in one commit, the binary patch can't be used in "git apply".
>> Is it a known issue?
>
> Not that I know of.
>
> Below is a patch against the test suite that fairly neatly displays the
> problem. I didn't get a chance to look into actually fixing it, though
> (I'm not even sure the problem is in apply, and not in the generated
> patch).
The generated diff is wrong.

A filepair that changes type must be split into deletion followed by creation, which means the "index" line should say 0{40} on the right hand side for the first half and then 0{40} on the left hand side for the second half. The patch generated by this step:

> +test_expect_success 'create patch' '
> +	git diff-tree --binary HEAD^ HEAD >patch
> +'
However says the blob contents change from "\0" to "file" on both.

This is because diff.c::run_diff() computes "index" only once and reuses it for both halves.

Previous: Jeff KingNext: Junio C Hamano
Message 4 of 7 in “bug: transform a binary file into a symlink in one commit => invalid binary patch”
  1. PixelJan 23, 2009
  2. Michael J GruberJan 23, 2009
  3. Jeff KingJan 26, 2009
  4. Junio C HamanoJan 26, 2009
  5. diff.c: output correct index lines for a split diffJunio C Hamano, Jan 26, 2009
  6. Jeff KingJan 26, 2009
  7. Junio C HamanoJan 28, 2009

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.