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

git prompt is very slow #139

Open
pasankg opened this issue Dec 2, 2019 · 3 comments · Fixed by #145
Open

git prompt is very slow #139

pasankg opened this issue Dec 2, 2019 · 3 comments · Fixed by #145

Comments

@pasankg
Copy link

pasankg commented Dec 2, 2019

Executing commands on the command line takes a couple of seconds more when oh-my-git is enabled in a repository.
With oh-my-git enables running time git st

real	0m1.837s
user	0m0.421s
sys	0m8.548s

And without oh-my-git on the same repo

real	0m1.473s
user	0m0.397s
sys	0m4.889s

Also just hitting enter on the cmd line it takes about 3 seconds for the prompt to release.
I tried in my mac terminal and iTerm2 and results were the same.

Any suggestions to fix this please.
Thank you.

@p-himik
Copy link

p-himik commented Apr 21, 2022

The slowest part on my end seems to be the one that computes the amount of commits ahead/behind the upstream at https://github.com/arialdomartini/oh-my-git/blob/master/base.sh#L91-L95.

It can be dramatically improved by using this instead:

        if [[ $has_upstream == true ]]; then
            local commits_ahead commits_behind
            read -r commits_behind commits_ahead <<<$(git rev-list --left-right --count ${current_commit_hash}...${upstream} 2> /dev/null)
        fi

@p-himik
Copy link

p-himik commented Apr 22, 2022

@arialdomartini Thanks for merging! But I've belatedly realized that, I think, there's an error there - commits_behind and commits_ahead are mixed up, the order should be different. Could you please check?

@arialdomartini
Copy link
Owner

@p-himik good catch! You are right.
I fixed that.

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

Successfully merging a pull request may close this issue.

3 participants