rbong / vim-flog

A blazingly fast, stunningly beautiful, exceptionally powerful git branch viewer for Vim/Neovim.
798 stars 23 forks source link

Add option to hide stash #149

Open SammysHP opened 1 week ago

SammysHP commented 1 week ago

When "all" mode is enabled, the log contains commits from the stash as well. Most users will probably consider the stash as something special and don't want to see it mixed together with "regular" commits.

Outside of vim/Flog my "git log" aliases include --exclude=refs/stash --all to exclude the stash. I'd like to see a similar option in Flog that can be set in g:flog(_permanent)_default_opts or a special variant of -all.

rbong commented 1 week ago

Workaround:

let g: flog_permanent_default_opts = {
  \ "raw_args": "--exclude=refs/stash",
  \ }

Known issue: if you use raw args combined with --all for anything else, raw args will get overwritten. We need an elegant solution for cases like this with raw args.

My thoughts on a potential native solution:

Potential solution to arguments getting overwritten:

We could add a setting that always prepends to certain args instead of allowing default values to be overwritten. This would work with either the workaround or the native -exclude solution:

# Always adds "--exclude=refs/stash" to the beginning of raw args, separating the rest with a space
let g: flog_prepended_default_opts = {
  \ "raw_args": "--exclude=refs/stash",
  \ }

# Effectively adds an -exclude=refs/stash arg at the start of the command
let g: flog_prepended_default_opts = {
  \ "exclude": ["refs/stash"],
  \ }

Let me know what you would think about this interface, particularly with -exclude because I think I want to add it.

SammysHP commented 1 week ago

Didn't know about raw_args, which might work here. On the other hand, exposing --exclude as a "native" -exclude sounds also nice.

We could add a setting that always prepends to certain args instead of allowing default values to be overwritten.

I think the fundamental issue is that there is no way to easily extend default options. Vim lets you +=add and -=remove option values. I don't know how difficult it would be to add something similar to the option parsing in Flog. Then you could simply do :Flog -exclude+=foo/bar and maintain the default options.

rbong commented 1 week ago

The += and -= proposal is interesting, and could be a potential new feature, but Flog arguments are ordered list, so the behaviour of -= could be confusing.

Also, I'm realizing I have to dig deeper into how other options interact with -exclude before I add it. I might want to add some other new flags at the same time.

SammysHP commented 5 days ago

Workaround:

Unfortunately not a workaround. Flog first appends --all to args and then raw_args afterwards. Filter expressions are position dependent and evaluation stops after the fist hit. If --all comes first, --exclude will be never evaluated.