git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/2] mergetool: refactored kdiff3 -> KDIFF3
@ 2007-08-10 23:56 Steffen Prohaska
  2007-08-10 23:56 ` [PATCH] mergetool: added support for kdiff3 on windows Steffen Prohaska
  0 siblings, 1 reply; 2+ messages in thread
From: Steffen Prohaska @ 2007-08-10 23:56 UTC (permalink / raw
  To: git, torgil.svensson, Johannes.Schindelin, tytso; +Cc: Steffen Prohaska

Use shell variable KDIFF3 instead of kdiff3 to call
kdiff3. This will be used in detection of the absolute
absolute path.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 git-mergetool.sh |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)


This change is needed to be able to provide an absolute
path to kdiff3, which will be looked up in the Windows
Registry. See the following patch.


diff --git a/git-mergetool.sh b/git-mergetool.sh
index e6bbb6b..90a69b3 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -13,6 +13,8 @@ SUBDIRECTORY_OK=Yes
 . git-sh-setup
 require_work_tree
 
+KDIFF3=kdiff3
+
 # Returns true if the mode reflects a symlink
 is_symlink () {
     test "$1" = 120000
@@ -191,10 +193,10 @@ merge_file () {
     case "$merge_tool" in
 	kdiff3)
 	    if base_present ; then
-		(kdiff3 --auto --L1 "$path (Base)" -L2 "$path (Local)" --L3 "$path (Remote)" \
+		("$KDIFF3" --auto --L1 "$path (Base)" -L2 "$path (Local)" --L3 "$path (Remote)" \
 		    -o "$path" -- "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
 	    else
-		(kdiff3 --auto -L1 "$path (Local)" --L2 "$path (Remote)" \
+		("$KDIFF3" --auto -L1 "$path (Local)" --L2 "$path (Remote)" \
 		    -o "$path" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1)
 	    fi
 	    status=$?
-- 
1.5.3.rc4.744.g68381

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] mergetool: added support for kdiff3 on windows
  2007-08-10 23:56 [PATCH 1/2] mergetool: refactored kdiff3 -> KDIFF3 Steffen Prohaska
@ 2007-08-10 23:56 ` Steffen Prohaska
  0 siblings, 0 replies; 2+ messages in thread
From: Steffen Prohaska @ 2007-08-10 23:56 UTC (permalink / raw
  To: git, torgil.svensson, Johannes.Schindelin, tytso; +Cc: Steffen Prohaska

kdiff3's homepage is http://kdiff3.sourceforge.net/.

kdiff3 is automatically added to the available
mergetools if its path is found in the Windows
Registry. Be sure to set

    git config core.autocrlf true

kdiff3 seems to follow Windows crlf convention.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 git-mergetool.sh |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)


This patch was developed against msysgit, and is add
functionality specific to Windows. It should also apply
against git.git's master and shouldn't do any harm
to the handling of mergetools on platforms other than
Windows

It was tested on a Windows with german localization. I'd
be interested if the lookup of kdiff3 works on other
localizations, too.

Handling mergetools that needs an absolute path is a bit
hacky. merge_tool is mostly used as an alias but also as
the name of an executable. A level of indirection would
be nice for handling absolute paths.

kdiff3 on Windows doesn't accept '--' on it's commandline.
Is '--' really needed on other platforms? I replaced it by
the variable KDIFF3SEPARATOR.

	Steffen


diff --git a/git-mergetool.sh b/git-mergetool.sh
index 90a69b3..9f64e7c 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -14,6 +14,7 @@ SUBDIRECTORY_OK=Yes
 require_work_tree
 
 KDIFF3=kdiff3
+KDIFF3SEPARATOR=--
 
 # Returns true if the mode reflects a symlink
 is_symlink () {
@@ -194,10 +195,10 @@ merge_file () {
 	kdiff3)
 	    if base_present ; then
 		("$KDIFF3" --auto --L1 "$path (Base)" -L2 "$path (Local)" --L3 "$path (Remote)" \
-		    -o "$path" -- "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
+		    -o "$path" $KDIFF3SEPERATOR "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
 	    else
 		("$KDIFF3" --auto -L1 "$path (Local)" --L2 "$path (Remote)" \
-		    -o "$path" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1)
+		    -o "$path" $KDIFF3SEPERATOR "$LOCAL" "$REMOTE" > /dev/null 2>&1)
 	    fi
 	    status=$?
 	    remove_backup
@@ -321,6 +322,11 @@ if test -z "$merge_tool" ; then
             merge_tool_candidates="kdiff3 $merge_tool_candidates"
         fi
     fi
+    regentry="$(REG QUERY 'HKEY_LOCAL_MACHINE\SOFTWARE\KDiff3\diff-ext' 2>/dev/null)" && {
+        KDIFF3=$(echo "$regentry" | grep diffcommand | cut -f 3)
+        KDIFF3SEPARATOR=
+        merge_tool_candidates="$merge_tool_candidates kdiff3"
+    } 
     if echo "${VISUAL:-$EDITOR}" | grep 'emacs' > /dev/null 2>&1; then
         merge_tool_candidates="$merge_tool_candidates emerge"
     fi
@@ -332,10 +338,12 @@ if test -z "$merge_tool" ; then
     for i in $merge_tool_candidates; do
         if test $i = emerge ; then
             cmd=emacs
+        elif test $i = kdiff3 ; then
+            cmd="$KDIFF3"
         else
             cmd=$i
         fi
-        if type $cmd > /dev/null 2>&1; then
+        if type "$cmd" > /dev/null 2>&1; then
             merge_tool=$i
             break
         fi
@@ -347,7 +355,13 @@ if test -z "$merge_tool" ; then
 fi
 
 case "$merge_tool" in
-    kdiff3|tkdiff|meld|xxdiff|vimdiff|gvimdiff|opendiff)
+    kdiff3)
+	if ! type "$KDIFF3" > /dev/null 2>&1; then
+	    echo "The merge tool $merge_tool is not available"
+	    exit 1
+	fi
+	;;
+    tkdiff|meld|xxdiff|vimdiff|gvimdiff|opendiff)
 	if ! type "$merge_tool" > /dev/null 2>&1; then
 	    echo "The merge tool $merge_tool is not available"
 	    exit 1
-- 
1.5.3.rc4.744.g68381

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-10 23:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-10 23:56 [PATCH 1/2] mergetool: refactored kdiff3 -> KDIFF3 Steffen Prohaska
2007-08-10 23:56 ` [PATCH] mergetool: added support for kdiff3 on windows Steffen Prohaska

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).