Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare working copy to merge-base #240

Closed
cdyson37 opened this issue Jan 2, 2018 · 15 comments
Closed

Compare working copy to merge-base #240

cdyson37 opened this issue Jan 2, 2018 · 15 comments
Assignees
Labels
feature New feature or request

Comments

@cdyson37
Copy link

cdyson37 commented Jan 2, 2018

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!

@eamodio
Copy link
Member

eamodio commented Jan 4, 2018

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.

@eamodio eamodio added the needs-more-info Needs further information, steps, details, etc. label Jan 4, 2018
@cdyson37
Copy link
Author

cdyson37 commented Jan 4, 2018

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 :)

@eamodio
Copy link
Member

eamodio commented Jan 4, 2018

Ah, now I see. Thanks!

@eamodio eamodio self-assigned this Jan 4, 2018
@eamodio eamodio added feature New feature or request and removed needs-more-info Needs further information, steps, details, etc. labels Jan 4, 2018
@eamodio eamodio added this to the Soon™ milestone Jan 4, 2018
@eamodio
Copy link
Member

eamodio commented Jan 4, 2018

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

@eamodio eamodio added the pending-release Resolved but not yet released to the stable edition label Jan 5, 2018
@eamodio
Copy link
Member

eamodio commented Jan 5, 2018

@cdyson37 If you'd like to check out this new feature its in the latest 7.3 beta

@cdyson37
Copy link
Author

cdyson37 commented Jan 5, 2018

How about Compare with common ancestor?

@cdyson37
Copy link
Author

cdyson37 commented Jan 5, 2018

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!

@eamodio
Copy link
Member

eamodio commented Jan 5, 2018

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.

@eamodio
Copy link
Member

eamodio commented Jan 5, 2018

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.

@cdyson37
Copy link
Author

cdyson37 commented Jan 5, 2018

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?)

@eamodio
Copy link
Member

eamodio commented Jan 5, 2018

Ugh, yeah -- I will see if there is anything else I can do, but if not a message might be a good way.

@eamodio
Copy link
Member

eamodio commented Jan 12, 2018

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.

@cdyson37
Copy link
Author

Sounds great - thank you!

@lolmaus
Copy link

lolmaus commented Mar 26, 2018

This is a great feature, thank you guys for requesting and implementing it.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants