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

PoshGit / ugit Compatibility Issues #912

Open
StartAutomating opened this issue Jul 9, 2022 · 5 comments
Open

PoshGit / ugit Compatibility Issues #912

StartAutomating opened this issue Jul 9, 2022 · 5 comments

Comments

@StartAutomating
Copy link

StartAutomating commented Jul 9, 2022

System Details

  • posh-git version/path: 1.1.0 ~\Documents\PowerShell\Modules\posh-git\1.1.0
  • PowerShell version: 7.2.5
  • git version 2.35.1.windows.2
  • OS: Microsoft Windows NT 10.0.22000.0

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.

@StartAutomating StartAutomating changed the title PoshGit PoshGit / ugit Compatibility Issues Jul 9, 2022
StartAutomating pushed a commit to StartAutomating/posh-git that referenced this issue Jul 9, 2022
dahlbyk added a commit that referenced this issue Jul 13, 2022
Updating GitUtils.ps1: (Fixing ugit compatibility issue #912)
@dahlbyk
Copy link
Owner

dahlbyk commented Jul 14, 2022

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
Copy link
Author

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
Copy link
Owner

dahlbyk commented Jul 14, 2022

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
Copy link
Author

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
Copy link

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

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

No branches or pull requests

3 participants