Skip to contentSkip to conversation

mergetools: add support for DeltaWalker

PATCH Superseded Tim Henigan 3 participants 8 messages Jun 15, 2016

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mergetools: add support for DeltaWalker

Thanks to bc7a96a8965d, it is possible to integrate new external diff/merge tools by adding a simple shell script at mergetools/$tool.

This commit adds DeltaWalker support.

---

Changes in v2:
- reworded the commit message
- moved >/dev/null redirect to after the final fi statement
- removed the 'status=$?' line at the end of merge_cmd()

Tested with DeltaWalker v1.9.8 on Ubuntu 11.10 and msysgit on Win7.

 mergetools/DeltaWalker |   12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 mergetools/DeltaWalker
mergetools/DeltaWalker new file +12 -0
new file mode 100644
index 0000000..b9e6618
@@ -0,0 +1,12 @@
+diff_cmd () {
+	"$merge_tool_path" "$LOCAL" "$REMOTE" >/dev/null 2>&1
+}
+
+merge_cmd () {
+	if $base_present
+	then
+		"$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" -merged="$PWD/$MERGED"
+	else
+		"$merge_tool_path" "$LOCAL" "$REMOTE" -merged="$PWD/$MERGED"
+	fi >/dev/null 2>&1
+}
Signature · 1 line
1.7.9.2.315.g25a78
#1 lore raw
Quoted 1 line · Tim Henigan
 mergetools/DeltaWalker |   12 ++++++++++++

How does an end user choose to use this backend? Perhaps like this?

    $ git mergetool --tool=DeltaWalker

All the other files in mergetools/ are in lower case, and I _strongly_ prefer to have this new file also be in lower case.

Such a change may mean you may have to override translate_merge_tool_path in this file, like some other backends seem to do.

Quoted 21 lines
 1 file changed, 12 insertions(+)
 create mode 100644 mergetools/DeltaWalker
mergetools/DeltaWalker new file +12 -0
new file mode 100644
index 0000000..b9e6618
@@ -0,0 +1,12 @@
+diff_cmd () {
+	"$merge_tool_path" "$LOCAL" "$REMOTE" >/dev/null 2>&1
+}
+
+merge_cmd () {
+	if $base_present
+	then
+		"$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" -merged="$PWD/$MERGED"
+	else
+		"$merge_tool_path" "$LOCAL" "$REMOTE" -merged="$PWD/$MERGED"
+	fi >/dev/null 2>&1
+}
#2 lore raw
Quoted 10 lines · Junio C Hamano
Quoted 1 line · Tim Henigan

 mergetools/DeltaWalker |   12 ++++++++++++

How does an end user choose to use this backend?  Perhaps like this?

   $ git mergetool --tool=DeltaWalker

All the other files in mergetools/ are in lower case, and I _strongly_ prefer to have this new file also be in lower case.

I agree.

Quoted 16 lines

Such a change may mean you may have to override translate_merge_tool_path in this file, like some other backends seem to do.

Quoted 13 lines
 1 file changed, 12 insertions(+)

 create mode 100644 mergetools/DeltaWalker

mergetools/DeltaWalker new file +4 -0
new file mode 100644
index 0000000..b9e6618
@@ -0,0 +1,12 @@
+diff_cmd () {
+     "$merge_tool_path" "$LOCAL" "$REMOTE" >/dev/null 2>&1
+}
+
Quoted 8 lines

mergetools/DeltaWalker line 12

Quoted 8 lines
mergetools/DeltaWalker new file +8 -0
+merge_cmd () {
+     if $base_present
+     then
+             "$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" -merged="$PWD/$MERGED"
+     else
+             "$merge_tool_path" "$LOCAL" "$REMOTE" -merged="$PWD/$MERGED"
+     fi >/dev/null 2>&1
+}

Is the $PWD/ prefix strictly needed? The rest of the mergetools use $MERGED as-is. Does it work without it?

Signature · 1 line
David
#3 lore raw
Quoted 11 lines · David Aguilar
Quoted 8 lines

mergetools/DeltaWalker line 12

Quoted 8 lines
mergetools/DeltaWalker new file +8 -0
+merge_cmd () {
+     if $base_present
+     then
+             "$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" -merged="$PWD/$MERGED"
+     else
+             "$merge_tool_path" "$LOCAL" "$REMOTE" -merged="$PWD/$MERGED"
+     fi >/dev/null 2>&1
+}

Is the $PWD/ prefix strictly needed? The rest of the mergetools use $MERGED as-is. Does it work without it?

Hrm, I didn't notice it but they do look fishy. Thanks for good eyes.

Tim?

#4 lore raw
Quoted 14 lines · Junio C Hamano
Quoted 11 lines · David Aguilar
Quoted 8 lines

mergetools/DeltaWalker line 12

Quoted 8 lines
mergetools/DeltaWalker new file +8 -0
+merge_cmd () {
+     if $base_present
+     then
+             "$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" -merged="$PWD/$MERGED"
+     else
+             "$merge_tool_path" "$LOCAL" "$REMOTE" -merged="$PWD/$MERGED"
+     fi >/dev/null 2>&1
+}

Is the $PWD/ prefix strictly needed?  The rest of the mergetools use $MERGED as-is.  Does it work without it?

Quoted 3 lines

Hrm, I didn't notice it but they do look fishy.  Thanks for good eyes.

Tim?

I ran a quick test using msysgit v1.7.9 on Win7 64-bit and found that it fails without '$PWD'.

When '$PWD/' is removed from the '-merged' option, it results in a Java JRE crash and the conflict resolutions entered by the user are not written to the file.

The JRE exception is 'EXCEPTION_ACCESS_VIOLATION (0xc0000005)'. I posted the full text of the exception to a public location, in case anyone is interested [1].

The format of the '-merged' option was copied directly from the DeltaWalker manual. There was no explanation why '$PWD' is needed.

[1]: https://gist.github.com/1970590

#5 lore raw
Quoted 26 lines · Tim Henigan
Quoted 14 lines · Junio C Hamano
Quoted 11 lines · David Aguilar
Quoted 8 lines

mergetools/DeltaWalker line 12

Quoted 8 lines
mergetools/DeltaWalker new file +8 -0
+merge_cmd () {
+     if $base_present
+     then
+             "$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" -merged="$PWD/$MERGED"
+     else
+             "$merge_tool_path" "$LOCAL" "$REMOTE" -merged="$PWD/$MERGED"
+     fi >/dev/null 2>&1
+}

Is the $PWD/ prefix strictly needed?  The rest of the mergetools use $MERGED as-is.  Does it work without it?

Quoted 3 lines

Hrm, I didn't notice it but they do look fishy.  Thanks for good eyes.

Tim?

I ran a quick test using msysgit v1.7.9 on Win7 64-bit and found that it fails without '$PWD'.

When '$PWD/' is removed from the '-merged' option, it results in a Java JRE crash and the conflict resolutions entered by the user are not written to the file.

Quoted 8 lines

The JRE exception is 'EXCEPTION_ACCESS_VIOLATION (0xc0000005)'.  I posted the full text of the exception to a public location, in case anyone is interested [1].

The format of the '-merged' option was copied directly from the DeltaWalker manual.  There was no explanation why '$PWD' is needed.

[1]: https://gist.github.com/1970590

Thanks, that makes a lot of sense. It looks like they have a bug. Do they know about it?

My naive guess is that they are using some inotify-like thing and subscribing to a directory (per the stack trace). Since dirname("relative") is "" they crash.

So this bug probably wouldn't be present when merging a file in a sub-directory, or ../ relative path. Is this the case?

Can you mention this in a comment so that someone doesn't copy/paste it into another tool in the future?

If they fix it then we may want to consider only supporting the newer version and remove the $PWD. Does the OS X version have this bug too?

I didn't notice any other production shell scripts in git using $PWD. There is one use of pwd in git-stash.sh and it's used in a few tests, as is $PWD, but $(pwd) is the most prevalent overall. I don't know the reason $PWD is avoided in the git shell scripts (though portability is often the reason).

Deltawalker is not currently available on any of the platforms where this would be a concern, but we may still want to use $(pwd) for consistency with the other commands. Does that work instead?

Signature · 1 line
David
#6 lore raw
Quoted 2 lines · David Aguilar

Can you mention this in a comment so that someone doesn't copy/paste it into another tool in the future?

Ok, I think the result should look like this, but could you fill in the details in the below?

-- >8 --
From: Tim Henigan <[email protected]>
Date: Sat, 3 Mar 2012 11:56:34 -0500
Subject: [PATCH] mergetools: add a plug-in to support DeltaWalker

DeltaWalker is a non-free tool that is popular among xxxxxxx users. Add a plug-in to support it from difftool and mergetool.

Note that $(pwd)/ in front of $MERGED shouldn't be necessary, but without it, DeltaWalker crashes with an JRE exception.

Helped-by David Aguilar
---
 mergetools/deltawalker |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 mergetools/deltawalker
mergetools/deltawalker new file +19 -0
new file mode 100644
index 0000000..f8631f2
@@ -0,0 +1,19 @@
+diff_cmd () {
+	"$merge_tool_path" "$LOCAL" "$REMOTE" >/dev/null 2>&1
+}
+
+merge_cmd () {
+	# The $(pwd)/ in front of $MERGED should not be necessary but
+	# DeltaWalker (at least ver XXX) crashes with a JRE exception
+	# and the $(pwd)/ seems to work around it.
+	if $base_present
+	then
+		"$merge_tool_path" "$LOCAL" "$REMOTE" "$BASE" -merged="$(pwd)/$MERGED"
+	else
+		"$merge_tool_path" "$LOCAL" "$REMOTE" -merged="$(pwd)/$MERGED"
+	fi >/dev/null 2>&1
+}
+
+translate_merge_tool_path() {
+	echo DeltaWalker
+}
Signature · 1 line
1.7.9.2.390.g8f827
#7 lore raw
In reply to David Aguilar
Quoted 2 lines · David Aguilar

Thanks, that makes a lot of sense.  It looks like they have a bug.  Do they know about it?

I have not reported the problem to them yet.

Quoted 2 lines

Can you mention this in a comment so that someone doesn't copy/paste it into another tool in the future?

Will add a comment in v4.

Quoted 2 lines

If they fix it then we may want to consider only supporting the newer version and remove the $PWD.  Does the OS X version have this bug too?

I don't have a OS X environment to test on. However, I did just find out that the bug is not present on Ubuntu 11.10. On Ubuntu, it works with or without $(pwd)/. The two platforms have different Java JDKs, so that could be a factor.

Quoted 9 lines

I didn't notice any other production shell scripts in git using $PWD. There is one use of pwd in git-stash.sh and it's used in a few tests, as is $PWD, but $(pwd) is the most prevalent overall.  I don't know the reason $PWD is avoided in the git shell scripts (though portability is often the reason).

Deltawalker is not currently available on any of the platforms where this would be a concern, but we may still want to use $(pwd) for consistency with the other commands.  Does that work instead?

$(pwd) works...I will make this change in v4.