1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-08 00:26:33 +02:00
git/mergetools/xxdiff
David Aguilar 571f4348dd mergetools/xxdiff: prevent segfaults from stopping difftool
Users often use "git difftool HEAD^" to review their work, and have
"mergetool.prompt" set to false so that difftool does not prompt them
before diffing each file.

This is very convenient because users can see all their diffs by
reviewing the xxdiff windows one at a time.

A problem occurs when xxdiff encounters some binary files.
It can segfault and return exit code 128, which is special-cased
by git-difftool-helper as being an extraordinary situation that
aborts the process.

Suppress the exit code from xxdiff in its diff_cmd() implementation
when we see exit code 128 so that the GIT_EXTERNAL_DIFF loop continues
on uninterrupted to the next file rather than aborting when it
encounters the first binary file.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-10-13 11:04:04 -07:00

31 lines
768 B
Plaintext

diff_cmd () {
"$merge_tool_path" \
-R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl+G"' \
"$LOCAL" "$REMOTE"
# xxdiff can segfault on binary files which are often uninteresting.
# Do not allow segfaults to stop us from continuing on to the next file.
if test $? = 128
then
return 1
fi
}
merge_cmd () {
if $base_present
then
"$merge_tool_path" -X --show-merged-pane \
-R 'Accel.SaveAsMerged: "Ctrl+S"' \
-R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl+G"' \
--merged-file "$MERGED" "$LOCAL" "$BASE" "$REMOTE"
else
"$merge_tool_path" -X $extra \
-R 'Accel.SaveAsMerged: "Ctrl+S"' \
-R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl+G"' \
--merged-file "$MERGED" "$LOCAL" "$REMOTE"
fi
}