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

[PATCH] mergetools: add config option to disable auto-merge

From
Michael Rappazzo <rappazzo@gmail.com>
Date
Jun 16, 2015, 21:35 UTC
Message-ID
<1434490514-36204-2-git-send-email-rappazzo@gmail.com>
In-Reply-To
<1434490514-36204-1-git-send-email-rappazzo@gmail.com>

For some mergetools, the current invocation of git mergetool will include an auto-merge flag. By default the flag is included, however if the git config option 'merge.automerge' is set to 'false', then that flag will now be omitted.

Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>
---
 Documentation/config.txt        |  6 ++++++
 Documentation/git-mergetool.txt | 19 +++++++++++++------
 mergetools/araxis               |  4 +++-
 mergetools/diffmerge            |  4 +++-
 mergetools/kdiff3               |  4 +++-
 5 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 43bb53c..658d8f7 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1864,6 +1864,12 @@ mergetool.meld.hasOutput::
 	to `true` tells Git to unconditionally use the `--output` option,
 	and `false` avoids using `--output`.
 
+mergetool.automerge::
+	When invoking a custom merge tool which includes an auto-merge
+	option, Git will include that option by default.  If this variable
+	is set to `false` then the auto-merge option is not used when 
+	invoking the custom merge tool.
+
 mergetool.keepBackup::
 	After performing a merge, the original file with conflict markers
 	can be saved as a file with a `.orig` extension.  If this variable
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index e846c2e..3461d3a 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -79,16 +79,23 @@ success of the resolution after the custom tool has exited.
 	Prompt before each invocation of the merge resolution program
 	to give the user a chance to skip the path.
 
-TEMPORARY FILES
----------------
-`git mergetool` creates `*.orig` backup files while resolving merges.
-These are safe to remove once a file has been merged and its
-`git mergetool` session has completed.
-
+CONFIGURATION OPTIONS
+---------------------
+mergetool.keepBackup::
+	`git mergetool` creates `*.orig` backup files while resolving merges.
+	These are safe to remove once a file has been merged and its
+	`git mergetool` session has completed.
++
 Setting the `mergetool.keepBackup` configuration variable to `false`
 causes `git mergetool` to automatically remove the backup as files
 are successfully merged.
 
+mergetool.automerge::
+	For some mergetools, the current invocation of git mergetool will
+	include an auto-merge flag.  By default the flag is included, however if
+	the git config option `merge.automerge` is set to `false`, then that
+	flag will be omitted.
+
 GIT
 ---
 Part of the linkgit:git[1] suite
diff --git a/mergetools/araxis b/mergetools/araxis
index 64f97c5..00e63da 100644
--- a/mergetools/araxis
+++ b/mergetools/araxis
@@ -6,7 +6,9 @@ merge_cmd () {
 	touch "$BACKUP"
 	if $base_present
 	then
-		"$merge_tool_path" -wait -merge -3 -a1 \
+		automerge="-merge"
+		test "$(git config --get --bool mergetool.automerge)" = false && automerge=''
+		"$merge_tool_path" -wait ${automerge} -3 -a1 \
 			"$BASE" "$LOCAL" "$REMOTE" "$MERGED" >/dev/null 2>&1
 	else
 		"$merge_tool_path" -wait -2 \
diff --git a/mergetools/diffmerge b/mergetools/diffmerge
index f138cb4..287489b 100644
--- a/mergetools/diffmerge
+++ b/mergetools/diffmerge
@@ -5,7 +5,9 @@ diff_cmd () {
 merge_cmd () {
 	if $base_present
 	then
-		"$merge_tool_path" --merge --result="$MERGED" \
+		automerge="--merge"
+		test "$(git config --get --bool mergetool.automerge)" = false && automerge=''
+		"$merge_tool_path" ${automerge} --result="$MERGED" \
 			"$LOCAL" "$BASE" "$REMOTE"
 	else
 		"$merge_tool_path" --merge \
diff --git a/mergetools/kdiff3 b/mergetools/kdiff3
index 793d129..8e1d063 100644
--- a/mergetools/kdiff3
+++ b/mergetools/kdiff3
@@ -7,7 +7,9 @@ diff_cmd () {
 merge_cmd () {
 	if $base_present
 	then
-		"$merge_tool_path" --auto \
+		automerge="--auto"
+		test "$(git config --get --bool mergetool.automerge)" = false && automerge=''
+		"$merge_tool_path" ${automerge} \
 			--L1 "$MERGED (Base)" \
 			--L2 "$MERGED (Local)" \
 			--L3 "$MERGED (Remote)" \
-- 
2.4.2
Previous: Michael RappazzoNext: Junio C Hamano
Message 2 of 6 in “mergetools: add config option to disable auto-merge”
  1. mergetools: add config option to disable auto-mergeMichael Rappazzo, Jun 16, 2015
  2. mergetools: add config option to disable auto-mergeMichael Rappazzo, Jun 16, 2015
  3. Junio C HamanoJun 17, 2015
  4. Mike RappazzoJun 18, 2015
  5. David AguilarJun 18, 2015
  6. Mike RappazzoJun 18, 2015

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.