gitsigns.nvim
gitsigns.nvim copied to clipboard
Extend `gitsigns.diffthis` for diff between index and HEAD
Hello Lewis! Thank you for a such a simple yet convenient plugin!
Is your feature request related to a problem? Please describe.
I often use gitsigns.diffthis
to compare current working tree to the index, and in my workflow, I usually stage my changes / hunks incrementally (parts of a feature, for example) as I work on a feature, before committing. As such, I use git diff --cached HEAD <file>
for this purpose (I got used to this feature while using VS Code long back).
One thing I had checked was -
- Open the index for a file using
show
function. - Tried to execute
diffthis HEAD
on the index file, but there was no change / no diff was opened.
Describe the solution you'd like
I am assuming there is a check which disallows diffthis
to work on index buffers, so I was wondering if it is possible to modify diffthis
function to work when the active buffer is the git index of a file.
Please let me know if this feature already is doable with the current plugin (probably something I missed), otherwise I do think this is a valuable addition to an already amazing plugin.
Additional context
I am hoping for something like this ; except the right side pane should be the git index of the file and not the file from the working tree.
Hey @lewis6991, I hope you're not busy. May I get a response? :)
This isn't possible at the moment but I plan to add diffthis support for any Gitsigns buffer.
So after you add that support, I can open the index for a file using show
and run diffthis HEAD
on the index buffer to get a git-diff between index and HEAD. Did I understand you correctly?
I was expecting this to be already possible from reading the docs:
diffthis({base}, {opts}) *gitsigns.diffthis()*
Perform a |vimdiff| on the given file with {base} if it is
given, or with the currently set base (index by default).
If {base} is the index, then the opened buffer is editable and
any written changes will update the index accordingly.
Parameters:
{base} (string|nil): Revision to diff against. Defaults
to index.
Examples:
" Diff against the index
:Gitsigns diffthis
" Diff against the last commit
:Gitsigns diffthis ~1
Does this mean that base can not be anything? I tried diffthis main
and nothing is shown.
Indeed something like that will be very convenient, without having to change the entire base
diffthis
only (currently) works on buffers of working copies.
diffthis
only (currently) works on buffers of working copies.
I don't understand what I mean. I have a working copy, and I want to compare it against its main verson
You can already do that: :Gitsigns diffthis main