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

Q: Using non-default git args #445

Closed VRehnberg closed 7 months ago

VRehnberg commented 7 months ago

There is the default_args config option which seems to do what I'd like, but I want to be able to send some args to git in only a few situations.

From the name it seems there should be a way to be able to use non-default args.


Concretely what I would like to do is to have a alias or something which is DiffviewOpen with a separate set of default args or possibly a possibility to send git args as an option to diffviewcommands.

sindrets commented 7 months ago

For the sake of clarity: the default_args - as documented - are vim command args that will always be prepended to the argument list when you invoke the command in question. So if you have

{
  default_args = {
    DiffviewOpen = { "foo", "bar" },
  }
}

and you invoke

:DiffviewOpen baz

the command will expand to

:DiffviewOpen foo bar baz

If you wish to pass arguments directly to Git, you should see the :h diffview-config-git_cmd config option.


If you wish to create a "command alias", you can just create a user command (:h user-commands). Example:

:command MyDiffview DiffviewOpen --imply-local origin/HEAD...HEAD

" Then you can use it like:
:MyDiffview
VRehnberg commented 7 months ago

Thanks, while it seems I could have had a command that temporarily uses a different set-up for diffview.nvim, the solution I went with was to temporarily set git environment variables instead.

https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables