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

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

 



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@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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]