sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.57k stars 101 forks source link

:DiffviewFileHistory % to also show changes against head #443

Closed mangelozzi closed 6 months ago

mangelozzi commented 7 months ago

Description

This is not a bug, but more of a feature request, if it not already possible.

It's a great feature to be able to see all the changes to a certain file with :DiffviewFileHistory %, however if would be great if it also showed the changes against head that arent committed yet.

Maybe this is possible but I could not figure it out. The closest thing I could find is --range=origin..HEAD but did not work. The docs say :

Diff the working tree against the index:
            :DiffviewOpen

But :DiffviewOpen % seems to diff only the commit history, does not have an entry for files that are saved, and not yet staged against HEAD?

Expected behavior

No response

Actual behavior

N/A

Steps to reproduce

N/A

Health check

N/A

Log info

N/A

Neovim version

N/A

Operating system and version

Ubuntu 22.04

Minimal config

N/A
sindrets commented 7 months ago

:DiffviewOpen with no rev args gives you the diff between the index and the working tree. By default this includes untracked files as well.

If you want to do this for one specific file, you can specify that as a path argument after the end-of-options token, as documented in the docs:

:DiffviewOpen -- some/path/to/a/file

" Current file:
:DiffviewOpen -- %

You can't show uncommitted changes in :DiffviewFileHistory, as this is a porcelain interface for git log, and it doesn't do that.

You can however set a custom base to compare against. That will make the right side of the diff always be a representation from whatever base rev you specify. And here we do support a special non-standard rev to represent the working tree: LOCAL. This isn't what you describe in your issue, but it could be useful to you nonetheless:

:DiffviewFileHistory --base=LOCAL %