Merge branch 'jk/two-way-merge-corner-case-fix'
[git] / mergetools / p4merge
1 diff_cmd () {
2         empty_file=
3
4         # p4merge does not like /dev/null
5         if test "/dev/null" = "$LOCAL"
6         then
7                 LOCAL="$(create_empty_file)"
8         fi
9         if test "/dev/null" = "$REMOTE"
10         then
11                 REMOTE="$(create_empty_file)"
12         fi
13
14         "$merge_tool_path" "$LOCAL" "$REMOTE"
15
16         if test -n "$empty_file"
17         then
18                 rm -f "$empty_file"
19         fi
20 }
21
22 merge_cmd () {
23         touch "$BACKUP"
24         if ! $base_present
25         then
26                 cp -- "$LOCAL" "$BASE"
27                 create_virtual_base "$BASE" "$REMOTE"
28         fi
29         "$merge_tool_path" "$BASE" "$REMOTE" "$LOCAL" "$MERGED"
30         check_unchanged
31 }
32
33 create_empty_file () {
34         empty_file="${TMPDIR:-/tmp}/git-difftool-p4merge-empty-file.$$"
35         >"$empty_file"
36
37         printf "%s" "$empty_file"
38 }