{"thread":{"id":"32463","subject":"[PATCH v3] mergetools/p4merge: Honor $TMPDIR for the /dev/null placeholder","startedAt":"2012-12-27T00:45:29Z","lastAt":"2012-12-27T00:45:29Z","messageCount":1,"participants":["David Aguilar"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"205525","messageId":"1356569129-10024-1-git-send-email-davvid@gmail.com","threadId":"32463","inReplyTo":null,"subject":"[PATCH v3] mergetools/p4merge: Honor $TMPDIR for the /dev/null placeholder","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2012-12-27T00:45:29Z","receivedAt":"2012-12-27T00:45:29Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Use $TMPDIR when creating the /dev/null placeholder for p4merge.\nThis prevents users from finding a seemingly random untracked file\nin their worktree.\n\nThis is different than what mergetool does with $LOCAL and\n$REMOTE because those files exist to aid users when resolving\nmerges.  p4merge's /dev/null placeholder is not helpful in that\nsituation so it is sensible to keep it out of the worktree.\n\nReported-by: Jeremy Morton <admin@game-point.net>\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\nv3 revised the commit message to better justify the change.\nThis is a replacement for what's current in 'next'.\n\n mergetools/p4merge | 27 +++++++++++++--------------\n 1 file changed, 13 insertions(+), 14 deletions(-)\n\ndiff --git a/mergetools/p4merge b/mergetools/p4merge\nindex 295361a..52f7c8f 100644\n--- a/mergetools/p4merge\n+++ b/mergetools/p4merge\n@@ -1,29 +1,21 @@\n diff_cmd () {\n+\tempty_file=\n+\n \t# p4merge does not like /dev/null\n-\trm_local=\n-\trm_remote=\n \tif test \"/dev/null\" = \"$LOCAL\"\n \tthen\n-\t\tLOCAL=\"./p4merge-dev-null.LOCAL.$$\"\n-\t\t>\"$LOCAL\"\n-\t\trm_local=true\n+\t\tLOCAL=\"$(create_empty_file)\"\n \tfi\n \tif test \"/dev/null\" = \"$REMOTE\"\n \tthen\n-\t\tREMOTE=\"./p4merge-dev-null.REMOTE.$$\"\n-\t\t>\"$REMOTE\"\n-\t\trm_remote=true\n+\t\tREMOTE=\"$(create_empty_file)\"\n \tfi\n \n \t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\"\n \n-\tif test -n \"$rm_local\"\n-\tthen\n-\t\trm -f \"$LOCAL\"\n-\tfi\n-\tif test -n \"$rm_remote\"\n+\tif test -n \"$empty_file\"\n \tthen\n-\t\trm -f \"$REMOTE\"\n+\t\trm -f \"$empty_file\"\n \tfi\n }\n \n@@ -33,3 +25,10 @@ merge_cmd () {\n \t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n \tcheck_unchanged\n }\n+\n+create_empty_file () {\n+\tempty_file=\"${TMPDIR:-/tmp}/git-difftool-p4merge-empty-file.$$\"\n+\t>\"$empty_file\"\n+\n+\tprintf \"$empty_file\"\n+}\n-- \n1.8.1.rc3.11.g86c3e6e\n"}]}