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
Michael J Gruber <git@drmicha.warpmail.net>
Date
Jan 23, 2009, 13:13 UTC
Message-ID
<4979C295.1000803@drmicha.warpmail.net>
In-Reply-To
<lyhc3q9pl1.fsf@leia.mandriva.com>
Pixel venit, vidit, dixit 23.01.2009 13:25:
Show 41 quoted lines
> hi, 
> 
> 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?
> 
> 
> reproducer: 
> 
> ----------
> #!/bin/sh -e
> 
> # the bug: if you transform a binary file into a symlink in one commit, 
> # the binary patch can't be used in "git apply"
> #
> # nb: if you uncomment the "##" lines, the problem disappears
> # since the first patch will empty the binary file then the non-binary file
> # will be transformed into a symlink
> 
> rm -rf t t2
> mkdir t
> dd if=/dev/urandom of=t/a count=10
> cp -r t t2
> 
> cd t
> git init
> git add .
> git commit -m initial
> 
> ##echo -n > a
> ##git commit -a -m foo
> ln -sf zzz a
> git commit -a -m foo2
> git format-patch :/initial
> 
> cd ../t2
> git apply ../t/*.patch
> 
> cd ..
> rm -rf t t2
> ----------

You're not even initialising a repo in t2. I assume you want to "cp -a t t2" after the "initial" commit, don't you? Doing that I get

error: binary patch to 'a' creates incorrect result (expecting e132db255c0e0e3e9309c3c58a0a9c9eb97dd942, got e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) error: a: patch does not apply error: a: already exists in working directory

which is not that magnificient either. If that's the error you're after your test script needs to be modified.

Michael
Previous: PixelNext: Jeff King
Message 2 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.