Merge branch 'jk/test-lsan-improvements'
[git/gitster.git] / mergetools / meld
blob8ec0867e032bf7ed4036d5da4f2bfae7fd2b2ae4
1 diff_cmd () {
2         "$merge_tool_path" "$LOCAL" "$REMOTE"
5 diff_cmd_help () {
6         echo "Use Meld (requires a graphical session)"
9 merge_cmd () {
10         check_meld_for_features
12         option_auto_merge=
13         if test "$meld_use_auto_merge_option" = true
14         then
15                 option_auto_merge="--auto-merge"
16         fi
18         if test "$meld_has_output_option" = true
19         then
20                 "$merge_tool_path" $option_auto_merge --output="$MERGED" \
21                         "$LOCAL" "$BASE" "$REMOTE"
22         else
23                 "$merge_tool_path" $option_auto_merge "$LOCAL" "$MERGED" "$REMOTE"
24         fi
27 merge_cmd_help () {
28         echo "Use Meld (requires a graphical session) with optional \`auto merge\` (see \`git help mergetool\`'s \`CONFIGURATION\` section)"
31 # Get meld help message
32 init_meld_help_msg () {
33         if test -z "$meld_help_msg"
34         then
35                 meld_path="$(git config mergetool.meld.path || echo meld)"
36                 meld_help_msg=$("$meld_path" --help 2>&1)
37         fi
40 # Check the features and set flags
41 check_meld_for_features () {
42         # Check whether we should use 'meld --output <file>'
43         if test -z "$meld_has_output_option"
44         then
45                 meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)
46                 case "$meld_has_output_option" in
47                 true | false)
48                         : use configured value
49                         ;;
50                 *)
51                         : empty or invalid configured value, detecting "--output" automatically
52                         init_meld_help_msg
54                         case "$meld_help_msg" in
55                         *"--output="* | *'[OPTION...]'*)
56                                 # All version that has [OPTION...] supports --output
57                                 meld_has_output_option=true
58                                 ;;
59                         *)
60                                 meld_has_output_option=false
61                                 ;;
62                         esac
63                         ;;
64                 esac
65         fi
66         # Check whether we should use 'meld --auto-merge ...'
67         if test -z "$meld_use_auto_merge_option"
68         then
69                 meld_use_auto_merge_option=$(
70                         git config --bool-or-str mergetool.meld.useAutoMerge
71                 )
72                 case "$meld_use_auto_merge_option" in
73                 true | false)
74                         : use well formatted boolean value
75                         ;;
76                 auto)
77                         # testing the "--auto-merge" option only if config is "auto"
78                         init_meld_help_msg
80                         case "$meld_help_msg" in
81                         *"--auto-merge"* | *'[OPTION...]'*)
82                                 meld_use_auto_merge_option=true
83                                 ;;
84                         *)
85                                 meld_use_auto_merge_option=false
86                                 ;;
87                         esac
88                         ;;
89                 "")
90                         meld_use_auto_merge_option=false
91                         ;;
92                 *)
93                         die "unknown mergetool.meld.useAutoMerge: $meld_use_auto_merge_option"
94                         ;;
95                 esac
96         fi