wfxr / forgit

:zzz: A utility tool powered by fzf for using git interactively.
MIT License
4.32k stars 136 forks source link

Fix infinite loop when passing invalid arguments to gsp #316

Closed sandr01d closed 11 months ago

sandr01d commented 1 year ago

Check list

Description

Passing invalid arguments to _forgit_stash_push results in an infinite loop printing gits error message. You can test this by running gsp -b. With this PR we only print the error message once and return gits exit code.

Type of change

Test environment

sandr01d commented 12 months ago

I agree with you, I prefer to have the error message. Also there are a few functions were we already do return in case of an error, so refactoring this would make things more consistent. There is an exception to this: In gbl we actually make use of this behavior. We do not return in case git blame returned an error, but use the parameters later on. This allows things like gbl --color-by-age. I do something similar in #317. In those cases we could just check whether all passed arguments are flags and only invoke the git command without fzf if there were non-flag parameters passed. I can update #317 accordingly. Would you prefer to have a separate PR for the refactoring or have this included in this one?

carlfriedrich commented 12 months ago

@sandr01d That sounds totally reasonable and I like the idea of checking for flags. IMO you can merge #317 directly and then do a follow up PR to do the refactoring. Thanks for your work on this!

sandr01d commented 11 months ago

Closing in favor of #318