scmbreeze / scm_breeze

Adds numbered shortcuts to the output git status, and much more
https://madebynathan.com/2011/10/19/git-shortcuts-like-youve-never-seen-before/
MIT License
2.82k stars 192 forks source link

Getting an error when using `gb` shortcut. #293

Closed ryanhinton closed 4 years ago

ryanhinton commented 4 years ago

Hello, this is probably another bug for Windows users. Whenever I attempt to execute gb shortcut for git branch, I get the following error.

λ gb
bash: /c/Program: No such file or directory
<< was unexpected at this time.

Is there something I need to do with configuration files or is this a problem somewhere in the code by chance? I'm not sure why some shortcuts work and some do not.

Thank you for any feedback.

ryanhinton commented 4 years ago

Hmmm.... I'm now thinking this issue has nothing to do with SCM Breeze since even git branch produces the same error.

ghthor commented 4 years ago

Scm breeze sets a shell function for the value of git.

$ type git
git is a function
git () 
{ 
    case $1 in 
        commit | blame | add | log | rebase | merge | difftool)
            exec_scmb_expand_args "$_git_cmd" "$@"
        ;;
        checkout | diff | rm | reset)
            exec_scmb_expand_args --relative "$_git_cmd" "$@"
        ;;
        branch)
            _scmb_git_branch_shortcuts "${@:2}"
        ;;
        *)
            "$_git_cmd" "$@"
        ;;
    esac
}
$ which git
/usr/bin/git

Try$(which git) branch and see if the error goes away.

ghthor commented 4 years ago

This looks like the git branch support is messing up on windows.

ryanhinton commented 4 years ago

Thank you for your reply :-) I tried your recommendation, but receive the same error.

λ $(which git) branch
bash: /c/Program: No such file or directory
ghthor commented 4 years ago

Ok, so what type of bash environment are you using on windows? Looks like there is a path with a space /c/Program Files/.. that isn't being handled correctly.

On Fri, Aug 30, 2019 at 5:21 PM Ryan Hinton notifications@github.com wrote:

Thank you for your reply :-) I tried your recommendation, but receive the same error.

λ $(which git) branch

bash: /c/Program: No such file or directory

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/scmbreeze/scm_breeze/issues/293?email_source=notifications&email_token=AABHEKV6KLWUC3DHE6SK2O3QHGFNBA5CNFSM4ISPF6SKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5S2CGY#issuecomment-526754075, or mute the thread https://github.com/notifications/unsubscribe-auth/AABHEKRPKLXUKXFXPKLCNZ3QHGFNBANCNFSM4ISPF6SA .

ghthor commented 4 years ago

What is the output of which git

ryanhinton commented 4 years ago
λ which git
/c/Program Files/Git/bin/git
ghthor commented 4 years ago

Yep, that path with the space is messing this up. I don't know how to handle this to be honest, I'll have to look into this further. The error you are getting is likely coming from here. But anywhere with _git_cmd would need to be audited to ensure it supports path to executable with a space.

ghthor commented 4 years ago

The quick fix would be to reinstall your git to a filepath without a space.

ryanhinton commented 4 years ago

is that a part of SCM Breeze or Git itself?

ryanhinton commented 4 years ago

I think I'm able to trail through this. Let me see if I can fix it and possibly be able to make a PR, if that is possible?

ghthor commented 4 years ago

The function bin_path is what is returning the path with a space in it. We'd need to do some type of additional processing on the path there to make it support paths with spaces. =/

ryanhinton commented 4 years ago

I did try to make this work, but kept receiving various errors. I'm rather new to shell scripting. I thought it would be simply a search and replace to escape spaces with a backslash and space, but with limited time and knowledge, I could not make it work. Instead, I uninstalled Git and installed it to the C:\ root path rather than C:\Program Files. This allowed gb to work.