]>
Commit | Line | Data |
---|---|---|
bc7a96a8 DA |
1 | diff_cmd () { |
2 | "$merge_tool_path" "$LOCAL" "$REMOTE" | |
3 | } | |
4 | ||
5 | merge_cmd () { | |
dbd8c09b LS |
6 | check_meld_for_features |
7 | ||
8 | option_auto_merge= | |
9 | if test "$meld_use_auto_merge_option" = true | |
f61bd9c6 | 10 | then |
dbd8c09b | 11 | option_auto_merge="--auto-merge" |
f61bd9c6 | 12 | fi |
7c10605d | 13 | |
f61bd9c6 DA |
14 | if test "$meld_has_output_option" = true |
15 | then | |
dbd8c09b | 16 | "$merge_tool_path" $option_auto_merge --output="$MERGED" \ |
f61bd9c6 DA |
17 | "$LOCAL" "$BASE" "$REMOTE" |
18 | else | |
dbd8c09b | 19 | "$merge_tool_path" $option_auto_merge "$LOCAL" "$MERGED" "$REMOTE" |
f61bd9c6 | 20 | fi |
bc7a96a8 | 21 | } |
f61bd9c6 | 22 | |
dbd8c09b LS |
23 | # Get meld help message |
24 | init_meld_help_msg () { | |
25 | if test -z "$meld_help_msg" | |
26 | then | |
27 | meld_path="$(git config mergetool.meld.path || echo meld)" | |
28 | meld_help_msg=$("$meld_path" --help 2>&1) | |
29 | fi | |
30 | } | |
f61bd9c6 | 31 | |
dbd8c09b LS |
32 | # Check the features and set flags |
33 | check_meld_for_features () { | |
34 | # Check whether we should use 'meld --output <file>' | |
35 | if test -z "$meld_has_output_option" | |
f61bd9c6 | 36 | then |
dbd8c09b LS |
37 | meld_has_output_option=$(git config --bool mergetool.meld.hasOutput) |
38 | case "$meld_has_output_option" in | |
39 | true | false) | |
40 | : use configured value | |
41 | ;; | |
42 | *) | |
43 | : empty or invalid configured value, detecting "--output" automatically | |
44 | init_meld_help_msg | |
45 | ||
46 | case "$meld_help_msg" in | |
47 | *"--output="* | *'[OPTION...]'*) | |
48 | # All version that has [OPTION...] supports --output | |
49 | meld_has_output_option=true | |
50 | ;; | |
51 | *) | |
52 | meld_has_output_option=false | |
53 | ;; | |
54 | esac | |
55 | ;; | |
56 | esac | |
57 | fi | |
58 | # Check whether we should use 'meld --auto-merge ...' | |
59 | if test -z "$meld_use_auto_merge_option" | |
b12d0450 | 60 | then |
dbd8c09b LS |
61 | meld_use_auto_merge_option=$( |
62 | git config --bool-or-str mergetool.meld.useAutoMerge | |
63 | ) | |
64 | case "$meld_use_auto_merge_option" in | |
65 | true | false) | |
66 | : use well formatted boolean value | |
67 | ;; | |
68 | auto) | |
69 | # testing the "--auto-merge" option only if config is "auto" | |
70 | init_meld_help_msg | |
71 | ||
72 | case "$meld_help_msg" in | |
73 | *"--auto-merge"* | *'[OPTION...]'*) | |
74 | meld_use_auto_merge_option=true | |
75 | ;; | |
76 | *) | |
77 | meld_use_auto_merge_option=false | |
78 | ;; | |
79 | esac | |
80 | ;; | |
81 | "") | |
82 | meld_use_auto_merge_option=false | |
83 | ;; | |
84 | *) | |
85 | die "unknown mergetool.meld.useAutoMerge: $meld_use_auto_merge_option" | |
86 | ;; | |
87 | esac | |
f61bd9c6 DA |
88 | fi |
89 | } |