vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Git - support HEAD <> working tree changes in gutter

Open TallGirlVanessa opened this issue 7 years ago • 37 comments
trafficstars

Issue Type: Feature Request

I'd like to see staged changes as well as unstaged changes in the gutter. Currently, VS Code only shows unstaged changes, at least when using Git.

Unstaged changes: fikcx

Staged changes: b6y38

See https://stackoverflow.com/questions/48881124/can-i-make-visual-studio-code-highlight-staged-changes as well as https://github.com/eamodio/vscode-gitlens/issues/396 .

VS Code version: Code 1.28.0 (431ef9da3cf88a7e164f9d33bf62695e07c6c2a9, 2018-10-04T16:40:40.180Z) OS version: Darwin x64 16.7.0

TallGirlVanessa avatar Oct 09 '18 20:10 TallGirlVanessa

When you're editing a file in git, there are three versions of it:

  • HEAD
  • Index
  • Working tree

So, there are two possible diffs to show:

  • HEAD <> Index
  • Index <> Working Tree

We currently show gutter decorations for Index <> Working Tree. Since the file which is open in the editor is always Working Tree, it doesn't make any sense to show HEAD <> Index changes in the gutter, since none of those two files is Working Tree.

joaomoreno avatar Oct 10 '18 07:10 joaomoreno

I get what you're saying, and recognize that this probably won't be read on a closed issue 😅 But, IntelliJ manages to make this work. So I have a hard time accepting that the feature doesn't make sense!

I see a third diff you haven't mentioned, which is HEAD <> Working Tree. That's exactly what I'm looking for, and that's what IntelliJ does too.

TallGirlVanessa avatar Oct 18 '18 14:10 TallGirlVanessa

Actually, because IntelliJ manages to do this, they actually end up having a confusing experience.

image

In this case, one of the changes is staged in the index, the other isn't. Which one is which? Also, when a change in the index intersects a change in the working tree, what do you actually show?

We can think about supporting a setting which toggles the dirty diff decorations to HEAD <> Working Tree and backwards... I wonder if there's enough need for it tho.

joaomoreno avatar Oct 18 '18 22:10 joaomoreno

I like how it works in IntelliJ: I often stage parts that I definitely want to commit, and to allow me to experiment with temporary changes and still have the ability to reset those without losing the staged changes. In the editor I still see changed lines and can quickly jump between them with "Ctrl+Alt+Shift+Up/Down" which allows for a very fluid editing experience.

fabb avatar Nov 30 '18 10:11 fabb

I have the same workflow as @fabb and would appreciate the toggle you mentioned @joaomoreno .

I agree there's ambiguity in the IDE in the approach I'm asking for. Speaking for myself, I only stage and commit from the command line, so ambiguity in the IDE between staged and unstaged doesn't bother me.

Here's the flow that led me to write this issue:

  1. Make some changes
  2. Test the changes
  3. Stage those changes
  4. Look over the working tree <> HEAD diff using the IDE
  5. Do last minute cleanup while I'm going through the diff, deleting extra newlines, removing unused imports, resolving lint errors
  6. Use the command line to double check my unstaged changes, to see whether I need to retest. If they're all trivial I can stage and continue. If they're not I need to test again.
  7. Stage
  8. Use the command line to look over what I staged
  9. Commit

When I tried this flow with VSCode I got stuck at step 4 because all my changes were no longer visible!

TallGirlVanessa avatar Nov 30 '18 15:11 TallGirlVanessa

It would be great to see staged changes in a different color at least "when": "textCompareEditorVisible && isInDiffEditor". That way we know what we are staging when we stage part of changes.

ilteris avatar Dec 15 '18 02:12 ilteris

@ilteris I agree. I can see adds, removals, changes, and even inline diffs; I feel like I shouldn't have to use another program just to see what is staged.

I don't even necessarily think it needs to have a separate color for staged changes (though that would be intuitive); for example, the GitGutter plugin for Sublime Text continues to show the status of lines even when they're staged, and defers the (un)staged status to the command line.

@joaomoreno an alternative example of the need for this is that when all changes of a file are staged, the file in VSCode looks the same as a file that is already committed.

geoffdavis92 avatar Jan 22 '19 17:01 geoffdavis92

Adding some perspective, this is the default behavior in Atom and can be configured in Sublime Text.

trkoch avatar Mar 29 '19 13:03 trkoch

I can see adding an option might confuse some users (even when disabled by default), on the other hand it disrupts the workflow of all users actively (and consciously) using the index as a in-between area of changes. For example, a possible workflow is to add changes to the index when everything is working as expected and all tests are green, right before any cleanup refactoring.

@joaomoreno I tried to take a look at the source but lost track eventually. Could you provide some hints what kind of changes are needed?

trkoch avatar Mar 29 '19 18:03 trkoch

I want to argue (pretty strongly, but lightheartedly) that IntelliJ behavior is the right default here.

Actually, because IntelliJ manages to do this, they actually end up having a confusing experience. In this case, one of the changes is staged in the index, the other isn't. Which one is which?

Note that you are only interested about "what's in the index", when you are making a commit. That is, this is a valuable info to show in the commit dialog.

When you are just hacking and making changes, you don't really care about what's in the index, you need to know which changes have you applied.

So, IntelliJ does (roughly) show what's in the index in the commit dialog:

image

Now, one can argue that IntelliJ is not a pinnacle of VCS integration design, however Emacs obviously is (/s). And Emacs (diff-hl and Magit) works exactly as described:

image

In the editor gutter, we see what is changed relative to HEAD. In the commit dialog, we clearly see whats in the index, and what's not in the index.

matklad avatar Jan 17 '20 12:01 matklad

Maybe we should we should have another gutter indicator for changes that are staged? (after having been git added) Example: stripes.

image

Please note this is a terrible mspaint (and specifically, kolourpaint) job but it shows the idea.

Nowaker avatar Apr 06 '20 22:04 Nowaker

@joaomoreno Can you review the proposed design above? What do you think? People seem to like it, given the number of upvotes it received.

Nowaker avatar Jan 02 '21 06:01 Nowaker

Would also be nice if one could do a diff between HEAD <> Working Tree as well. That would allow editing while seeing changes relative to HEAD (what I think users are practically asking for in #91065, #91274, #74149, #15785, and #33681). The various text editors listed above also support this as well (e.g. IntelliJ, Sublime, fugitive).

studgeek avatar Feb 05 '21 20:02 studgeek

I think easiest first step would be adding the ability to switch gutter bar diffs from current "Index <> Working Tree" to "HEAD <> Working Tree" and back. That is what @vlmphipps and @joaomoreno suggest early in the thread. It's also I believe what the other mentioned IDEs do.

The double gutter that @Nowaker mentioned is interesting, but I think its worth pointing out that it may be a bit trickier than it sounds on the surface. I assume it would be displaying Working Tree and would show gutters for both "HEAD <> Working Tree" and "Index <> Working Tree". The challenge is Working Set isn't always a superset of Index like that example image shows. HEAD, Index, and Working Tree can actually be very different. For example, it's possible for a file to exist in Working Tree and HEAD, but not exist in Index (or the reverse). I think it's still possible to do the double gutter diff, but each gutter diff ("HEAD <> Working Tree" and "Index <> Working Tree") would need to be its own column rather than mixed as shown in the proposed screenshot.

studgeek avatar Feb 11 '21 15:02 studgeek

After ages of using other editors that show "HEAD <> Working Tree" in the gutter, this is the 2nd most annoying feature of VSCode for me. (The feature that most annoys me in VSCode comes from extension, that I plan to fork somewhen in the future, but I digress)

Gutter should show the user what has been changed in the files, and was not committed yet. Anything else is just confusing for anybody that have worked with any other editor.

At the minimum you should add the option to let us choose what we want to compare our working tree to (in the case that you insist to keep the comparison to the index).

edit: typo

ivanpu avatar Mar 08 '21 16:03 ivanpu

+1 to the above comment.

would need to be its own column rather than mixed as shown in the proposed screenshot

@studgeek I see no problem with double column approach if warranted. Just saying most editors show a simplified view of things; maybe some sophisticated information gets lost but these are edge cases that aren't relevant for everyday use cases.

Nowaker avatar Mar 08 '21 16:03 Nowaker

| At the minimum you should add the option to let us choose what we want to compare our working tree to (in the case that you insist to keep the comparison to the index).

And this should not be just limited to Index and HEAD, but also base of your PR branch or any change in between. E.g. when you work on final clean-up of your patch queue.

mafjmafj avatar May 06 '21 09:05 mafjmafj

Well said, @mafjmafj! That's an absolute minimum.

And I'd love to see the below (or some variation thereof) as an ultimate goal:

image

Nowaker avatar May 06 '21 21:05 Nowaker

Step back comment: We work these days with focus on changes and change sets. And we need a tool that not only supports that but makes it a central focus.

mafjmafj avatar May 08 '21 11:05 mafjmafj

Hi @lszomoru, regariding your self-assignment, can we expect to have this at some point in the near future?

jolammi avatar Oct 05 '21 10:10 jolammi

@jolammi, the self-assignment was part of a bulk update due to a transfer of ownership of the SCM/git area.

lszomoru avatar Jan 05 '22 16:01 lszomoru

@joaomoreno said:

Actually, because IntelliJ manages to do this, they actually end up having a confusing experience ... In this case, one of the changes is staged in the index, the other isn't. Which one is which?

While this is true, the current functionality is also confusing for other reasons:

A gutter with no modifications [EDIT: unfortunately this 404s now. Hopefully the next paragraph paints the picture.]

In this case, one of the changes is staged in the index, the others are already committed. Which one is which?


I'm also confused about the state of this issue: is it waiting for someone to implement it, or are we still discussing whether this is a desired feature?

DanKaplanSES avatar Sep 08 '22 22:09 DanKaplanSES

Is this change going to happen?

ghost avatar Oct 07 '22 16:10 ghost

Looks like forgotten. VSCode is now focusing on AI, with little care given to the core features like this.

Nowaker avatar Jun 10 '23 01:06 Nowaker

This is still a wanted feature :pray:

ranger-ross avatar Feb 11 '24 12:02 ranger-ross

Related on Stack Overflow: Can I make Visual Studio Code highlight staged changes?

starball5 avatar Mar 28 '24 11:03 starball5

Hello , as the original top post suggested : by @TallGirlVanessa
this is must to have ... ( staged changes should be indicated !!! ) is this gonna happen ?

thanks

EdgarLip avatar Apr 17 '24 11:04 EdgarLip

I don't understand how this necessary functionality is still not added.

canyone2015 avatar May 07 '24 06:05 canyone2015

Hi, sorry to mention you @kieferrm, just wanted someone from the VSCode team to see this. Many people think this is an important improvement, and we really hope you can plan it someday. Thank you.

mgaineev avatar Jun 01 '24 19:06 mgaineev