Andrew Bullock
Andrew Bullock

Reputation: 37436

Why is BeyondCompare 4 / Git trying to perform a text diff on binary files?

I'm trying to merge a branch which has a different .NET .dll and .pdb, and git/BC4 is trying to do a text merge on the files instead of letting me choose local vs remote.

I've never experienced this before, presumably I have changed some setting or BC4 has some difference to BC3.

My relevant .gitconfig

[merge]
    tool = bec3
    renamelimit = 2000
[mergetool]
    prompt = false
    keepBackup = false
[mergetool "bec3"]
    cmd = \"C:/Program Files (x86)/Beyond Compare 4/bcomp.exe\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\"
    trustExitCode = true

I'm using msysgit 1.9.5 and Beyond Compare 4.0.3

Edit: I dont want to binary merge, git used to simply make me choose the local or remote file to resolve the conflict. My question is "is this a git setting (if so, what?) or a BC setting?"

Upvotes: 1

Views: 262

Answers (2)

VonC
VonC

Reputation: 1329870

This works better 6 years later: With Git 2.34 (Q4 2021), the xxdiff difftool (in your case 'BeyondCompare') backend can exit with status 128, which the difftool-helper that launches the backend takes as a significant failure, when it is not significant at all.
This is no longer blocking.

Here, 'xxdiff' is the diff tool of your choice (again, here, BeyondCompare)

See commit 571f434 (12 Oct 2021) by David Aguilar (davvid).
(Merged by Junio C Hamano -- gitster -- in commit 6a1bb08, 25 Oct 2021)

mergetools/xxdiff: prevent segfaults from stopping difftool

Signed-off-by: David Aguilar

Users often use "git difftool"(man) 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.

Upvotes: 0

Chris Kennedy
Chris Kennedy

Reputation: 2909

Beyond Compare doesn't support merging binary files. Some version control systems allow you to define different merge tools based on file extension, calling different merge tools for binary and text files. I don't think Git provides a way to do that.

You'll have to merge binary files outside of Beyond Compare.

To resolve the conflict with the repository version of the .dll file:

    git checkout --theirs -- file.dll
    git add file.dll
    git commit

To resolve the conflict with your version of the .dll file:

    git checkout --ours -- file.dll
    git add file.dll
    git commit

I'll add merge of binary files to our feature wish list for a future version of Beyond Compare.

Upvotes: 1

Related Questions