[PATCH v9 5/5] mergetool: add automerge_enabled tool-specific override function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The author or maintainer of a mergetool may optionally elect disable (or
enable) the `autoMerge` feature for that mergetool even if the user has
chosen differently using the `mergetool.autoMerge` and
`mergetool.<tool>.autoMerge` options.

To add a tool-specific override, edit the `mergetools/<tool>` shell
script for that tool and add an `automerge_enabled` function:

    automerge_enabled () {
        return 1
    }

Disabling may be desirable if the mergetool wants or needs access to the
original, unmodified 'LOCAL', 'REMOTE', and 'BASE' versions of the
conflicted file. For example:

- A tool may use a custom conflict resolution algorithm and prefer to
  ignore the results of Git's conflict resolution.
- A tool may want to visually compare/constrast the version of the file
  from before the merge (saved to 'LOCAL', 'REMOTE', and 'BASE') with
  Git's conflict resolution results (saved to 'MERGED').
- A student or researcher working on a new algorithm may want to
  directly compare the result of that algorithm with the result of Git's
  algorithm.

Helped-by: Junio C Hamano <gitster@xxxxxxxxx>
Signed-off-by: Seth House <seth@xxxxxxxxx>
---
 git-mergetool--lib.sh | 4 ++++
 git-mergetool.sh      | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index e059b3559e..567991abbc 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -164,6 +164,10 @@ setup_tool () {
 		return 1
 	}
 
+	automerge_enabled () {
+		return 0
+	}
+
 	translate_merge_tool_path () {
 		echo "$1"
 	}
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 929192d0f8..a44afd3822 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -336,7 +336,7 @@ merge_file () {
 
 	initialize_merge_tool "$merge_tool"
 
-	if test "$(
+	if automerge_enabled && test "$(
 		git config --get --bool "mergetool.$merge_tool.automerge" ||
 		git config --get --bool "mergetool.automerge" ||
 		echo true)" = true
-- 
2.29.2





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux