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

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Mon, 06 Sep 2021 23:59:42 +0200

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" &&