From: Jay Soffian <jaysoffian@gmail.com>
To: git@vger.kernel.org
Cc: Jay Soffian <jaysoffian@gmail.com>,
David Aguilar <davvid@gmail.com>,
"Shawn O . Pearce" <spearce@spearce.org>,
Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] mergetool--lib: add support for p4merge
Date: Wed, 28 Oct 2009 02:11:27 -0700 [thread overview]
Message-ID: <1256721087-72534-1-git-send-email-jaysoffian@gmail.com> (raw)
Add native support for p4merge as a diff / merge tool. There are two
oddities. First, launching p4merge on Mac OS X requires running a helper
shim (which in turn is looked for in a couple common locations, as it's
very unlikely to be in PATH). Second, p4merge seems to require its file
arguments be absolute paths.
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
As requested by an Android developer at GitTogether09.
Only tested on Mac OS X 10.6.1. Feedback from anyone running p4merge on other
OS's would be appreciated.
Documentation/git-difftool.txt | 2 +-
Documentation/git-mergetool.txt | 2 +-
git-mergetool--lib.sh | 44 ++++++++++++++++++++++++++++++++++++++-
3 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
index 96a6c51..8e9aed6 100644
--- a/Documentation/git-difftool.txt
+++ b/Documentation/git-difftool.txt
@@ -31,7 +31,7 @@ OPTIONS
Use the diff tool specified by <tool>.
Valid merge tools are:
kdiff3, kompare, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff,
- ecmerge, diffuse, opendiff and araxis.
+ ecmerge, diffuse, opendiff, p4merge and araxis.
+
If a diff tool is not specified, 'git-difftool'
will use the configuration variable `diff.tool`. If the
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index 68ed6c0..4a6f7f3 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -27,7 +27,7 @@ OPTIONS
Use the merge resolution program specified by <tool>.
Valid merge tools are:
kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge,
- diffuse, tortoisemerge, opendiff and araxis.
+ diffuse, tortoisemerge, opendiff, p4merge and araxis.
+
If a merge resolution program is not specified, 'git-mergetool'
will use the configuration variable `merge.tool`. If the
diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index bfb01f7..23b2816 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -7,6 +7,12 @@ merge_mode() {
test "$TOOL_MODE" = merge
}
+abspath() {
+ d=$(dirname "$1")
+ d=$(cd "$d" && pwd -P)
+ echo "$d/$(basename "$1")"
+}
+
translate_merge_tool_path () {
case "$1" in
vimdiff)
@@ -21,6 +27,19 @@ translate_merge_tool_path () {
araxis)
echo compare
;;
+ p4merge)
+ # Look for the Mac OS X P4Merge shim
+ for app_dir in "/Applications" "$HOME/Applications"
+ do
+ launchp4merge="$app_dir/p4merge.app/Contents/Resources/launchp4merge"
+ if type "$launchp4merge" > /dev/null 2>&1; then
+ echo "$launchp4merge"
+ return 0
+ fi
+ done
+ # Otherwise assume we're not on Mac OS X and just return p4merge
+ echo "$1"
+ ;;
*)
echo "$1"
;;
@@ -45,7 +64,7 @@ check_unchanged () {
valid_tool () {
case "$1" in
- kdiff3 | tkdiff | xxdiff | meld | opendiff | \
+ kdiff3 | tkdiff | xxdiff | meld | opendiff | p4merge | \
emerge | vimdiff | gvimdiff | ecmerge | diffuse | araxis)
;; # happy
tortoisemerge)
@@ -284,6 +303,29 @@ run_merge_tool () {
>/dev/null 2>&1
fi
;;
+ p4merge)
+ # At least on Mac OS X p4merge wants absolute paths
+ ABS_LOCAL=$(abspath "$LOCAL")
+ ABS_REMOTE=$(abspath "$REMOTE")
+ if merge_mode; then
+ ABS_MERGED=$(abspath "$MERGED")
+ touch "$BACKUP"
+ if $base_present; then
+ ABS_BASE=$(abspath "$BASE")
+ "$merge_tool_path" \
+ "$ABS_BASE" "$ABS_LOCAL" "$ABS_REMOTE" "$ABS_MERGED" \
+ >/dev/null 2>&1
+ else
+ "$merge_tool_path" \
+ "/dev/null" "$ABS_LOCAL" "$ABS_REMOTE" "$ABS_MERGED" \
+ >/dev/null 2>&1
+ fi
+ check_unchanged
+ else
+ "$merge_tool_path" "$ABS_LOCAL" "$ABS_REMOTE" \
+ >/dev/null 2>&1
+ fi
+ ;;
*)
merge_tool_cmd="$(get_merge_tool_cmd "$1")"
if test -z "$merge_tool_cmd"; then
--
1.6.5.2.74.g610f9.dirty
next reply other threads:[~2009-10-28 9:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-28 9:11 Jay Soffian [this message]
2009-10-28 9:21 ` [PATCH] mergetool--lib: add support for p4merge Jay Soffian
2009-10-28 9:27 ` David Aguilar
2009-10-28 9:36 ` David Aguilar
2009-10-28 9:52 ` Jay Soffian
2009-10-28 10:02 ` Jay Soffian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1256721087-72534-1-git-send-email-jaysoffian@gmail.com \
--to=jaysoffian@gmail.com \
--cc=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.