Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

posh-git prompt with detached head adds to $global:error.Count #27

Closed
dl1ely opened this issue Oct 7, 2016 · 8 comments
Closed

posh-git prompt with detached head adds to $global:error.Count #27

dl1ely opened this issue Oct 7, 2016 · 8 comments
Assignees

Comments

@dl1ely
Copy link

dl1ely commented Oct 7, 2016

I notice that $global:error.Count constantly increases when just pressing the return key in a git versioned directory with detached head:

 ☠ Pfeiffer.Stefan@NB24  ~\…\…\…\oh-my-posh   (46908d8...) ●  $global:error.Count
53
 ☠ Pfeiffer.Stefan@NB24  ~\…\…\…\oh-my-posh   (46908d8...) ●  $global:error.Count
55
 ☠ Pfeiffer.Stefan@NB24  ~\…\…\…\oh-my-posh   (46908d8...) ●  $global:error.Count
57
 ☠ Pfeiffer.Stefan@NB24  ~\…\…\…\oh-my-posh   (46908d8...) ● 

This triggers an perpetual display of the FailedCommand-Character (skull in my case). I could not reproduce that in other git versioned directories, so i assume it has to do with the detached head. Not sure if that is an posh-git-issue...

@JanDeDobbeleer
Copy link
Owner

JanDeDobbeleer commented Oct 7, 2016

I like the skull. I really do. But it's a posh-git error on this line.

git : fatal: no tag exactly matches '1aeab566491847616c8318584fc4ee5713ed0800'
At C:\Users\Jan\Documents\WindowsPowerShell\Modules\posh-git\GitUtils.ps1:57 char:39
+ ...            default { git describe --tags --exact-match HEAD 2>$null }
+                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (fatal: no tag e...c4ee5713ed0800':String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

This means we either create an issue over there (or a PR with a fix :-))

@dl1ely
Copy link
Author

dl1ely commented Oct 7, 2016

Thanks for analyzing that. My skills are too limited to submit a PR. Even submitting a proper issue is hard, i do not know to even get the error message you quoted on the screen.

@JanDeDobbeleer
Copy link
Owner

You can get the errors thrown in PowerShell by looking at the $error object. It's what I use to determine whether or not the last command failed ($lastexitcode is unreliable). I'm looking for a way to adjust those git commands in a way where they no longer throw an error but rather the commit hash. But that might break other stuff, so I have to dig a bit deeper 😎

@JanDeDobbeleer
Copy link
Owner

I looked at the code at bit more and I can't seem to find a solution for this. It will iterate over a few options and return the first one that does not return NULL. The problem is that the first one git symbolic-ref HEAD 2>$null returns NULL due to being detached. It will then do a describe to see if we checked out a tag and not find one (3 options are available) and add that error to $error. This is what we are seeing.

@JanDeDobbeleer
Copy link
Owner

I fixed it and created a PR over at posh-git.
If you want to fix it locally, check the changes in that PR ;-)

@dl1ely
Copy link
Author

dl1ely commented Oct 10, 2016

Thanks for not only fixing bugs in other projects but also educating me about Powershell along the way. 👍 I think the issue can be closed over here?

@JanDeDobbeleer
Copy link
Owner

I'd leave it open for people to find in case they notice the same issue. It won't be resolved until the PR is accepted at posh-git, which will not be anytime soon looking at their response times 😎.

And you are welcome!

@JanDeDobbeleer
Copy link
Owner

PR closed at posh-git.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

2 participants