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

Powershell 7.3.0 does not show posh-git status bar #932

Closed
alexanderwallau opened this issue Nov 21, 2022 · 7 comments
Closed

Powershell 7.3.0 does not show posh-git status bar #932

alexanderwallau opened this issue Nov 21, 2022 · 7 comments

Comments

@alexanderwallau
Copy link

System Details

  • posh-git version/path:
  • PowerShell version: 7.3.0
  • Git version: 2.37.1.windows.1
  • Operating system name and version: [Version 10.0.19045.2251]

Issue Description

I am experiencing a problem with Powershell 7.30 in windows terminal (ver 1.15.2875.0) specifically that the status bar oes not appear in folders with git repository.
Troubleshooting done so far:

  • Un-&Reinstalled git, Windows Terminal and posh-git
  • Checked Execution-Policies; posh-git is loded correctly

My suspision would be that the methods to add the status bar to the PowerShell promt have changed because of the autotabbing for git working as usual.

@juliank
Copy link

juliank commented Nov 24, 2022

I can confirm the same issue with the same versions mentioned above.

My temporary workaround is to use the Windows PowerShell profile (being version 5.1.19041) within Windows Terminal, instead of PowerShell (Core). The posh-git status bar shows as expected there.

@lewis-hu
Copy link

lewis-hu commented Dec 1, 2022

When I turned on tracing, I found that this line is not setting the status variable at all:

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

@tsposato
Copy link

tsposato commented Dec 2, 2022

Same issue here with PowerShell 7.3.0

@seanblue
Copy link

I'm using PowerShell 7.3.1 and seeing the same issue.

@tcomben
Copy link

tcomben commented Dec 29, 2022

I think I found a workaround. If you replace lines 326-331 in ./src/GitUtils.ps1 with the code below, it works. For some reason, I needed to get rid of the "2" after the branch argument in the status command, as well as the ">$null". Git doesn't like having an empty string in the pathspec argument either, hence not including $untrackedFilesOption when it's empty.

posh-git/src/GitUtils.ps1

Lines 326 to 331 in b8c1f17

switch ($settings.UntrackedFilesMode) {
"No" { $untrackedFilesOption = "-uno" }
"All" { $untrackedFilesOption = "-uall" }
default { $untrackedFilesOption = "-unormal" }
}
$status = Invoke-Utf8ConsoleCommand { git --no-optional-locks '-c' core.quotepath=false '-c' color.status=false status $untrackedFilesOption --short --branch 2>$null }

$psMajor = $($PSVersionTable.PSVersion.Major) -as [int]
$psMinor = $($PSVersionTable.PSVersion.Minor) -as [int]

$status = $null
$untrackedFilesOption = if ($settings.UntrackedFilesMode) { "-u$($settings.UntrackedFilesMode)" } else { "" }
if (($psMajor -ge 7 -and $psMinor -ge 3) -or $psMajor -gt 7) {
    if ($untrackedFilesOption.Length -gt 0) {
        $status = Invoke-Utf8ConsoleCommand { git -c core.quotepath=false -c color.status=false status $untrackedFilesOption --short --branch }
    }
    else {
        $status = Invoke-Utf8ConsoleCommand { git -c core.quotepath=false -c color.status=false status --short --branch }
    }
}
else {
    $status = Invoke-Utf8ConsoleCommand { git -c core.quotepath=false -c color.status=false status $untrackedFilesOption --short --branch 2>$null }
}

@inspektor99
Copy link

inspektor99 commented Jan 4, 2023

I think I found a workaround. If you replace lines 326-331 in ./src/GitUtils.ps1 with the code below, it works. For some reason, I needed to get rid of the "2" after the branch argument in the status command, as well as the ">$null". Git doesn't like having an empty string in the pathspec argument either, hence not including $untrackedFilesOption when it's empty.

posh-git/src/GitUtils.ps1

Lines 326 to 331 in b8c1f17

switch ($settings.UntrackedFilesMode) {
"No" { $untrackedFilesOption = "-uno" }
"All" { $untrackedFilesOption = "-uall" }
default { $untrackedFilesOption = "-unormal" }
}
$status = Invoke-Utf8ConsoleCommand { git --no-optional-locks '-c' core.quotepath=false '-c' color.status=false status $untrackedFilesOption --short --branch 2>$null }

$psMajor = $($PSVersionTable.PSVersion.Major) -as [int]
$psMinor = $($PSVersionTable.PSVersion.Minor) -as [int]

$status = $null
$untrackedFilesOption = if ($settings.UntrackedFilesMode) { "-u$($settings.UntrackedFilesMode)" } else { "" }
if (($psMajor -ge 7 -and $psMinor -ge 3) -or $psMajor -gt 7) {
    if ($untrackedFilesOption.Length -gt 0) {
        $status = Invoke-Utf8ConsoleCommand { git -c core.quotepath=false -c color.status=false status $untrackedFilesOption --short --branch }
    }
    else {
        $status = Invoke-Utf8ConsoleCommand { git -c core.quotepath=false -c color.status=false status --short --branch }
    }
}
else {
    $status = Invoke-Utf8ConsoleCommand { git -c core.quotepath=false -c color.status=false status $untrackedFilesOption --short --branch 2>$null }
}

Confirmed fixed in PS 7.3.x, also works in previous versions.

My code replacement in GitUtils.ps1 was slightly different:

Replace this line (236ish) with @tcomben s fix:

$status = Invoke-Utf8ConsoleCommand { git -c core.quotepath=false -c color.status=false status $untrackedFilesOption --short --branch 2>$null }

@lewis-hu
Copy link

lewis-hu commented May 14, 2023

I realised I encountered this issue because I installed poshgit using chocolatey, which, according to https://community.chocolatey.org/packages/poshgit, it's latest version stalled at 0.7.3.1.

Installing latest via

git clone https://github.com/dahlbyk/posh-git.git && .\install.ps1

fixed it for me.

Reference:

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

7 participants