Search code examples
gitgit-diff

generating diff between between two branches, after a partial review


Let's say I have this situation in git:

  B---D---F---H---J---K--->topic
 /       /       /
A---C---E---G---I--->master

After getting as far as commit F, I submit the topic branch for review. The reviewer makes some suggestions, and the world moves on, so another merge is done. As answered here Git diff on topic branch, excluding merge commits that happened in the meantime? the way to generate the diff from A to F simply git diff master..topic. Now however, revisions B and D have already been reviewed, and I would like to exclude them from a new diff for review. git diff E..topic includes G and I however.

How do I get a diff of H, J and K, excluding things pulled in through G and I?


Solution

  • torek's suggestion (to do multiple reviews) is a possibility, but has the unfortunate side effect of meaning that code that was say in need of improvement after F and fixed in H must be reviewed twice: once in its sub-par state, and once when it has been finished. The nice thing about git diff master..topic was that it squashed these, and just gave the final difference between the branches.

    What I did to solve the problem was create a branch from F, merge master into there, and then do a diff between my new temporary branch and the topic branch. That way all changes to master were glossed over, and only the changes to the topic branch since the previous review point are used.