mergetools/p4merge: create a base if none available
[git/git.git] / mergetools / p4merge
CommitLineData
bc7a96a8 1diff_cmd () {
950b5680
DA
2 empty_file=
3
3facc600 4 # p4merge does not like /dev/null
3facc600
DA
5 if test "/dev/null" = "$LOCAL"
6 then
950b5680 7 LOCAL="$(create_empty_file)"
3facc600
DA
8 fi
9 if test "/dev/null" = "$REMOTE"
10 then
950b5680 11 REMOTE="$(create_empty_file)"
3facc600
DA
12 fi
13
bc7a96a8 14 "$merge_tool_path" "$LOCAL" "$REMOTE"
3facc600 15
950b5680 16 if test -n "$empty_file"
3facc600 17 then
950b5680 18 rm -f "$empty_file"
3facc600 19 fi
bc7a96a8
DA
20}
21
22merge_cmd () {
23 touch "$BACKUP"
4549162e
KB
24 if ! $base_present
25 then
26 cp -- "$LOCAL" "$BASE"
27 create_virtual_base "$BASE" "$REMOTE"
28 fi
c699a7cc 29 "$merge_tool_path" "$BASE" "$REMOTE" "$LOCAL" "$MERGED"
bc7a96a8
DA
30 check_unchanged
31}
950b5680
DA
32
33create_empty_file () {
34 empty_file="${TMPDIR:-/tmp}/git-difftool-p4merge-empty-file.$$"
35 >"$empty_file"
36
d272c849 37 printf "%s" "$empty_file"
950b5680 38}