Re: [PATCH] diff.c: output correct index lines for a split diff
- From
Jeff King <peff@peff.net>
- Date
- Jan 26, 2009, 09:07 UTC
- Message-ID
- <20090126090712.GA12648@coredump.intra.peff.net>
- In-Reply-To
- <7vhc3m8o0b.fsf_-_@gitster.siamese.dyndns.org>
On Mon, Jan 26, 2009 at 12:33:56AM -0800, Junio C Hamano wrote:
> This moves the code to generate metainfo lines around, so that two > independent sets of metainfo lines are used for the split halves.
The patch and the generated output look correct to me, so
Acked-by: Jeff King <peff@peff.net>
> I did not include your new test script here; perhaps we can add it to an > existing typechange diff/apply test, like t4114?
I think it makes sense to add to t4114. Please squash in the test below.
One think to note, though: test 8 (binary -> symlink) shows breakage with the current master, but test 9 (symlink -> binary) does not. However, if you run the test under "-d" you can see that the diff has bogus metainfo. It's just that "apply" doesn't care.
Your test fixes the test failure, and I verified manually that the diff output is sensible. I don't think an additional test is worth it, but we could add one that explicitly checks the metainfo if you want to be extra paranoid.
---
diff --git a/t/t4114-apply-typechange.sh b/t/t4114-apply-typechange.sh index 5533492..0f185ca 100755 --- a/t/t4114-apply-typechange.sh +++ b/t/t4114-apply-typechange.sh @@ -25,6 +25,10 @@ test_expect_success 'setup repository and commits' ' git update-index foo && git commit -m "foo back to file" && git branch foo-back-to-file && + printf "\0" > foo && + git update-index foo && + git commit -m "foo becomes binary" && + git branch foo-becomes-binary && rm -f foo && git update-index --remove foo && mkdir foo && @@ -85,6 +89,20 @@ test_expect_success 'symlink becomes file' ' ' test_debug 'cat patch' +test_expect_success 'binary file becomes symlink' ' + git checkout -f foo-becomes-binary && + git diff-tree -p --binary HEAD foo-symlinked-to-bar > patch && + git apply --index < patch + ' +test_debug 'cat patch' + +test_expect_success 'symlink becomes binary file' ' + git checkout -f foo-symlinked-to-bar && + git diff-tree -p --binary HEAD foo-becomes-binary > patch && + git apply --index < patch + ' +test_debug 'cat patch' + test_expect_success 'symlink becomes directory' ' git checkout -f foo-symlinked-to-bar &&