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

Added a check for stash before executing git stash list for performance #158

Closed
wants to merge 1 commit into from
Closed

Added a check for stash before executing git stash list for performance #158

wants to merge 1 commit into from

Conversation

82phil
Copy link

@82phil 82phil commented Dec 10, 2019

Background

I noticed that when in Git repositories the prompt would delay for roughly a half a second before returning.

image

Running WSL1 on the Windows 1909 release, other version details:

$ git --version
git version 2.17.1
$ lsb_release -a
…
Description:    Ubuntu 18.04.1 LTS

Also somewhat discussed in issue #129 - Latency

Investigation

I walked segment-git.go and tried out the commands it would issue. That is where I found that git stash list takes considerably longer.

Diving into the source for Git (for the 2.17 release) I found that git stash would call a shell script that added overhead. I also found the script provides a quick method to check if a stash existed, see https://github.com/git/git/blob/6e9e91e9cae74cd7feb9300563d40361b2b17dd2/git-stash.sh#L379

Changes

I simply added the check for a stash. The command raises an error if there is no stash.

This also means that if a stash exists, performance will regress
image

@justjanne justjanne closed this Dec 12, 2019
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 this pull request may close these issues.

2 participants