Skip to content

Commit 571f434

Browse files
davvidgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af6d1d6 commit 571f434

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mergetools/xxdiff

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ diff_cmd () {
33
-R 'Accel.Search: "Ctrl+F"' \
44
-R 'Accel.SearchForward: "Ctrl+G"' \
55
"$LOCAL" "$REMOTE"
6+
7+
# xxdiff can segfault on binary files which are often uninteresting.
8+
# Do not allow segfaults to stop us from continuing on to the next file.
9+
if test $? = 128
10+
then
11+
return 1
12+
fi
613
}
714

815
merge_cmd () {

0 commit comments

Comments
 (0)