Skip to content

Commit 894610a

Browse files
committed
Merge branch 'da/p4merge-mktemp'
Create an empty file in $TMPDIR instead of using an empty file in the local directory. * da/p4merge-mktemp: mergetools/p4merge: Honor $TMPDIR for the /dev/null placeholder
2 parents b81827b + 950b568 commit 894610a

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

mergetools/p4merge

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
diff_cmd () {
2+
empty_file=
3+
24
# p4merge does not like /dev/null
3-
rm_local=
4-
rm_remote=
55
if test "/dev/null" = "$LOCAL"
66
then
7-
LOCAL="./p4merge-dev-null.LOCAL.$$"
8-
>"$LOCAL"
9-
rm_local=true
7+
LOCAL="$(create_empty_file)"
108
fi
119
if test "/dev/null" = "$REMOTE"
1210
then
13-
REMOTE="./p4merge-dev-null.REMOTE.$$"
14-
>"$REMOTE"
15-
rm_remote=true
11+
REMOTE="$(create_empty_file)"
1612
fi
1713

1814
"$merge_tool_path" "$LOCAL" "$REMOTE"
1915

20-
if test -n "$rm_local"
21-
then
22-
rm -f "$LOCAL"
23-
fi
24-
if test -n "$rm_remote"
16+
if test -n "$empty_file"
2517
then
26-
rm -f "$REMOTE"
18+
rm -f "$empty_file"
2719
fi
2820
}
2921

@@ -33,3 +25,10 @@ merge_cmd () {
3325
"$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
3426
check_unchanged
3527
}
28+
29+
create_empty_file () {
30+
empty_file="${TMPDIR:-/tmp}/git-difftool-p4merge-empty-file.$$"
31+
>"$empty_file"
32+
33+
printf "$empty_file"
34+
}

0 commit comments

Comments
 (0)