threads / patch / 13916

patchAdded mergetool.kdiff3.doubledash config option

Subject: [PATCH] Added mergetool.kdiff3.doubledash config option

## tl;dr

6 messages between Jun 12, 2008 and Jun 14, 2008. Diffs are folded; open one to read it.

replies: 5people: 3as markdown or json

Patrick Higgins· Jun 12, 2008, 19:55 UTC · lore

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(-)
Show changes to 2 files +15 −2

Documentation/config.txt, git-mergetool.sh

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· Jun 12, 2008, 20:36 UTC · re: Patrick Higgins · lore

Re: [PATCH] Added mergetool.kdiff3.doubledash config option

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

Show 5 quoted lines
> +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· Jun 12, 2008, 22:44 UTC · re: Junio C Hamano · lore

RE: [PATCH] Added mergetool.kdiff3.doubledash config option

From: Junio C Hamano [mailto:gitster@pobox.com]
Show 19 quoted lines
> 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· Jun 13, 2008, 14:58 UTC · re: patrick.higgins@cexp.com · lore

Re: [PATCH] Added mergetool.kdiff3.doubledash config option

On Thu, Jun 12, 2008 at 04:44:03PM -0600, Patrick.Higgins@cexp.com wrote:
Show 8 quoted lines
> 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· Jun 14, 2008, 06:17 UTC · re: Theodore Tso · lore

Re: [PATCH] Added mergetool.kdiff3.doubledash config option

Theodore Tso <tytso@mit.edu> writes:
Show 14 quoted lines
> 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· Jun 14, 2008, 06:29 UTC · re: Junio C Hamano · lore

Re: [PATCH] Added mergetool.kdiff3.doubledash config option

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

← back to recent threads