-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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 plugin: Replace calls to git status with porcelain commands #40
Conversation
No! I specifically wrote it this way to avoid multiple calls to Git commands to make the prompt fast. The difference between |
I must say I would like to see benchmarks showing that this is slower than Having git to do a formatting job, then trying to extract the content from the formatted data (with a ton of conditions/regex) instead of calling the plumbing methods (which are made to be fast) without having any processing to do seems way slower to me. Plus as I said, currently, using |
This is not the first iteration of the code. I have not written benchmarks. But, I saw perceived slowness with my eyeballs. Yes, I know how that sounds. Feel free to benchmark it. |
Right now I don't really have the time (nor the willingness) to do the benchmarks. Anyway keeping the current version or this version of the code shouldn't change anything to the end-user (except for the dirty-count part, I'll submit another patch for that [#42] and the issue with colors.ui=always), so it won't be a problem to choose either this solution or the current one. If someone wants to do the benchmarks that would be awesome. For what it worth, I think this is a bit more maintainable (separation of concerns, 1 command per task), but if indeed it's slower than the current code, and can't be modified in order to be faster it would be better to stick with the current solution. In the mean time, unless absolutely you want to close this pull request, can we keep this request open until we have more details on the performances? |
It is more maintainable. Clearly, one command that gives you everything is faster than multiple commands that give you pieces. Now, does parsing said one command slow it down to where the speed gained from running one command is nullified? We have to be careful. A few milliseconds here, a few milliseconds there will add up to one or two seconds of loading time, which is noticeable when you open new terminal windows or tabs. I have been aware of the |
(Except when you want to use cat as the git pager and want to pipe to another thing...). On another note (but still performance wise), I mentioned it in #39, but wouldn't it be possible to diable some part of git-info based on the settings of the current theme? Regarding the overall speed, I'm not even sure that's always true that only one command does it faster, if the implementation only calls plumbing methods to aggregate everything in one big formated result it could be even slower. But I totally agree, even with a few millisecs, with every other script around it could be quickly a nightmare. |
It's possible, but you would have to add many if statements to check if the zstyles have been defined. Also, style.zsh will have to be turned into a giant comment. It's a complication. |
But if it's applied on "groups" of data, for example if we know we won't use the remote name, or the difference between local and remote, or in the case of #39, if we don't use the describe system at all, it would be in the current code one less regex and in this patch one less command called. I also don't think that style.zsh should be there, it acts mostly like a documentation and not a default minimal implementation (in your theme you've almost overridden every style [and I do so too in the theme I'm currently building]). |
How would you like style HTML if you had no HTML? Would you like to write abstract CSS? style.zsh acts as a default, which you can change in your theme item by item. There are others in keyboard.zsh. |
What I mean is, I think it would be better to have a nice documentation on how to use the git-plugin-prompt and a style.zsh stripped to the bare minimum ( prompt, branch, dirty and clean [+ignore & ignore submodule]). The idea of having a style.zsh being a gigantic comment file comes from the fact that OMZ needs a documentation in the code. Of course you're right we need a default behaviour, this way someone just using |
I prefer for plugins to be documented in a README file inside of the plugin directory. Documentation should always accompany source code. Users should not have to hunt for wikis. However, the newly enabled wiki is useful for keeping the main README.md short. Another option, which will unfortunately make styling more verbose but more flexible and similar to Turn: # %a - Indicator to notify of added files.
zstyle ':omz:plugin:git:prompt' added 'added:%a' Into: # %a - Indicator to notify of added files.
zstyle ':omz:plugin:git:prompt:added' format 'added:%a'
zstyle ':omz:plugin:git:prompt:added' enable 'yes' |
This prompt is an example of what porcelain commands need to be run to acquire the same information provided by |
Yes, it seems they are the same as the one I use.
|
What do you think of the zstyles I wrote two days ago? |
I like the idea of enabling/disabling some part of the style, if it's possible to do that on each git command used in git_info instead of each format.
Plus it's not that verbose if it's used like this:
|
You'll have to rebase it since it no longer cleanly merges. |
That should be okay now. |
I found another issue with the |
We're changing to porcelain commands. I'll go through your patch later today. We'll look at enable/disable if performance is a problem later. You might have to rebase once more when I merge in the #41 patch, which also fixes a remote related bug. |
Updated to match #41 changes |
Are you sure? It still can't be merged cleanly. |
Hum, I pushed just before 854c67a I'll rebase right away |
Count file status in an external loop. git status shouldn't be used in a non porcelain mode
The branch name shouldn't be extracted from the git status
The current action hasn't anything to do with git status
The remote branch's name should be obtained manually, not with git status
The difference with the remote branch shouldn't be obtain through git status
The remote should only show when you are on a branch, right? |
Exactly, you can't have a remote-branch without a local-branch. |
Is there a risk that upstream_diff_cmd may fail in future Git versions? Should we split ahead and behind (2 calls)? |
I don't think there is such a risk (plumbing methods don't change that radically), and doing two requests here could take more time (depending on the code implementation): if git has to go through the commits-tree two time to get its info, that could be slower. I think that if |
Do you know how recent for i in {1..5}; time (git rev-list --count --left-right '@{upstream}'...HEAD > /dev/null)
0.00s user 0.01s system 72% cpu 0.014 total
0.00s user 0.01s system 67% cpu 0.014 total
0.00s user 0.01s system 75% cpu 0.013 total
0.00s user 0.01s system 69% cpu 0.014 total
0.00s user 0.01s system 79% cpu 0.013 total for i in {1..5}; time (git rev-list --count '@{upstream}'..HEAD > /dev/null; git rev-list --count HEAD..'@{upstream}' > /dev/null)
0.01s user 0.01s system 74% cpu 0.026 total
0.01s user 0.01s system 80% cpu 0.024 total
0.01s user 0.01s system 81% cpu 0.023 total
0.01s user 0.01s system 80% cpu 0.023 total
0.01s user 0.01s system 82% cpu 0.022 total |
It's here at least since 1.5.1.1 |
Fixed: installation on OS X fails
Restore the parser status to PS2
Clean the git plugin to avoid calls to git status.
Right now, most of the git plugin depends on the git-status command which is called like a user would do.
There is plenty of plumbing tools more adapted to get this kind of data and even more information.
A possible issue with git-status is the fact that if colors.ui is set to always, it will screw up colors in the prompt.
Another neat feature if the dirty count. Now we can know how many dirty files are in the current repository.