Announcement

Collapse
No announcement yet.

Comparing git branches using folder diff and copying changes

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Comparing git branches using folder diff and copying changes

    I've recently updated to BC4 from BC3 because of the improved folder-diff between git branches. Something that I can't get quite right though is the ability to "copy to other side" when doing the diff, and actually saving the result.

    This is my diff setting:
    Code:
    [difftool "bc"]
    path = c:/Program Files/Beyond Compare 4/bcomp.exe
    cmd = \"c:/Program Files/Beyond Compare 4/bcomp.exe\" \"$LOCAL\" \"$REMOTE\"
    I'm then starting the diff with either of the following commands:
    Code:
    git difftool -d master..HEAD
    git difftool -d HEAD..master
    git difftool -d master
    and then copy from the left window to the right, and press save. But the changes I make doesn't stick after closing Beyond Compare. Is there a way of getting this to work? I'm reviewing a huge merge, and going through the files one at a time would be excruciating.

  • #2
    Hello,

    First, quick update: I do not think you need the cmd = definition as part of the difftool. If the keyword "bc" is used, the path alone is sufficient for BC4.
    http://www.scootersoftware.com/suppo...vcs#gitwindows

    The file paths generated by Git are passed to BC4, as two temporary folders with temporary files within them. BC4's save command is updating the temp file, and signalling to Git when it closes. What Git does with the temporary file depends on a few things. Git is not going to automatically update Master or HEAD remotely, but the save instead updates the local file. However, this update only occurs if Head matches the current local version; if the local version has already been updated (so the local version is different than what was displayed in the diff) then Git discards the attempted save. For the dirdiff editing to apply, you'll need to directly dirdiff against the local version or make sure the local version is equal to the editing attempt, which updates the local version, which can then be staged and committed.
    Aaron P Scooter Software

    Comment


    • #3
      Originally posted by Aaron View Post
      Hello,

      First, quick update: I do not think you need the cmd = definition as part of the difftool. If the keyword "bc" is used, the path alone is sufficient for BC4.
      http://www.scootersoftware.com/suppo...vcs#gitwindows

      The file paths generated by Git are passed to BC4, as two temporary folders with temporary files within them. BC4's save command is updating the temp file, and signalling to Git when it closes. What Git does with the temporary file depends on a few things. Git is not going to automatically update Master or HEAD remotely, but the save instead updates the local file. However, this update only occurs if Head matches the current local version; if the local version has already been updated (so the local version is different than what was displayed in the diff) then Git discards the attempted save. For the dirdiff editing to apply, you'll need to directly dirdiff against the local version or make sure the local version is equal to the editing attempt, which updates the local version, which can then be staged and committed.
      Thanks, I've been running with the "clean" settings from your FAQ previously, the reason I've added the cmd was to be able to send "-automerge" to the mergetool, which is an amazing flag when merging a lot. It isn't needed for the difftool.

      I have a clean working tree when doing the dirdiff, shouldn't that mean that BC is able to update the local version when running the above commands?
      Last edited by AzP; 20-Mar-2019, 02:57 AM.

      Comment


      • #4
        In my testing, BC4 did update the local copy when executing a Save after some edits on the side that matched the local side content (but was a temporary copy of it). However, I had to verify locally (navigate to the local copy), as executing the diff command again would load the old master..Head, which were pointing to the original locations and not the new, edited local copy. I'm double checking, and my git was slightly out of date (2.20.1.windows.1).
        I've updated to 2.21.0 and now I'm seeing different behavior: the difftool -d is now returning the local copy updates each time for Head.

        BC4 itself isn't in much control of what is happening here. The expected behavior is, when called from git as difftool -d, you should see a Folder Compare pop up with the two temporary folders git has generated, filled with temporary files. BC4 can open the files, edit, save, and close. When closed, git is notified and then processes the temporary files under its control.

        Which version of Git are you running, and does updating help?
        Aaron P Scooter Software

        Comment


        • #5
          I was already running git 2.21.0, but when I now try the same command as before (git difftool -d master) it actually saves my changes properly, and gives me changes that are not staged.
          I currently have "dual settings" though, one in my global gitconfig and one in my local (because the latter one is needed for "Compare" to work correctly in Visual Studio, for some reason). Perhaps it works correctly now because that setting is overriding my global one.

          Comment


          • #6
            When making changes to the .gitconfig, it is sometimes useful to fully close any open instances of git bash or the command line, just to verify git isn't using a cached instance. Or, if in a bad state, a full reboot can sometimes help be certain it is pulling in the proper .gitconfig.
            Aaron P Scooter Software

            Comment

            Working...
            X