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

Add option to hide stash #149

Open
SammysHP opened this issue Nov 15, 2024 · 4 comments
Open

Add option to hide stash #149

SammysHP opened this issue Nov 15, 2024 · 4 comments

Comments

@SammysHP
Copy link

SammysHP commented Nov 15, 2024

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
Copy link
Owner

rbong commented Nov 15, 2024

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:

  • Something like -exclude-stash-refs would work but that sets a new precedent and I want to think about it more.
  • We could also add -exclude. This would have the same issues as -raw-args, being overwritten if you use it for anything else, but at least it would allow you to use raw args for other things. Completion also would also be basic to start but that's a secondary issue.

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
Copy link
Author

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
Copy link
Owner

rbong commented Nov 15, 2024

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants