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

Optimize the git command used to check stash #503

Conversation

ncs-msmith
Copy link
Contributor

Compare the output of GIT_TRACE=1 git rev-parse refs/stash
with GIT_TRACE=1 git stash list -n 1. Both return the most recent
saved stash, but rev-parse takes less time and fewer calls.

When there is no saved stash, rev-parse will return 'refs/stash',
so we need to filter that out.

Compare the output of `GIT_TRACE=1 git rev-parse refs/stash`
with `GIT_TRACE=1 git stash list -n 1`. Both return the most recent
saved stash, but rev-parse takes less time and fewer calls.

When there is no saved stash, rev-parse will return 'refs/stash',
so we need to filter that out.
@ncs-msmith
Copy link
Contributor Author

ncs-msmith commented Feb 14, 2017

[502640072:~/liquidprompt] feature/optimize-stash-marker+ 11m28s ± time GIT_TRACE=1 git stash list -n 1
02:15:50.425685 git.c:594               trace: exec: 'git-stash' 'list' '-n' '1'
02:15:50.426245 run-command.c:369       trace: run_command: 'git-stash' 'list' '-n' '1'
02:15:50.832859 git.c:594               trace: exec: 'git-sh-i18n--envsubst' '--variables' 'usage: $dashless $USAGE'
02:15:50.833651 run-command.c:369       trace: run_command: 'git-sh-i18n--envsubst' '--variables' 'usage: $dashless $USAGE'
02:15:51.231793 git.c:594               trace: exec: 'git-sh-i18n--envsubst' 'usage: $dashless $USAGE'
02:15:51.232424 run-command.c:369       trace: run_command: 'git-sh-i18n--envsubst' 'usage: $dashless $USAGE'
02:15:51.638833 git.c:371               trace: built-in: git 'rev-parse' '--git-dir'
02:15:51.837774 git.c:371               trace: built-in: git 'rev-parse' '--git-path' 'objects'
02:15:52.245130 git.c:371               trace: built-in: git 'rev-parse' '--show-toplevel'
02:15:52.457231 git.c:371               trace: built-in: git 'rev-parse' '--git-path' 'index'
02:15:52.653917 git.c:371               trace: built-in: git 'config' '--get-colorbool' 'color.interactive'
02:15:52.857751 git.c:371               trace: built-in: git 'config' '--get-color' 'color.interactive.help' 'red bold'
02:15:53.063719 git.c:371               trace: built-in: git 'config' '--get-color' '' 'reset'
02:15:53.270403 git.c:371               trace: built-in: git 'rev-parse' '--verify' '--quiet' 'refs/stash'
02:15:53.468215 git.c:371               trace: built-in: git 'log' '--format=%gd: %gs' '-g' '--first-parent' '-m' '-n' '1' 'refs/stash' '--'
02:15:53.470152 run-command.c:369       trace: run_command: 'less'
02:15:53.470884 run-command.c:228       trace: exec: 'less'
stash@{0}: WIP on feature/optimize-stash-marker: 8ee89eb Optimize the git command used to check stash

real	0m3.257s
user	0m1.010s
sys	0m2.187s

vs

[502640072:~/liquidprompt] feature/optimize-stash-marker+ 14m50s ± time GIT_TRACE=1 git rev-parse refs/stash
02:16:02.152990 git.c:371               trace: built-in: git 'rev-parse' 'refs/stash'
14ed66dee9795c967283f36f11a11896d473bfea

real	0m0.006s
user	0m0.001s
sys	0m0.003s

dolmen added a commit that referenced this pull request Feb 22, 2017
@dolmen dolmen added the merged! label Apr 10, 2017
@dolmen dolmen closed this Apr 10, 2017
@dolmen dolmen self-assigned this Apr 10, 2017
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.

None yet

2 participants