wfxr / forgit

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

Fix branch preview for branches that have the same name as a file #374

Closed sandr01d closed 3 months ago

sandr01d commented 3 months ago

Check list

Description

The preview for branches (when using gbd or gcb) did not work for branches that have the same name as a file in the repository. The preview creates the following error message when adding a branch called 'LICENSE' to this repository and trying to preview it:

fatal: ambiguous argument 'LICENSE': both revision and filename                                                                                     

Use '--' to separate paths from revisions, like this:                                                                                               

'git <command> [<revision>...] -- [<file>...]'

This PR fixes this behavior by separating files and revisions with '--' as git suggests, while leaving the files blank to keep matching all files.

Type of change

Test environment

carlfriedrich commented 3 months ago

Good catch! Can reproduce the error, and the fix works for me. Thanks!