vscode-git-graph
vscode-git-graph copied to clipboard
Compare any two commits in preferred order
Describe the improvement that you'd like Currently, comparing any two commits always compares the newer commit (ie. latest in time) versus the older commit, regardless of which commit is clicked first (then CTRL/CMD clicking on the other commit), Some situation requires comparison in a preferred order.
Additional context (optional) A good example is comparing alternative experimental approaches of branch A versus branch B: A versus B, or B versus A.
GitLens extension allows this, via the Search & Compare under Source Control panel.
I just stumbled across the same issue and tinkered a bit with the code to see if this limitation can be lifted somehow. While doing so I noticed that the same issue was discussed briefly in #29 with generally positive reactions. One concern brought up over there was
The diff should be clearly interpretable from the Diff view alone, so the only way to allow the reversed ordering would be to change the tab title.
It seems this has been done in the meantime, so it is not an issue anymore.
Another open question would be how to handle diffs between a commit and the working tree. Should such comparisons be reversible as well? In principle it is possible to obtain such a diff from git using the -R flag, e.g. git diff --name-status -R <commit> for the diff from working tree to <commit>. The only downside I've noticed so far is that when VSCode is instructed to open a workspace file in the left (old) side of a diff editor, changes cannot be saved immediately (the left side is editable, but pressing CTRL+S opens a "save as" dialog).
But maybe this is too confusion for users and gitgraph should keep normalizing the comparison order when the worktree is involved. Any thoughts?
@mhutchie If you don't object to the feature in general, I'd try to prepare a PR.
When working with multiple branches, and when comparing changes between them, it would be extremely useful to use the click order set the order of the diff (just like you can with arbitrary commits and git diff: git diff <branch A commit> <branch B commit> path/to/file)
Upon discovering this feature (today), I immediately tried to use it with a set of commits in different branches whose time was the inverse of the A->B comparison I wanted to do.