Skip to content

Commit f61bd9c

Browse files
davvidgitster
authored andcommitted
mergetools/meld: Use '--output' when available
meld 1.5.0 and newer allow the output file to be specified when merging multiple files. Check whether the meld command supports '--output' and use it when available. Signed-off-by: David Aguilar <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bc7a96a commit f61bd9c

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

mergetools/meld

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,30 @@ diff_cmd () {
33
}
44

55
merge_cmd () {
6+
if test -z "${meld_has_output_option:+set}"
7+
then
8+
check_meld_for_output_version
9+
fi
610
touch "$BACKUP"
7-
"$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
11+
if test "$meld_has_output_option" = true
12+
then
13+
"$merge_tool_path" --output "$MERGED" \
14+
"$LOCAL" "$BASE" "$REMOTE"
15+
else
16+
"$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
17+
fi
818
check_unchanged
919
}
20+
21+
# Check whether 'meld --output <file>' is supported
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" --output /dev/null --help >/dev/null 2>&1
27+
then
28+
meld_has_output_option=true
29+
else
30+
meld_has_output_option=false
31+
fi
32+
}

0 commit comments

Comments
 (0)