Re: bug: transform a binary file into a symlink in one commit => invalid binary patch
- From
Jeff King <peff@peff.net>
- Date
- Jan 26, 2009, 00:35 UTC
- Message-ID
- <20090126003556.GA19368@coredump.intra.peff.net>
- In-Reply-To
- <lyhc3q9pl1.fsf@leia.mandriva.com>
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).
---
diff --git a/t/t4130-apply-symlink-binary.sh b/t/t4130-apply-symlink-binary.sh new file mode 100755 index 0000000..0ee2ba1 --- /dev/null +++ b/t/t4130-apply-symlink-binary.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +test_description='apply handles binary to symlink conversion' +. ./test-lib.sh + +test_expect_success 'create commit with binary' ' + echo content >file && git add file && + printf "\0" > binary && git add binary && + git commit -m one +' + +test_expect_success 'convert binary to symlink' ' + rm binary && + ln -s file binary && + git add binary && + git commit -m two +' + +test_expect_success 'create patch' ' + git diff-tree --binary HEAD^ HEAD >patch +' + +test_expect_success 'apply patch' ' + git reset --hard HEAD^ && + git apply patch && + test -h binary && + test_cmp binary file +' + +test_done