Skip to contentSkip to conversation

Added mergetool.kdiff3.doubledash config option

PATCH In review Patrick Higgins 3 participants 6 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Added mergetool.kdiff3.doubledash config option

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

---
 Documentation/config.txt |    6 ++++++
 git-mergetool.sh         |   11 +++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
Documentation/config.txt +6 -0
index 5331b45..da40c2e 100644
@@ -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
git-mergetool.sh +9 -2
index fcdec4a..57cbac0 100755
@@ -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=$?
 	    ;;
Signature · 1 line
1.5.6.rc2
#1 lore raw
Quoted 4 lines · Patrick Higgins

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

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

Documentation/config.txt mergetool.<tool>.trustExitCode:: · line 891

Quoted 5 lines
Documentation/config.txt +5 -0
+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?

#2 lore raw

From: Junio C Hamano [mailto:[email protected]]

Quoted 11 lines

Documentation/config.txt mergetool.<tool>.trustExitCode:: · line 891

Quoted 5 lines · Patrick Higgins
Documentation/config.txt +5 -0
+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

Quoted 8 lines

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.

#3 lore raw
Quoted 8 lines · On Thu, Jun 12, 2008 at 04:44:03PM -0600, [email protected] 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

#4 lore raw
Quoted 6 lines · Theodore Tso
Quoted 5 lines · On Thu, Jun 12, 2008 at 04:44:03PM -0600, [email protected] 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

Quoted 8 lines
Quoted 3 lines

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?

#5 lore raw
Quoted 5 lines · Junio C Hamano

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