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

Re: [PATCH v2] apply: resolve trivial merge without hitting ll-merge with "--3way"

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Sep 6, 2021, 21:59 UTC
Message-ID
<87pmtlnyu7.fsf@evledraar.gmail.com>
In-Reply-To
<20210905190657.2906699-1-gitster@pobox.com>
On Sun, Sep 05 2021, Junio C Hamano wrote:
> +	if (!image->buf || type != OBJ_BLOB)
> +		die("unable to read blob object %s", oid_to_hex(result_id));

This die() message seems to only be applicable to the first condition here, shouldn't this be:

    if (!image->buf)
        die(_("unable to read blob object %s"), oid_to_hex(result_id));
    if (type != OBJ_BLOB)
        die(_("object %s is %s, expected blob"), oid_to_hex(result_id), type_name(type));
Also as shown there, missing _() for marking the translation.
> [...]
> +test_expect_success 'apply binary file patch' '
> +	git reset --hard main &&

Partly this is cleaning up a mess after an existing test, but here there's no reason we can't use test_when_finished() for all the new tests to make them clean up after themselves:

diff --git a/t/t4108-apply-threeway.sh b/t/t4108-apply-threeway.sh
index cc3aa3314a3..c3c9b52e30d 100755
--- a/t/t4108-apply-threeway.sh
+++ b/t/t4108-apply-threeway.sh
@@ -232,6 +232,8 @@ test_expect_success 'apply with --3way --cached and conflicts' '
 
 test_expect_success 'apply binary file patch' '
 	git reset --hard main &&
+	test_when_finished "git reset --hard main" &&
+
 	cp "$TEST_DIRECTORY/test-binary-1.png" bin.png &&
 	git add bin.png &&
 	git commit -m "add binary file" &&
@@ -246,7 +248,8 @@ test_expect_success 'apply binary file patch' '
 '
 
 test_expect_success 'apply binary file patch with 3way' '
-	git reset --hard main &&
+	test_when_finished "git reset --hard main" &&
+
 	cp "$TEST_DIRECTORY/test-binary-1.png" bin.png &&
 	git add bin.png &&
 	git commit -m "add binary file" &&
@@ -261,7 +264,8 @@ test_expect_success 'apply binary file patch with 3way' '
 '
 
 test_expect_success 'apply full-index patch with 3way' '
-	git reset --hard main &&
+	test_when_finished "git reset --hard main" &&
+
 	cp "$TEST_DIRECTORY/test-binary-1.png" bin.png &&
 	git add bin.png &&
 	git commit -m "add binary file" &&
Previous: Elijah NewrenNext: Junio C Hamano
Message 9 of 16 in “git-apply: fix --3way with binary patch”
  1. git-apply: fix --3way with binary patchJerry Zhang, Jul 28, 2021
  2. Junio C HamanoJul 28, 2021
  3. Junio C HamanoJul 28, 2021
  4. ll-merge: teach ll_binary_merge() a trivial three-way mergeJunio C Hamano, Jul 28, 2021
  5. Elijah NewrenJul 28, 2021
  6. Junio C HamanoJul 29, 2021
  7. apply: resolve trivial merge without hitting ll-merge with "--3way"Junio C Hamano, Sep 5, 2021
  8. Elijah NewrenSep 6, 2021
  9. Ævar Arnfjörð BjarmasonSep 6, 2021
  10. Junio C HamanoSep 7, 2021
  11. Junio C HamanoSep 7, 2021
  12. Jerry ZhangJul 28, 2021
  13. Jerry ZhangJul 28, 2021
  14. Junio C HamanoJul 28, 2021
  15. Jerry ZhangJul 28, 2021
  16. Junio C HamanoJul 28, 2021

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.