Show merge-base diff
For a long time I have been trying to have the Git UI in JB IDE (WebStorm in my case) address one of most typical scenarios I am falling into: getting an all-in-one diff of a branch that I have no clue about.
Typically I either inherited from someone without a word of legend - or - it is my own branch that I had put aside a long time ago where I have no longer a recollection of the changes. In both cases I need to quickly scroll through aggregated changes diffed against another branch (typically: main/master) - a typical GitHub diff experience.
This task got a bit easier in JB IDEs ever since we got the all-in-one type of view (see Advanced Settings and gear icon). But it is still clunky in two ways:
a. There is no convenient “entry point” + I need to manually select the entire commit range in Git Log first. I go by the colors - the commits after merge-base usually start with a different color.
b. The diff view is poorly designed - the placement of UI elements is misleading as to their roles and hierarchy.
There is a lot to improve IMO, but I'd like to take this former point here. Here are my ideas to start with:
1. Could we have a Show a Common Ancestor Diff… command in the submenu of each and every branch? (naming up to JB) - basically UI should allow to compare every branch to every branch.
2. Given that I typically first checkout the branch and then compare, I would love to have a key-mappable command that compares the current branch - without having to dig it up from the submenus.
Of course naming is important, because for this diff it is crucial which branch you compare and which one you compare to, but I don't want to focus on details here. I'm just interested in having the entire flow working seamlessly.
Is there any other way to achieve what I'm after? Except using VSCode with GitKraken/GitLens…
请先登录再写评论。
Hi,
Please see: https://youtrack.jetbrains.com/issue/IJPL-155890
Does show diff with working tree help?
Additionally, you can use Compare with the current branch and highlight commits that do not belong to the same branch.
Compare branch already uses triple dot notation: https://youtrack.jetbrains.com/issue/IJPL-106178/Option-to-compare-git-branch-to-merge-base-instead-of-current-revision
Hi,
Thanks for chiming in. I appreciate your willingness to help :) Now brace for a long reading!
First off, let's leave working tree comparison for a different discussion. This is a whole different story where I also have a lot of comments.
Looking at `git merge-base` syntax I understand that figuring a merge-base without knowing two commits is tricky/expensive/unreliable/impossible. So ok - you'll always need to provide two commit-like references - fair enough.
Let's look into the Compare With [branch] option you mention. In all fairness, find it almost useless and the flow very awkward. Here's why:
I find the entry point very clunky - you need to reach out to branch menu + identify and target the correct item in submenu. This is so inaccessible and tedious - even if you use keyboard arrows. Also it has a mental overhead - you need to figure out which branch item you need to reach to.
Example:
Given you are on branch A -> you need to find branch B in the menu -> dig out the submenu item labeled Compare with A.
A>B>A - A circular mental journey! Ridiculous, if you ask me :)
Let's look at the layout of “Compare With [branch]” dialog
While I admit that the richness of the data you get might be useful in some cases, for my flow it consists mostly of wasted screen estate: I only need one of the red frames and only - and this also is disputable whether I need it at all. Could be collapsible.
And the blue diff panes - for my workflow I only need one, and it should be wide enough to present files and changes in a continuous way.
Let's compare UX with IDE's Git Rebase flow
IDE Git Rebase's has quite a nice flow - you paste in the branch/commit ref (in my case it's typically `origin/main`), all settings - including the branch - are persistent across IDE sessions, so most of the time you just hit enter and you see the result. Thus, the user journey basically boils down to a keyboard shortcut + enter! That's the experience I would be after. You could compare thousands of branches with `origin/main` one after another without hassle.
How we could redesign the flow
Here I've sketched out how I would imagine my ideal user flow, based on Git Rebase experience.
So let's assume you are on your branch (`feat/login`).
1. You have a keyboard-mappable command Compare Current Branch With (note: this already frees user from selecting one commit ref!)
2. The command brings up a dialog:
3. Press Show Diff and you get Git code review experience - one continuous, aggregated view where you can select commits and see the files in a left-hand side menu (this acts like a scroll-spy affix menu). In the header area you could see a summary of the commit(s) you selected. The dropdown saying All commits offers a list of individual commits (so the current experience would not be lost, should anyone need it).
…and when you think of it - those two windows could even be merged into one!
I hope you can now recognize the difference in the workflows - currently offered and requested.
Yes, I know “this is not something IDE offers at this time” - but that's why I posted my original massage: to make a change. I hope we could also have a UX designer in this discussion.
Have a great day, and happy coding!
PS. Wherever I say “I need it” “I don't need it” my sole purpose is to present my preferred experience and not sound like an egocentric :) There's probably thousands of users who have different flows, but I am sure IDE can also adopt a new, simplified one.
Thanks for all the details. I've passed this feedback to our UX team.