4

In git, how do I verify that a merge upstream master commit does not contain any additional diffs? Say I want to verify that the person didn't do anything 'sneaky' besides actually merge the changes from the upstream master branch.

I want to verify that the only diffs come from the other commits they made; that they did not perform an 'evil merge'.

Is there a way to verify that no additional changes were made during the merge step?
Or better yet: show me the potential 'evil merge' diffs so I can see for myself what extra work might have been done?

Example scenario:

          P1---P2   P3---P4---P5---P6
         /       \  /        /       \
    A---B---C---D--E--------F---------G master
                    \      /
                     C1---C2

P1..P2: First pull request
C1..C2: My working branch
P3..P4: More work done inbetween
P5: The commit that merges in master branch changes
P6: More regular work
  1. Someone sends a pull request to my repo (P1..P2)
  2. The pull request is fantastic, and I merge it (E)
  3. I do some further development (C1..C2), integrate my own branch to master (F), and publish
  4. The other person has done more work in the meantime (P3..P4)
  5. They merge upstream changes into their local repo (P5), makes more changes (P6), and send a second pull request
  6. Can I verify that they didn't sneak in any extra diffs during the merge (P5)?
culix
  • 10,188
  • 6
  • 36
  • 52
  • did you try `git diff --name-status master..branchName` ? – royki Nov 28 '14 at 09:26
  • @Altius Using `git diff --name-status master..branchName` only seems to show me a list of all files that changed, not the actual code diffs. Also, it shows all files that were normally part of the merge and included in both parents. I'm only looking for the diffs that were *not* in both parents. 'Evil merge' changes. – culix Nov 28 '14 at 19:10
  • Have you used `SourceTree` [SourceTree](http://www.sourcetreeapp.com/)? Or even better in `Emacs`. – royki Nov 28 '14 at 19:17
  • @Altius Do either of those programs help me verify that a git merge contains no extra changes? If so, how? – culix Nov 30 '14 at 02:58
  • It has been one week and there are no other replies. Accepting my own answer for now, but I'm still open to other suggestions if anyone has an easier/better solution. – culix Dec 07 '14 at 02:10

1 Answers1

1

You can check whether a git merge commit contains any other changes by doing a diff of diffs. Here's one way.

          P1---P2   P3---P4---P5---P6
         /       \  /        /       \
    A---B---C---D--E--------F---------G master
                    \      /
                     C1---C2
  1. Calculate the diff of all changes in the master branch between the original common parent E and the master branch commit just before the merge, F:

    git diff E F > master_changes_to_merge.txt

  2. Calculate a diff of everything changed in the 'merge in master' commit, P5

    git diff P4 P5 > master_changes_actually_merged.txt

  3. Diff those:

    diff master_changes_to_merge.txt master_changes_actually_merged.txt

If step 3 shows no output, there should be no evil merge changes.

culix
  • 10,188
  • 6
  • 36
  • 52
  • And if anyone's actual branch histories look as straightforward as the ones in this diagram, I salute you. – culix Dec 02 '14 at 04:34