mhutchie / vscode-git-graph

View a Git Graph of your repository in Visual Studio Code, and easily perform Git actions from the graph.
https://marketplace.visualstudio.com/items?itemName=mhutchie.git-graph
Other
1.97k stars 261 forks source link

View diff of diffs (range-diff) #843

Open ackvf opened 1 week ago

ackvf commented 1 week ago

Describe the feature that you'd like Display a diff of changes introduced in two commits ignoring all intermediary commits.

git range-diff A~1..A A'~1..A'

Where A is the original commit, A' is rebased commit. and ~1 means parent of said commit, which results in the changeset of just one commit (from parent to current commit = 1 set of changes).

Additional context (optional) I have an old commit A with changes to files a, b, c. A target branch has several commits (B, K, X) touching files b, k, l, m, x, y, z I rebase the commit A onto latest target brach, resolve conflicts to file b and make last minute adjustments to file c, which results in commit A'.

Now I want to compare the changes between A and A', but ignore all changes from intermediary commits B, K, X.

Currently: Displays all changes between two commits. image

Expected: Only displays changes in related files.

qwerty@QWERTY-XPS9310:~/xrepos/xxx/aaa$ git range-diff d37e8f26..e4e0a1d5 3a0e633d..cd75d971
1:  e4e0a1d57 ! 1:  cd75d9717 Add Avatar element (#560)
    @@ plugins/aaa-element-avatar/package.json (new)
     +    "testEnvironment": "jsdom"
     +  },
     +  "license": "UNLICENSED",
-    +  "name": "@xxx/aaa-element-avatar",
+    +  "name": "@xxx/aaa-element-avatarz",
     +  "publishConfig": {
     +    "registry": "https://npm.pkg.github.com",
     +    "scope": "xxx"
image

Note that this practically compares just two commits, but a range can be arbitrary. To support this, there would have to be a new mechanism to select a range of commits

Possible solution:

Currently after selecting one commit and then holding CTRL, additional commit can be selected for the diff.

Solution 1) With the "range-diff" or "diff of diffs" option enabled in settings or via a tiny checkbox visible in the currently displayed diff view, the user will be allowed to choose 4 commits in sequence: 1) A 2) B 3) C 4) D

resulting in git range-diff A..B C..D

Solution 2) Introduce new keyboard modifier for said commits 1) normal click chooses A 2) CTRL + click chooses B 3) SHIFT + click chooses C 4) ALT + click chooses D

Solution 3) This is similar to how Google Spreadsheet does it or even File Explorer under Windows, where CTRL can be used to start subsequent groups. 1) A: normal click 2) B: SHIFT + click (shift denotes range select) 3) C: CTRL + click (ctrl denotes new group) 4) D: CTRL + SHIFT + click (shift (while ctrl) denotes range select in latest group) git-graph-test