It would be useful to perform a comparison which shows what would happen if a branch were merged. To be specific, I'd like to compare the working copy with git merge-base X HEAD where X is specified by the user (and is probably "master").
I find this is the best way of seeing what effect accepting a PR would have on a target branch.
This isn't the same as comparing with upstream (which shows you how a branch has changed since it was last pushed/pulled) nor is it the same as comparing with X (which would include changes that have happened subsequently on X).
With meld, I do all this with:
meld = difftool --dir-diff --tool=meld
meldbase = !git meld $(git merge-base origin/master HEAD)
review = !git fetch $1 $2 && git checkout FETCH_HEAD && git meldbase && true
Note in the above that meldbase and review are comparing the merge-base with the working copy, not with HEAD. I like it this way as it lets me see any tweaks I may have made and not committed, and lets me make edits as I'm reviewing.
Thanks!
Can you provide an example of when there is a difference between comparing from the merge-base as opposed to git diff origin/master...HEAD. I can't see any differences in the behavior.
From the man page, you're right in saying:
"git diff A...B" is equivalent to "git diff $(git-merge-base A B) B"
However I'm more interested in comparing my working copy (which is a checkout of B, with possibly local changes) with the merge-base, so I'm after:
git diff $(git-merge-base A B) # no second argument => working copy
I should have put a little emphasis on _working copy_ in the original post :)
Ah, now I see. Thanks!
So now the challenge becomes how this should work and the naming of it ;)
I think I will need to use the same 2-step style of the branch compare, choose Select for Compare (branch A), and then choose something like Compare Base with Selected to Working Tree (branch B)
Which will be used in git diff $(git-merge-base A B)
Thoughts on the naming?
Compare Base with Selected to Working Tree
or
Compare Selected Base with Working Tree
or
Compare Selected Merge Base with Working Tree
@cdyson37 If you'd like to check out this new feature its in the latest 7.3 beta
How about Compare with common ancestor?
Odd - doesn't seem to be working for me at all - in fact none of the comparisons seem to do anything. vscode 1.19.0. Apologies if I'm just being very stupid!
Hrm, I just tried on 1.19.1 and didn't have any issue. What steps are you performing? Are you using Select for Compare on a branch, and then choosing Compare Selected Base with Working? And that should show the GitLens Results view -- unfortunately it can only be opened collapsed by default :( so you have to expand it to see the contents.
As for naming, maybe Compare Common Ancestor with Working is better than Compare Selected Base with Working or Compare Selected Ancestor with Working -- having Selected in there is probably important because of the 2-step nature.
Ahh it opens collapsed - sorry I completely missed that! Anyway this functionality is perfect for me. I can go through the changed files and make small fixes before merging. Thank you!
(Maybe as a hint it should flash a banner saying "now open gitlens results", with a "don't show again" button once people have got the hint?)
Ugh, yeah -- I will see if there is anything else I can do, but if not a message might be a good way.
FYI, the latest beta switches to the explorer view (still can't expand the GitLens Results view tho) and will pop a message the first time, telling you where to look.
Sounds great - thank you!
This is a great feature, thank you guys for requesting and implementing it.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
This is a great feature, thank you guys for requesting and implementing it.