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

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 &&
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 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.