Skip to contentSkip to conversation

mergetool

PATCH In review Steffen Prohaska 2 participants 10 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#1 lore raw

PATCH v3 1/2 mergetool: use path to mergetool in config var mergetool.<tool>.path

This commit adds a mechanism to provide absolute paths to the external programs called by 'git mergetool'. A path can be specified in the configuation variable mergetool.<tool>.path. The configuration variable is similar to how we name branches and remotes. It is extensible if we need to specify more details about a tool.

The mechanism is especially useful on Windows, where external programs are unlikely to be in PATH.

---
 Documentation/git-mergetool.txt |    6 ++
 git-mergetool.sh                |   97 +++++++++++++++++++++-----------------
 2 files changed, 60 insertions(+), 43 deletions(-)
Documentation/git-mergetool.txt +6 -0
index 6c32c6d..78b2f43 100644
@@ -31,6 +31,12 @@ If a merge resolution program is not specified, 'git mergetool'
 will use the configuration variable merge.tool.  If the
 configuration variable merge.tool is not set, 'git mergetool'
 will pick a suitable default.
++
+You can explicitly provide a full path to the tool by setting the
+configuration variable mergetool.<tool>.path. For example, you
+can configure the absolute path to kdiff3 by setting
+mergetool.kdiff3.path. Otherwise, 'git mergetool' assumes the tool
+is available in PATH.
 
 Author
 ------
git-mergetool.sh +54 -43

174 lines not on this page · raw message

Signature · 1 line
1.5.3.4.222.g2830
#2 lore raw

PATCH v3 2/2 mergetool: add support for ECMerge

Add support to mergetool for ECMerge available from
http://www.elliecomputing.com/Products/merge_overview.asp

---
 Documentation/git-mergetool.txt |    2 +-
 git-mergetool.sh                |   12 +++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
Documentation/git-mergetool.txt +1 -1
index 78b2f43..a26c260 100644
@@ -25,7 +25,7 @@ OPTIONS
 -t or --tool=<tool>::
 	Use the merge resolution program specified by <tool>.
 	Valid merge tools are:
-	kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, and opendiff
+	kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff
 +
 If a merge resolution program is not specified, 'git mergetool'
 will use the configuration variable merge.tool.  If the
git-mergetool.sh +11 -1
index 1e4583f..fdf4912 100755
@@ -250,6 +250,16 @@ merge_file () {
 	    check_unchanged
 	    save_backup
 	    ;;
+	ecmerge)
+	    touch "$BACKUP"
+	    if base_present; then
+		"$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --mode=merge3 --to="$path"
+	    else
+		"$merge_tool_path" "$LOCAL" "$REMOTE" --mode=merge2 --to="$path"
+	    fi
+	    check_unchanged
+	    save_backup
+	    ;;
 	emerge)
 	    if base_present ; then
 		"$merge_tool_path" -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$(basename "$path")"
@@ -299,7 +309,7 @@ done
 
 valid_tool() {
 	case "$1" in
-		kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff)
+		kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
 			;; # happy
 		*)
 			return 1
Signature · 1 line
1.5.3.4.222.g2830
#3 lore raw

Re: [PATCH 1/2 v3] mergetool: use path to mergetool in config var mergetool.<tool>.path

In reply to Steffen Prohaska
Quoted 2 lines · Steffen Prohaska

This commit adds a mechanism to provide absolute paths to the external programs called by 'git mergetool'. ...

...

Quoted 13 lines
git-mergetool.sh +9 -0
@@ -297,17 +297,38 @@ do
     shift
 done
 
+valid_tool() {
+	case "$1" in
+		kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff)
+			;; # happy
+		*)
+			return 1
+			;;
+	esac
+}

...

Quoted 1 line

+ test -n "$merge_tool" || valid_tool "$merge_tool" || {

Wouldn't an empty $merge_tool string be caught above in the valid_tool function where it falls through and returns 1? So isn't test -n here redundant?

Signature · 1 line
Shawn.
#4 lore raw

Re: [PATCH 1/2 v3] mergetool: use path to mergetool in config var mergetool.<tool>.path

Quoted 19 lines · Shawn O. Pearce
Quoted 2 lines · Steffen Prohaska

This commit adds a mechanism to provide absolute paths to the external programs called by 'git mergetool'. ...

...

Quoted 14 lines
git-mergetool.sh +9 -0
@@ -297,17 +297,38 @@ do
     shift
 done
 
+valid_tool() {
+	case "$1" in
+		kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff |  
 gvimdiff)
+			;; # happy
+		*)
+			return 1
+			;;
+	esac
+}

...

Quoted 5 lines
Quoted 1 line

+ test -n "$merge_tool" || valid_tool "$merge_tool" || {

Wouldn't an empty $merge_tool string be caught above in the valid_tool function where it falls through and returns 1? So isn't test -n here redundant?

Sharp eyes, thanks.

Correct is

test -z "$merge_tool" || valid_tool "$merge_tool" || {

No merge tool or a valid merge tool is allowed at this place. If the tool's already empty there's no need to tell the user that it will be reset to empty.

I'll send a v4 version.

Steffen

#5 lore raw

PATCH v4 1/2 mergetool: use path to mergetool in config var mergetool.<tool>.path

This commit adds a mechanism to provide absolute paths to the external programs called by 'git mergetool'. A path can be specified in the configuation variable mergetool.<tool>.path. The configuration variable is similar to how we name branches and remotes. It is extensible if we need to specify more details about a tool.

The mechanism is especially useful on Windows, where external programs are unlikely to be in PATH.

---
 Documentation/git-mergetool.txt |    6 ++
 git-mergetool.sh                |   97 +++++++++++++++++++++-----------------
 2 files changed, 60 insertions(+), 43 deletions(-)
Documentation/git-mergetool.txt +6 -0
index 6c32c6d..78b2f43 100644
@@ -31,6 +31,12 @@ If a merge resolution program is not specified, 'git mergetool'
 will use the configuration variable merge.tool.  If the
 configuration variable merge.tool is not set, 'git mergetool'
 will pick a suitable default.
++
+You can explicitly provide a full path to the tool by setting the
+configuration variable mergetool.<tool>.path. For example, you
+can configure the absolute path to kdiff3 by setting
+mergetool.kdiff3.path. Otherwise, 'git mergetool' assumes the tool
+is available in PATH.
 
 Author
 ------
git-mergetool.sh +54 -43

174 lines not on this page · raw message

Signature · 1 line
1.5.3.4.222.g2830
#6 lore raw

Re: [PATCH 1/2 v3] mergetool: use path to mergetool in config var mergetool.<tool>.path

In reply to Steffen Prohaska
Quoted 12 lines · Steffen Prohaska
Quoted 6 lines · Shawn O. Pearce

...

Quoted 1 line

+ test -n "$merge_tool" || valid_tool "$merge_tool" || {

Wouldn't an empty $merge_tool string be caught above in the valid_tool function where it falls through and returns 1? So isn't test -n here redundant?

Sharp eyes, thanks.

Correct is

Quoted 7 lines

test -z "$merge_tool" || valid_tool "$merge_tool" || {

No merge tool or a valid merge tool is allowed at this place. If the tool's already empty there's no need to tell the user that it will be reset to empty.

I'll send a v4 version.

Thanks but its a little late. I'm about to push maint/master/next/pu and this series is in next. While testing it I found another bug related to init_tool_merge_tool_path() not having $merge_tool initialized and thus causing it to never select a default tool if the user didn't have one configured.

Here's what I'm actually about to push out:

--8>--
From e3fa2c761fdc490494e8e0855bcee4d7e58ada6a Mon Sep 17 00:00:00 2001
From: Steffen Prohaska <[email protected]>
Date: Wed, 17 Oct 2007 19:16:11 +0200
Subject: [PATCH] mergetool: use path to mergetool in config var mergetool.<tool>.path

This commit adds a mechanism to provide absolute paths to the external programs called by 'git mergetool'. A path can be specified in the configuation variable mergetool.<tool>.path. The configuration variable is similar to how we name branches and remotes. It is extensible if we need to specify more details about a tool.

The mechanism is especially useful on Windows, where external programs are unlikely to be in PATH.

[sp: Fixed a few minor issues prior to applying]

---
 Documentation/git-mergetool.txt |    6 ++
 git-mergetool.sh                |   97 +++++++++++++++++++++-----------------
 2 files changed, 60 insertions(+), 43 deletions(-)
Documentation/git-mergetool.txt +6 -0
index 6c32c6d..78b2f43 100644
@@ -31,6 +31,12 @@ If a merge resolution program is not specified, 'git mergetool'
 will use the configuration variable merge.tool.  If the
 configuration variable merge.tool is not set, 'git mergetool'
 will pick a suitable default.
++
+You can explicitly provide a full path to the tool by setting the
+configuration variable mergetool.<tool>.path. For example, you
+can configure the absolute path to kdiff3 by setting
+mergetool.kdiff3.path. Otherwise, 'git mergetool' assumes the tool
+is available in PATH.
 
 Author
 ------
git-mergetool.sh +54 -43

174 lines not on this page · raw message

Signature · 5 lines
1.5.3.4.1231.gac645


-- 
Shawn.
#7 lore raw

Re: [PATCH 1/2 v3] mergetool: use path to mergetool in config var mergetool.<tool>.path

Quoted 15 lines · Shawn O. Pearce
Quoted 14 lines · Steffen Prohaska
Quoted 6 lines · Shawn O. Pearce

...

Quoted 1 line

+ test -n "$merge_tool" || valid_tool "$merge_tool" || {

Wouldn't an empty $merge_tool string be caught above in the valid_tool function where it falls through and returns 1? So isn't test -n here redundant?

Sharp eyes, thanks.

Correct is

test -z "$merge_tool" || valid_tool "$merge_tool" || {

Quoted 7 lines
Quoted 5 lines

No merge tool or a valid merge tool is allowed at this place. If the tool's already empty there's no need to tell the user that it will be reset to empty.

I'll send a v4 version.

Thanks but its a little late.

Sorry.

Quoted 5 lines

I'm about to push maint/master/next/pu
and this series is in next. While testing it I found another bug related to init_tool_merge_tool_path() not having $merge_tool initialized and thus causing it to never select a default tool if the user didn't have one configured.

I see. Thanks for fixing this.

Quoted 1 line

Here's what I'm actually about to push out:

One remark ...

[...]

git-mergetool.sh do · line 327

Quoted 9 lines

if test -z "$merge_tool"; then
merge_tool=git config merge.tool

(quoted diff) +0 -2
-    case "$merge_tool" in
-	kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff |  

gvimdiff | "")

git-mergetool.sh +1 -2
-	    ;; # happy
-	*)
+    if ! valid_tool "$merge_tool"; then

I think its ok to have an empty tool here ...

Quoted 3 lines

echo >&2 "git config option merge.tool set to unknown tool:
$merge_tool"
echo >&2 "Resetting to default..."

... So we should not print this message if the tool is empty.

But an empty tool is not valid. Therefore a check if "$merge_tool" is not empty should be added to the if.

Steffen

#8 lore raw

PATCH 1/1 mergetool: avoid misleading message "Resetting to default..."

If no mergetool is configured in the configuration variable merge.tool the resetting message should not be printed.

This is fixed. The message is only printed if a tool is configured but the entry in merge.tool is invalid.

---
 git-mergetool.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
git-mergetool.sh +1 -1
index 94511f9..a68b403 100755
@@ -334,7 +334,7 @@ init_merge_tool_path() {
 
 if test -z "$merge_tool"; then
     merge_tool=`git config merge.tool`
-    if ! valid_tool "$merge_tool"; then
+    if test -n "$merge_tool" && ! valid_tool "$merge_tool"; then
 	    echo >&2 "git config option merge.tool set to unknown tool: $merge_tool"
 	    echo >&2 "Resetting to default..."
 	    unset merge_tool
Signature · 1 line
1.5.3.4.222.g2830
#9 lore raw
In reply to Steffen Prohaska
Quoted 1 line · Steffen Prohaska

So here they are again.

[ half of the message is missing. First time I used compose ;) ]

I haven't found these two patches in Shawn's nor Lars' repo. I believe they would be pretty useful on Windows. They apply to spearce/master.

Steffen