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

[PATCH 2/1] Verify that --cherry-pick avoids looking at full diffs

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 15, 2016, 15:51 UTC
Message-ID
<alpine.DEB.2.20.1607151749540.6426@virtualbox>

The entire point of the previous patch was to make sure that we look at abbreviated patch IDs (using the diff *headers* only, but avoiding to load the blobs into memory and diff them) first, and only look at full patch IDs when the abbreviated patch IDs were not for the --cherry-pick test.

Let's make sure that we actually avoid looking at the full patch ID, simply by corrupting an object that is needed for the full patch ID, and then seeing that --cherry-pick still works.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	On Fri, 15 Jul 2016, Johannes Schindelin wrote:
	> I also think that this patch series could use a test that
	> verifies that we no longer generate unneeded diffs. Maybe by
	> rebasing a commit on top of an commit touching a different file,
	> after corrupting the blob of the latter one? Let me give it a
	> try.
	And here it is. I verified that this test passes with your patch
	and fails without it.
 t/t6007-rev-list-cherry-pick-file.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh
index 28d4f6b..a5f7c2a 100755
--- a/t/t6007-rev-list-cherry-pick-file.sh
+++ b/t/t6007-rev-list-cherry-pick-file.sh
@@ -207,4 +207,23 @@ test_expect_success '--count --left-right' '
 	test_cmp expect actual
 '
 
+remove_loose_object () {
+	sha1="$(git rev-parse "$1")" &&
+	remainder=${sha1#??} &&
+	firsttwo=${sha1%$remainder} &&
+	rm .git/objects/$firsttwo/$remainder
+}
+
+test_expect_success '--cherry-pick avoids looking at full diffs' '
+	git checkout -b shy-diff &&
+	test_commit dont-look-at-me &&
+	echo Hello >dont-look-at-me.t &&
+	test_tick &&
+	git commit -m tip dont-look-at-me.t &&
+	git checkout -b mainline HEAD^ &&
+	test_commit to-cherry-pick &&
+	remove_loose_object shy-diff^:dont-look-at-me.t &&
+	git rev-list --cherry-pick ...shy-diff
+'
+
 test_done
-- 
2.9.0.281.g286a8d9
Next: Junio C Hamano
Message 1 of 3 in “Verify that --cherry-pick avoids looking at full diffs”
  1. 2/1 Verify that --cherry-pick avoids looking at full diffsJohannes Schindelin, Jul 15, 2016
  2. Junio C HamanoJul 15, 2016
  3. Johannes SchindelinJul 16, 2016

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.