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

Improve performance for git prompts (on PowerShell) #4880

Open
1 task done
brian6932 opened this issue Apr 28, 2024 · 6 comments
Open
1 task done

Improve performance for git prompts (on PowerShell) #4880

brian6932 opened this issue Apr 28, 2024 · 6 comments
Assignees
Labels
🚀 feat New feature

Comments

@brian6932
Copy link
Contributor

brian6932 commented Apr 28, 2024

Code of Conduct

  • I agree to follow this project's Code of Conduct

What would you like to see changed/added?

posh-git's not really maintained, there has been an open PR to improve the git status performance for quite some time (dahlbyk/posh-git#924). It's currently extremely sluggish (yes even with "ignore_submodules":{"*":"none"}). Realistically to have consistent performance across all supported shells, it would be nice for oh-my-posh to have it's own git status handling, either with git-status-cache or with it's own cache. Since that's a bit more involved, a quick solution for now would be to use https://github.com/zhengweidi/git-status-cache-posh-client/tree/master with https://github.com/zhengweidi/git-status-cache/tree/master, or something like gitstatusd https://github.com/romkatv/gitstatus.

@ivan-the-terrible
Copy link
Contributor

ivan-the-terrible commented May 2, 2024

Currently doing some reading about this. I like the note that's here on romkatv gitstatus README's Why Fast. This does make a lot of sense and I might seek to replicate the scenario used in the benchmarks.

I also understand the idea behind the PRs you listed from posh-git PR 924 using Get-GitConciseStatusFromCache (which is defined here).

There is a oh-my-posh does have a cache declared within the JSON file at AppData\Local\oh-my-posh\omp.cache.
image

Here is the setGitStatus function where the cache might be implemented:

image

Will dig further into the codebase to see what can be done and maybe put out a PR.

@ivan-the-terrible
Copy link
Contributor

@brian6932 what would be really cool is if there is a Go package available with the logic :)
If you could poke around to find one, that would be extremely helpful.

@brian6932
Copy link
Contributor Author

There's https://github.com/go-git/go-git I guess, you'd have to implement the caching on top of it, or just use the code from https://github.com/go-git/go-git/blob/master/status.go and work from there, as it'd reduce dependencies.

@JanDeDobbeleer
Copy link
Owner

JanDeDobbeleer commented May 2, 2024

Go git is terribly slow, tried it before. I don't mind adding support for existing cache tools, I'm not in favor of adding logic that aims to do what git itself should improve (faster status).

@brian6932
Copy link
Contributor Author

brian6932 commented May 2, 2024

I found starship (which uses gitoxide) to have a relatively performant git status prompt (https://github.com/mcwarman/starship/tree/feature/detailed-github-status), only thing's that submodules have to be disabled ([git_status] ignore_submodules = true), or else it becomes extremely slow, so it's definitely not impossible to parse git status from .git quicker.

@JanDeDobbeleer
Copy link
Owner

JanDeDobbeleer commented May 2, 2024

@brian6932 check, but as a maintainer, I need to be careful how far this can get pushed. And that's an implementation where I want to be in the lead so I can also keep offering support. It's not easy or straightforward or git would've fixed it already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 feat New feature
Projects
None yet
Development

No branches or pull requests

3 participants