Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-7097

Diff is incorrect when source branch modified before destination branch

    • Icon: Bug Bug
    • Resolution: Answered
    • Icon: Low Low
    • None
    • 3.6.1
    • None
    • Stash 3.6.1 linux x86_64 on both:

      • Fedora 20, git 2.1.0, JDK8
      • RHEL6, git 2.2.2, JDK7

      If a portion of a file is independently deleted in two branches, then sometimes the diff view is incorrect.

      To reproduce, create a new repo in stash, then run the attached shell script (changing the remote URL if needed), and view the diff between master and branch:

      http://localhost:7990/stash/projects/TEST/repos/diffbug/compare/diff?targetBranch=refs%2Fheads%2Fmaster&sourceBranch=refs%2Fheads%2Fbranch

      Expected results: the diff view shows the first line changed from 'MASTER START' to 'BRANCH START', like 'git diff master branch' shows:

      $ git diff master branch
      diff --git a/test.txt b/test.txt
      index 9199536..91ad9bb 100644
      — a/test.txt
      +++ b/test.txt
      @@ -1,3 +1,3 @@
      -MASTER START
      +BRANCH START

      END

      Actual results: the diff view shows the 'MIDDLE' section having been deleted as well as the first line changing

      Reversing the source/dest branches (ie http://localhost:7990/stash/projects/TEST/repos/diffbug/compare/diff?targetBranch=refs%2Fheads%2Fbranch) shows the ONLY the middle section changing WITHOUT the first line changing.

      This affects both the side-by-side diff and the unified Once a pull request is made, then the diff in the PR is correct.

        1. stash-diffbug.sh
          0.4 kB
        2. stash-diffbug.sh
          0.4 kB

          Form Name

            [BSERV-7097] Diff is incorrect when source branch modified before destination branch

            Gary Miner added a comment -

            I know this is closed. But this is extremely confusing for our devs, I would prefer that the diff "preview" was disabled if this is going to stay like this.

            Gary Miner added a comment - I know this is closed. But this is extremely confusing for our devs, I would prefer that the diff "preview" was disabled if this is going to stay like this.

            Hi bradley.baetz,
            This is expected behaviour due to the limitations of the diffing approach taken with the compare page. You can read more about the way we do diffs in pull requests in this blog post

            Because a branch compare is transient and there is a non-trivial cost to generating the merge commit for the diff, we chose to ship compare with a simple common ancestor diff. This is why you are not seeing the same diff on the compare page as you do when you create a pull request.

            We may consider revisiting this decision in the future.

            Michael

            Michael McGlynn (Inactive) added a comment - - edited Hi bradley.baetz , This is expected behaviour due to the limitations of the diffing approach taken with the compare page. You can read more about the way we do diffs in pull requests in this blog post Because a branch compare is transient and there is a non-trivial cost to generating the merge commit for the diff, we chose to ship compare with a simple common ancestor diff. This is why you are not seeing the same diff on the compare page as you do when you create a pull request. We may consider revisiting this decision in the future. Michael

            Oops, had a typo in the script. Try this one instead

            Bradley Baetz added a comment - Oops, had a typo in the script. Try this one instead

              Unassigned Unassigned
              06fbb7509c24 Bradley Baetz
              Affected customers:
              0 This affects my team
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: