# [PATCH] Added mergetool.kdiff3.doubledash config option

6 messages from 2008-06-12 to 2008-06-14. Participants: Patrick Higgins, Junio C Hamano, patrick.higgins@cexp.com, Theodore Tso.
Thread: https://gitlist.dev/t/13916

## Patrick Higgins, 2008-06-12 19:55

Subject: [PATCH] Added mergetool.kdiff3.doubledash config option
Message-ID: <1213300505-3867-1-git-send-email-patrick.higgins@cexp.com>
URL: https://gitlist.dev/e/1213300505-3867-1-git-send-email-patrick.higgins%40cexp.com

```
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=$?
 	    ;;
-- 
1.5.6.rc2

```

## Junio C Hamano, 2008-06-12 20:36

Subject: Re: [PATCH] Added mergetool.kdiff3.doubledash config option
Message-ID: <7vve0ez8z3.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vve0ez8z3.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <1213300505-3867-1-git-send-email-patrick.higgins@cexp.com>

```
Patrick Higgins <patrick.higgins@cexp.com> writes:

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

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
involved in mergetool.  I'll Cc Ted to see what he thinks...

> +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.

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?

```

## patrick.higgins@cexp.com, 2008-06-12 22:44

Subject: RE: [PATCH] Added mergetool.kdiff3.doubledash config option
Message-ID: <911589C97062424796D53B625CEC0025E46159@USCOBRMFA-SE-70.northamerica.cexp.com>
URL: https://gitlist.dev/e/911589C97062424796D53B625CEC0025E46159%40USCOBRMFA-SE-70.northamerica.cexp.com
In-Reply-To: <7vve0ez8z3.fsf@gitster.siamese.dyndns.org>

```
From: Junio C Hamano [mailto:gitster@pobox.com]

> Patrick Higgins <patrick.higgins@cexp.com> writes:
> 
> > +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.
> 
> 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?

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.

```

## Theodore Tso, 2008-06-13 14:58

Subject: Re: [PATCH] Added mergetool.kdiff3.doubledash config option
Message-ID: <20080613145803.GE24675@mit.edu>
URL: https://gitlist.dev/e/20080613145803.GE24675%40mit.edu
In-Reply-To: <911589C97062424796D53B625CEC0025E46159@USCOBRMFA-SE-70.northamerica.cexp.com>

```
On Thu, Jun 12, 2008 at 04:44:03PM -0600, Patrick.Higgins@cexp.com wrote:
> 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.

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

```

## Junio C Hamano, 2008-06-14 06:17

Subject: Re: [PATCH] Added mergetool.kdiff3.doubledash config option
Message-ID: <7vhcbwilps.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vhcbwilps.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20080613145803.GE24675@mit.edu>

```
Theodore Tso <tytso@mit.edu> writes:

> On Thu, Jun 12, 2008 at 04:44:03PM -0600, Patrick.Higgins@cexp.com wrote:
>> 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.
>
> 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.

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?

```

## Theodore Tso, 2008-06-14 06:29

Subject: Re: [PATCH] Added mergetool.kdiff3.doubledash config option
Message-ID: <20080614062904.GB12260@mit.edu>
URL: https://gitlist.dev/e/20080614062904.GB12260%40mit.edu
In-Reply-To: <7vhcbwilps.fsf@gitster.siamese.dyndns.org>

```
On Fri, Jun 13, 2008 at 11:17:51PM -0700, Junio C Hamano wrote:
> 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?

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

```
