rbong / vim-flog

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

:Flog -patch not working? #129

Closed ferdinandyb closed 2 months ago

ferdinandyb commented 2 months ago

I would have assumed running :Flog -patch vs :Flog would have resulted in somehow the patches showing in the Flog buffer but it doesn't seem to change anything as far as I can tell.

rbong commented 2 months ago

Thanks for reporting this.

The way it works right now is that when you pass -no-patch to :Flog, it passes --no-patch to git log, however -patch is considered the default, so it doesn't pass --patch when -patch is specified.

The use case considered was for options that enable --patch by default, such as when you pass a range to Flog with -limit=....

I will rework this option to work in either case. Thanks again.

rbong commented 2 months ago

This is now implemented.

The "gp" binding still toggles between "--no-patch"/default. This is because, according to my testing, "-patch" can crash Vim with large or even medium-size repositories, and I don't want to add a two-button binding that insta-crashes Vim.

By using "Flogsetargs -patch=" (no argument after "="), the behaviour can be set to default rather than passing "--patch" or "--no-patch". If you use "Flogsetargs", this is the recommended way to turn off/on the option to avoid crashes.

I am leaving this ticket open to potentially deal with the performance issues and improve the implementation. It's unlikely that we can avoid the performance issues in the first place, but maybe we can detect especially long output and do something clever?

ferdinandyb commented 2 months ago

Thanks! It works. At first I was surprised that in literally only added the patch (I've never before used --patch with --oneline), but it is logical :)

rbong commented 2 months ago

Testing with the new -default-collapsed option, it seems to keep -patch from crashing Vim with lots of lines.

This is surprising to me, and I still have to dig into why this is happening, but if you want to run -patch, I recommend using this option. If it's unavoidable, I'd like to add some options to automatically collapse commits that are too long or if commits are too long as a whole, but hopefully I can just plain fix it.

rbong commented 2 months ago

Haven't yet altered the -patch behaviour, but I fixed the crash. It was a Neovim-specific performance issue.

rbong commented 2 months ago

Now that the performance issue is fixed, I changed it so that gp essentially toggles -patch on/off rather than off/default.

I try to be clever about it. So if -limit= is set, which implies -patch, it will toggle between off/default, but if it is not set, it will toggle between on/default.

This has the advantage that if you clear limit using :Flogsetargs, it won't override the new implied value of -patch. The downside is it won't work as expected if --patch is implied using -raw-args.

If there are any issues with the new implementation, please open a new ticket.