No announcement yet.

git conflicts with binary files?

  • Filter
  • Time
  • Show
Clear All
new posts

  • git conflicts with binary files?

    I use bc3 as the merge tool with Cygwin git on Windows to resolve conflicts. Works great with text files!

    But I can't figure out a way to use it with binary files that conflict, which is a pain. I realize bc3 isn't going to do any real merging, I just want to be able to type git mergetool, and if one of the files is binary, just let me pick the left or right file to output as the result. As it is, bc3 gives an error, and closing it apparently reports an error code that causes git to consider the merge a failure. Choosing the left or right file for output without actually performing a merge should always give a successful exit status.

    And even for text files, I'd like there to be an option to pick the entire left file or the entire right file for output. To do that now when I need to, I select the entire text window for the side I want, copy it to the clipboard, then select the entire output window and paste the clipboard into it and save.

    Is there a way to get the behavior I want that I just can't find? This tool is so awesome, I'm finding it hard to believe there's something useful that it could do but doesn't do!

  • #2

    BC3 doesn't currently support this. A few other version control solutions offer masking for different file types to lead to different tools, which is how they are able to work around this. It is on our wishlist to either detect or allow the merging of binary files, but isn't something we currently support.

    As for picking the entire file, you can use the View menu -> Favor Left to auto select any left changes that are not conflicts. This still wouldn't automatically bring in conflict sections however, as those are normally in need of review. If you do need to do a full "copy/paste", instead of a paste: once you Select All of a specific input pane, the gutter Copy To Output arrow will be the whole selection. You can then click the arrow, instead of pasting into the output.
    Aaron P Scooter Software


    • #3
      Thanks, Aaron, I guess I feel relieved that it wasn't described somewhere and I just missed it :-) Although this probably isn't the most critical of features, it certainly could come in handy for resolving conflicts in git, because (at least the way I'm configured), git directs the workflow such that when a conflict is detected you just press return and find yourself in bc3's three-way merge. 99% of the time, that does exactly what you want. But if you can't do what you want within the three-way merge (like choose one side or the other easily, even if the files are binary), then exiting bc3 and getting an error on the merge, followed by some arcane manual command-line fiddling, is a big step down in convenience. To someone who thinks that BC3 functionality is actually magic, it *seems* like adding such a capability would be dead easy to so.

      I guess I should dig into the way that git integrates with various merge tools to see if I can at least have it detect binary files at that level, and have it invoking something else (like even a simple shell script) to let you select which file. Part of the problem doing things manually with git is that the way you do the manual resolution is very un-intuitive: "git checkout --ours" or "git checkout --theirs" followed by "git add". Besides the fact that the meaning of "ours" vs "theirs" isn't obvious to start with, there's also the fact that their meanings are *reversed" in some sense depending on whether you're performing a merge or a rebase.

      Anyway, just want to thank you again for a great program. One of the few in this space that's well worth the license fee.


      • #4
        We appreciate the feedback and description of your workflow. We'll look into if there's anything we can do that might help, and I'll ask around the office for someone more familiar with git if there's a configuration which might help.
        Aaron P Scooter Software


        • #5
          My workaround

          Okay, I've done minimal testing of this, but it appears to work for me using Cygwin git with bc3 as the merge tool. I'm just following your suggestion about masking on different filetypes to lead to different tools. And posting it here for reference and possible use by others. The scripts give credit to the origins of the basic technique, which is a little tricky to get right with pathnames on Cygwin. My only contribution is testing for binary files and the chooser script.

          The global git config:
          git config --global mergetool.bc3.cmd " \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
          git config --global mergetool.bc3.trustExitCode true
          The referenced script is attached, along with the scripts it uses: and, all of which are on my PATH in /usr/local/bin (note I just added a .txt extension to allow them to upload, and note that they have Unix line-endings, so notepad won't like them).
          Attached Files
          Last edited by sootsnoot; 02-Jul-2015, 11:32 PM. Reason: bugs in attachments