Subject: Re: [PATCH v9 4/5] mergetool: break setup_tool out into separate initialization function

From: Seth House <[email-masked]>
Date: Tue, 29 Dec 2020 10:23:49 -0700

On Tue, Dec 29, 2020 at 09:50:44AM +0100, Johannes Sixt wrote:
> Would it be possible to move the call above the
> `mergetool_tmpdir_init` call, so that nothing has to be rewound?

Ah, I see. Good suggestion. Yes, moving that call higher works just
fine. E.g.:

diff --git a/git-mergetool.sh b/git-mergetool.sh
index a44afd3822..36c1920dd6 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -276,6 +276,8 @@ merge_file () {
 		ext=
 	esac
 
+	initialize_merge_tool "$merge_tool" || return
+
 	mergetool_tmpdir_init
 
 	if test "$MERGETOOL_TMPDIR" != "."
@@ -334,8 +336,6 @@ merge_file () {
 	checkout_staged_file 2 "$MERGED" "$LOCAL"
 	checkout_staged_file 3 "$MERGED" "$REMOTE"
 
-	initialize_merge_tool "$merge_tool"
-
 	if automerge_enabled && test "$(
 		git config --get --bool "mergetool.$merge_tool.automerge" ||
 		git config --get --bool "mergetool.automerge" ||

Thanks. I'll roll that change into a v10 patch series later today or
tomorrow to give a little more time for any other feedback.