Sync with 2.30.8
[git.git] / mergetools / meld
blobaab4ebb9355ae946f1c7b289569f1892ea29e583
1 diff_cmd () {
2         "$merge_tool_path" "$LOCAL" "$REMOTE"
5 merge_cmd () {
6         check_meld_for_features
8         option_auto_merge=
9         if test "$meld_use_auto_merge_option" = true
10         then
11                 option_auto_merge="--auto-merge"
12         fi
14         if test "$meld_has_output_option" = true
15         then
16                 "$merge_tool_path" $option_auto_merge --output="$MERGED" \
17                         "$LOCAL" "$BASE" "$REMOTE"
18         else
19                 "$merge_tool_path" $option_auto_merge "$LOCAL" "$MERGED" "$REMOTE"
20         fi
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
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"
36         then
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
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"
60         then
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
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
88         fi