[PATCH] Added mergetool.kdiff3.doubledash config option

Previous thread: [PATCH] test-lib: Allow to be used by contrib projects by Santi Béjar on Thursday, June 12, 2008 - 12:13 pm. (2 messages)

Next thread: git-svn for vendor branches? by David A. Greene on Thursday, June 12, 2008 - 12:59 pm. (2 messages)
From: Patrick Higgins
Date: Thursday, June 12, 2008 - 12:55 pm

Qt-only builds of kdiff3 (no KDE) do not support a bare '--' on the command
line. It will fail silently and mysteriously.

Signed-off-by: Patrick Higgins <patrick.higgins@cexp.com>
---
 Documentation/config.txt |    6 ++++++
 git-mergetool.sh         |   11 +++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 5331b45..da40c2e 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -884,6 +884,12 @@ mergetool.<tool>.trustExitCode::
 	if the file has been updated, otherwise the user is prompted to
 	indicate the success of the merge.
 
+mergetool.kdiff3.doubledash::
+	A boolean to indicate whether or not your kdiff3 supports a '--'
+	on the command line to separate options from filenames. If you
+	built it without KDE, it probably doesn't have this support and
+	you	should set this to false.  Defaults to true.
+
 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/git-mergetool.sh b/git-mergetool.sh
index fcdec4a..57cbac0 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -181,12 +181,19 @@ merge_file () {
 
     case "$merge_tool" in
 	kdiff3)
+	    doubledash=`git config --bool mergetool.kdiff3.doubledash`
+	    if test "$doubledash" = "false"; then
+		double_dash=""
+	    else
+		double_dash="--"
+	    fi
+
 	    if base_present ; then
 		("$merge_tool_path" --auto --L1 "$MERGED (Base)" --L2 "$MERGED (Local)" --L3 "$MERGED (Remote)" \
-		    -o "$MERGED" -- "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
+		    -o "$MERGED" $double_dash "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
 	    else
 		("$merge_tool_path" --auto --L1 "$MERGED (Local)" --L2 "$MERGED (Remote)" \
-		    -o "$MERGED" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1)
+		    -o "$MERGED" $double_dash "$LOCAL" "$REMOTE" > /dev/null 2>&1)
 	    fi
 	    status=$?
 	    ;;
-- ...
From: Junio C Hamano
Date: Thursday, June 12, 2008 - 1:36 pm

Hmm, I am seeing this patch for the first time, I have not seen any
discussion history leading to the patch, and I have not been primarily

The above description makes it clear that there is an issue that needs to
be addressed.  I however am wondering if this can be either autodetected
at runtime, or if it can't, the user should be able to specify the option
when the user runs mergetool from the command line.  It would be necessary
to countermand whichever choice you configured in your config when you
need to run kdiff3 with KDE from one machine and the one without from
another machine, wouldn't it?
--

From: Patrick.Higgins
Date: Thursday, June 12, 2008 - 3:44 pm

I have found the following to be a way to distinguish the two versions based solely on exit status. The broken one exits with 255.

kdiff3 --auto -o /dev/null -- /dev/null /dev/null

I'll work up another patch that uses this. This check adds about 0.5s overhead. That seems a little high to me, but given that mergetool is interactive, I guess that could be acceptable.
--

From: Theodore Tso
Date: Friday, June 13, 2008 - 7:58 am

Hmm, do we have a policy about whether or not it is acceptable to
modify .gitconfig behind the user's back?  It would be nice if the
check would be done once and then the result gets cached.  So if not
in .gitconfig, maybe somewhere else.

      	       	    	     	      - Ted

--

From: Junio C Hamano
Date: Friday, June 13, 2008 - 11:17 pm

The reason I suggested either a cheap runtime check or command line
override was because you can be accessing the same repository from two
different machines, with different kdiff3.  If you check once and store
the result in .gitconfig or .git/config, it would not help the situation a
bit, would it?
--

From: Theodore Tso
Date: Friday, June 13, 2008 - 11:29 pm

Good point.  I'm not sure 0.5s is really fast enough to be considered
a "cheap runtime check", unfortunately.  At the very least it should
be cached across a single "git mergetool" invocation, though; maybe if
that were the case it would be acceptable.

          					- Ted

--

Previous thread: [PATCH] test-lib: Allow to be used by contrib projects by Santi Béjar on Thursday, June 12, 2008 - 12:13 pm. (2 messages)

Next thread: git-svn for vendor branches? by David A. Greene on Thursday, June 12, 2008 - 12:59 pm. (2 messages)