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

Version Control Actions #6101

Open
helmesjo opened this issue Feb 25, 2023 · 2 comments
Open

Version Control Actions #6101

helmesjo opened this issue Feb 25, 2023 · 2 comments
Labels
C-enhancement Category: Improvements

Comments

@helmesjo
Copy link

helmesjo commented Feb 25, 2023

In the same spirit as <space>-a (perform code action) it would be a nice addition to have something similar for version control.
There already is support for highlighting code changes, but then also having for example <space>-v for perform version action (just picked some unused char) to get a list of possible version control actions for a line (eg. stage/unstage, discard etc.) would be a great addition IMO (which quite naturally can be made generic to work with different VCS). Obviously the exposed functionality can start small and grow. This would require some pondering regarding reload and how that should be handled (maybe just a warning that reload will be performed, or a second This will reload current buffer, continue? [Y/n]: confirmation could be enough).

I tried looking through the docs and issues, but didn't find it being mentioned (possible I didn't look hard enough).

@helmesjo helmesjo added the C-enhancement Category: Improvements label Feb 25, 2023
@pascalkuthe
Copy link
Member

I was planning to go in a different direction and implement all vcs features in term of generic commands.
Many VCS features can be expressed in terms of generic operations on a diff:

  • reset a line is already implemented in Add command for resetting diff hunks #5736 and is completely independent from the source of the diff
  • staging and upstaging can be implemented in terms of opening the stashed version of the file in a buffer side by side diff version of the buffer on which you can perform :diffget and :diffput commands (like in nvim). In the longterm I want to switch the diff to be performed against the stage by default (See discussion in Allow VCS diffing to ignore staged changes #5825) and once the diffmode is added, staging changes would involve just opening the diffmode, and doing :diffput (possibly bound to a hotkey). Right now :diffget only operators on the primary cursor, it might be good to extend it to work on all hunks that either fully contain or are fully contained in a selection so %:diffget can reset the entire file.
  • a blame is also decently vcs independent (all you need is an iterator of file version) but that is better implemented as a command, I am not sure how to best add a UI here tough

@telemenar
Copy link

telemenar commented May 8, 2023

In terms of an idea for the UI for blame. Similar to the presentation you get in github on the web, the vim plugin tpope/vim-fugitive does a similar blame presentation:
vim-fugitive-blame

Though the thing that I find the most powerful in blame mode are the additional actions you have from that mode:

  • Open Commit for current line (presuming you have something like Git commit picker #5292)
  • Open file in blame mode at commit version for current line
  • Open file in blame mode prior to commit version for current line

I've found this ability to interact with the history of a file amazing to help understand why code ended up the way that it is. It is also the sort of action that is fantastically easier to do in an editor than it is to do with a tool in the cli next to your editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

3 participants