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

Pass "git.exe" instead of "git" to Get-Command #478

Merged
merged 1 commit into from
Jul 10, 2017

Conversation

mikesigs
Copy link
Contributor

Passing just "git" to get-command causes the script to fail if you have an alias called "git". For example, I have hub installed , which recommends aliasing git=hub. However, after doing this it breaks this posh-git script because get-command git returns the new alias which has no path.

Running get-command git returns:
CommandType Name Version Source

-----------     ----                                               -------    ------
Alias           git -> hub.exe

But get-command git.exe returns:
CommandType Name Version Source

-----------     ----                                               -------    ------
Application     git.exe                                            2.13.2.1   C:\Program Files\Git\cmd\git.exe

Passing just "git" to get-command causes the script to fail if you have an alias called "git". For example, I have hub installed (https://github.com/github/hub), which recommends aliasing git=hub. However, after doing this it breaks this posh-git script because `get-command git` returns the new alias which has no path.

Running `get-command git` returns:
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           git -> hub.exe

But `get-command git.exe` returns:
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     git.exe                                            2.13.2.1   C:\Program Files\Git\cmd\git.exe
@mikesigs mikesigs changed the title Search for "git.exe" instead of "git" Pass "git.exe" instead of "git" to Get-Command Jul 10, 2017
@dahlbyk dahlbyk merged commit 8bfcf1e into dahlbyk:develop Jul 10, 2017
@mikesigs mikesigs deleted the patch-2 branch July 10, 2017 22:40
@dahlbyk
Copy link
Owner

dahlbyk commented Jul 10, 2017

This works for me. There's a small chance this is a regression for folks with an older version of Git, which may have only put git.cmd in $PATH, but I'm content to test that in production.

@dahlbyk
Copy link
Owner

dahlbyk commented Jul 10, 2017

(Thanks!)

@mikesigs
Copy link
Contributor Author

mikesigs commented Jul 10, 2017 via email

@dahlbyk
Copy link
Owner

dahlbyk commented Jul 10, 2017

I expect Get-Command git.exe,git.cmd -ErrorAction SilentlyContinue would do the trick?

@mikesigs
Copy link
Contributor Author

mikesigs commented Jul 10, 2017 via email

mikesigs added a commit to mikesigs/posh-git that referenced this pull request Jul 10, 2017
Related dahlbyk#478. This is a better fix. By specifying the CommandType as Application we can continue looking for `git` (exe or cmd) but avoiding any potential aliases the user may have created for "git".
@rkeithhill
Copy link
Collaborator

rkeithhill commented Jul 10, 2017

Unfortunately this (original fix in this PR) won't work when running posh-git on PS Core on Linux / macOS:

image

@rkeithhill
Copy link
Collaborator

rkeithhill commented Jul 10, 2017

A better fix for this is to use the -CommandType Application parameter. Hehe, sorry I didn't see you last comment. Yup, much better fix.

dahlbyk pushed a commit that referenced this pull request Jan 10, 2018
Related #478. This is a better fix. By specifying the CommandType as Application we can continue looking for `git` (exe or cmd) but avoiding any potential aliases the user may have created for "git".
@dahlbyk dahlbyk mentioned this pull request Jan 10, 2018
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

Successfully merging this pull request may close these issues.

3 participants