dahlbyk / posh-git

A PowerShell environment for Git
http://dahlbyk.github.io/posh-git/
MIT License
7.59k stars 801 forks source link

PoshGit / ugit Compatibility Issues #912

Open StartAutomating opened 2 years ago

StartAutomating commented 2 years ago

System Details

Issue Description

posh-git has a compatibility issue with ugit.

This is because ugit overrides git with a PowerShell command.

While this does support any number of arguments, PowerShell can get confused when dealing with short argument names.

Thus line 331 in Get-GitStatus blows up the prompt.

The solution for this works just fine if ugit is loaded or not.

Quote the single character arguments:

git --no-optional-locks '-c' core.quotepath=false '-c' color.status=false status $untrackedFilesOption --short --branch 2>$null

Since posh-git is already very useful, but doesn't return git naturally as objects, it makes sense for both modules to work together in concert.

dahlbyk commented 2 years ago

Since posh-git is already very useful, but doesn't return git naturally as objects, it makes sense for both modules to work together in concert.

Agree! I'll ship a new version as soon as I can get a few lingering PRs merged.

StartAutomating commented 2 years ago

Cool!

It occurs to me that you might rely on git output being text in other places. So while this might have gotten rid of the most obvious breaking change, it's possible there are others.

It would be fairly trivial for you to save $executionContext.SessionState.InvokeCommand('git','Application') into a variable, and call that explicitly in your scripts (it's the trick ugit is doing under the hood).

Doing this should prevent any future hijinks.

dahlbyk commented 2 years ago

It would be fairly trivial for you to save $executionContext.SessionState.InvokeCommand('git','Application') into a variable

I assume you mean InvokeCommand.GetCommand('git', 'Application'). Would this be more efficient than Get-Command git -CommandType Application?

StartAutomating commented 2 years ago

Sorry for the delay in response (and the typo).

Yes, $executionContext is faster than Get-Command. I'll add a Benchmark on this to Benchpress.

On my box, here's what the results were:

Technique Time RelativeSpeed Throughput
$executionContext 00:00:00.198679 1x 503.32/s
Get-Command 00:00:00.266019 1.34x 375.91/s
charltonstanley commented 1 year ago

It's so cool to see two awesome projects collaborating together! :smile: I'm looking forward to when this fix will be released as it is affecting me as well right now.