mergetools/p4merge: Handle "/dev/null"
authorDavid Aguilar <davvid@gmail.com>
Thu, 11 Oct 2012 03:22:36 +0000 (20:22 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 11 Oct 2012 18:50:00 +0000 (11:50 -0700)
p4merge does not properly handle the case where "/dev/null"
is passed as a filename.

Work it around by creating a temporary file for this purpose.

Reported-by: Jeremy Morton <admin@game-point.net>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 Needs to be amended with Tested-by when a report comes...

mergetools/p4merge

index 1a45c1b0c5128335fc340e7d6409b4e772419a07..295361a8aa7d075bbb9fdb8173858e37f9a43211 100644 (file)
@@ -1,5 +1,30 @@
 diff_cmd () {
+       # p4merge does not like /dev/null
+       rm_local=
+       rm_remote=
+       if test "/dev/null" = "$LOCAL"
+       then
+               LOCAL="./p4merge-dev-null.LOCAL.$$"
+               >"$LOCAL"
+               rm_local=true
+       fi
+       if test "/dev/null" = "$REMOTE"
+       then
+               REMOTE="./p4merge-dev-null.REMOTE.$$"
+               >"$REMOTE"
+               rm_remote=true
+       fi
+
        "$merge_tool_path" "$LOCAL" "$REMOTE"
+
+       if test -n "$rm_local"
+       then
+               rm -f "$LOCAL"
+       fi
+       if test -n "$rm_remote"
+       then
+               rm -f "$REMOTE"
+       fi
 }
 
 merge_cmd () {