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

[RFC PATCH 2/3] mergetools/kdiff3: allow opting-out of auto-merges

From
David Aguilar <davvid@gmail.com>
Date
May 9, 2013, 09:13 UTC
Message-ID
<1368090810-40596-2-git-send-email-davvid@gmail.com>
In-Reply-To
<1368090810-40596-1-git-send-email-davvid@gmail.com>

By default, "git mergetool" passes the `--auto` flag to `kdiff3` when merging a file. The `--auto` flag tells `kdiff3` to skip showing the GUI and automatically save the merged result when it is able to trivially resolve a merge.

Some users prefer to eyeball the merged result using mergetool and the use of `--auto` prevents them from doing so. Add a configuration variable to allow opting-out of the auto-merge feature.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
Marked "RFC" because I am kinda against adding more configuration
variables.  Someone ran into this and I did personally find the
behavior a bit surprising.  Alternatively, we *could* change the
default behavior, but I am not convinced that doing so is a good idea
either, hence this patch.  Other then the "kinda against",
it does make the behavior less surprising.
 Documentation/merge-config.txt |  9 +++++++++
 mergetools/kdiff3              | 20 ++++++++++++++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/Documentation/merge-config.txt b/Documentation/merge-config.txt
index d78d6d8..3bd5f21 100644
--- a/Documentation/merge-config.txt
+++ b/Documentation/merge-config.txt
@@ -59,6 +59,15 @@ merge.tool::
 
 include::mergetools-merge.txt[]
 
+mergetool.kdiff3.manualMerge::
+	Tell Git that not to use `kdiff3`'s auto-merge feature.
+	By default, "git mergetool" passes the `--auto` flag to `kdiff3`
+	when merging a file.  The `--auto` flag tells `kdiff3` to skip
+	showing the GUI and automatically save the merged result when it
+	is able to trivially resolve a merge.  The `--auto` flag will
+	not be used when this variable is set to `true`.  False by
+	default.
+
 merge.verbosity::
 	Controls the amount of output shown by the recursive merge
 	strategy.  Level 0 outputs nothing except a final error
diff --git a/mergetools/kdiff3 b/mergetools/kdiff3
index a30034f..d0acda9 100644
--- a/mergetools/kdiff3
+++ b/mergetools/kdiff3
@@ -1,3 +1,18 @@
+kdiff3_initialized=
+kdiff3_args=--auto
+
+kdiff3_init () {
+	if test -n "$kdiff3_initialized"
+	then
+		return
+	fi
+	if test "$(git config --bool mergetool.kdiff3.manualMerge)" = true
+	then
+		kdiff3_args=
+	fi
+	kdiff3_initialized=true
+}
+
 diff_cmd () {
 	"$merge_tool_path" \
 		--L1 "$MERGED (A)" --L2 "$MERGED (B)" \
@@ -5,16 +20,17 @@ diff_cmd () {
 }
 
 merge_cmd () {
+	kdiff3_init
 	if $base_present
 	then
-		"$merge_tool_path" --auto \
+		"$merge_tool_path" $kdiff3_args \
 			--L1 "$MERGED (Base)" \
 			--L2 "$MERGED (Local)" \
 			--L3 "$MERGED (Remote)" \
 			-o "$MERGED" "$BASE" "$LOCAL" "$REMOTE" \
 		>/dev/null 2>&1
 	else
-		"$merge_tool_path" --auto \
+		"$merge_tool_path" $kdiff3_args \
 			--L1 "$MERGED (Local)" \
 			--L2 "$MERGED (Remote)" \
 			-o "$MERGED" "$LOCAL" "$REMOTE" \
-- 
1.8.3.rc1.38.g0f1704c
Previous: David AguilarNext: David Aguilar
Message 2 of 11 in “mergetools/kdiff3: do not use --auto when diffing”
  1. 1/3 mergetools/kdiff3: do not use --auto when diffingDavid Aguilar, May 9, 2013
  2. 2/3 mergetools/kdiff3: allow opting-out of auto-mergesDavid Aguilar, May 9, 2013
  3. 3/3 Makefile: avoid deprecation warnings on OS X 10.8David Aguilar, May 9, 2013
  4. John KeepingMay 9, 2013
  5. David AguilarMay 9, 2013
  6. Junio C HamanoMay 9, 2013
  7. John KeepingMay 9, 2013
  8. Junio C HamanoMay 9, 2013
  9. David AguilarMay 9, 2013
  10. Charles BaileyMay 10, 2013
  11. David AguilarMay 10, 2013

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.