From: Jeremy Morton <admin@game-point.net>
To: git@vger.kernel.org
Subject: Fixing the p4merge launch shell script
Date: Wed, 03 Oct 2012 00:38:35 +0100 [thread overview]
Message-ID: <506B7AFB.1070700@game-point.net> (raw)
Hi,
I've noticed that the p4merge shell script could do with some
improvement when it comes to merging. Because p4merge throws up an
error when one of the files it's given to diff is "/dev/null", git needs
to create a temporary empty file and pass that to p4merge when diffing a
file that has been created/deleted (eg. create file, git add ., git diff
--cached).
At the moment, the hack I'm using, which works, is to create a
c:/blank.txt file which is an empty file, and modify
"libexec/git-core/mergetools/p4merge" to start with this:
diff_cmd () {
if [ ! -f "$LOCAL" ]
then
LOCAL="C:/blank.txt"
fi
if [ ! -f "$REMOTE" ]
then
REMOTE="C:/blank.txt"
fi
"$merge_tool_path" "$LOCAL" "$REMOTE"
}
Obviously, this isn't good enough because c:/blank.txt probably won't
exist on the system. It would be nice for the temporary blank file to
have the same extension as the one that's been added, so we could diff
(say) c:/users/jez/Temp/abc123_newFile.foo
c:/development/bar/newfile.foo. However, I can't see a way to do this
purely from within the shell script (even `mktemp` doesn't exist on all
systems so that isn't good enough). I believe git needs to create this
temporary blank file itself, much like it creates a temporary file for
the previous version of a file that's been modified when it's being
diff'd. It then needs to expose the location of this temporary file as
a variable; say $LOCALBLANK. So, we would be able to modify the shell
script to this:
diff_cmd () {
if [ ! -f "$LOCAL" ]
then
LOCAL=$LOCALBLANK
fi
if [ ! -f "$REMOTE" ]
then
REMOTE=$REMOTEBLANK
fi
"$merge_tool_path" "$LOCAL" "$REMOTE"
}
Thoughts? Is there an easier way to do this?
--
Best regards,
Jeremy Morton (Jez)
next reply other threads:[~2012-10-03 0:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-02 23:38 Jeremy Morton [this message]
2012-10-03 0:44 ` Fixing the p4merge launch shell script Junio C Hamano
2012-10-03 8:34 ` Jeremy Morton
2012-10-04 6:59 ` David Aguilar
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=506B7AFB.1070700@game-point.net \
--to=admin@game-point.net \
--cc=git@vger.kernel.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.
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).