mergetools/meld: make usage of `--output` configurable and more robust
Older versions of meld listed --output in `meld --help`. Newer versions only mention `meld [OPTIONS...]`. Improve the checks to catch these newer versions. Add a `mergetool.meld.hasOutput` configuration to allow overriding the heuristic. Reported-by: Andrey Novoseltsev <novoselt@gmail.com> Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
David Aguilar committed
Oct 15, 2014 at 21:45 UTC
b12d04503b0aba1f2d68b164b348cbf94bbe570b
2 files changed
+16
-2
Documentation/config.txt
+9
@@ -1754,6 +1754,15 @@ mergetool.<tool>.trustExitCode::
1754
if the file has been updated, otherwise the user is prompted to
1755
indicate the success of the merge.
1756
1757
+mergetool.meld.hasOutput::
1758
+ Older versions of `meld` do not support the `--output` option.
1759
+ Git will attempt to detect whether `meld` supports `--output`
1760
+ by inspecting the output of `meld --help`. Configuring
1761
+ `mergetool.meld.hasOutput` will make Git skip these checks and
1762
+ use the configured value instead. Setting `mergetool.meld.hasOutput`
1763
+ to `true` tells Git to unconditionally use the `--output` option,
1764
+ and `false` avoids using `--output`.
1765
+
1766
mergetool.keepBackup::
1767
After performing a merge, the original file with conflict markers
1768
can be saved as a file with a `.orig` extension. If this variable
mergetools/meld
+7
-2
@@ -18,13 +18,18 @@ merge_cmd () {
18
check_unchanged
19
}
20
21
-# Check whether 'meld --output <file>' is supported
21
+# Check whether we should use 'meld --output <file>'
22
check_meld_for_output_version () {
23
meld_path="$(git config mergetool.meld.path)"
24
meld_path="${meld_path:-meld}"
25
26
- if "$meld_path" --help 2>&1 | grep -e --output >/dev/null
26
+ if meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)
27
then
28
+ : use configured value
29
+ elif "$meld_path" --help 2>&1 |
30
+ grep -e '--output=' -e '\[OPTION\.\.\.\]' >/dev/null
31
+ then
32
+ : old ones mention --output and new ones just say OPTION...
33
meld_has_output_option=true
34
else
35
meld_has_output_option=false