-
-
Notifications
You must be signed in to change notification settings - Fork 803
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
asynchronous git prompt updates #51
Conversation
Very interesting... I'd considered trying something like this long ago but never got very far - nice work! Are there any leaks if the shell is closed without calling Stop-Prompt? Let me give this a try for a while... |
Thanks, If the shell process is closed, of course there will be no leaks, but I am -Robert On Fri, Jun 1, 2012 at 6:38 PM, Keith Dahlby <
|
With the latest commit I made the default behavior for Start-GitPrompt is to update the status synchronously, in which case it caches the status and only invalidates the cache asynchronously, and only when files are changed in the repository. This is similar to #52, but it allows for ignore file patterns to filter out non-essential file changes. My intention is for these patterns to be based on the ,gitignore file settings. |
I almost wonder if it would be worth adding a repository watcher component to libgit2sharp to provide Git-aware change notifications (excluding ignored files, etc). Seems like it could be useful to something like GH4W. /cc @nulltoken @tclem @haacked @xpaulbettsx @aroben |
yeah, it seems like a feature that would be useful for other CLR based git tools as well |
That would be awesome. On Jun 5, 2012, at 3:22 PM, Keith Dahlby dahlbyk@noreply.github.com wrote:
|
In order to avoid duplicating the "ignore" logic, wouldn't this invoke |
Potentially, though the exposed file status could be lazy to avoid the perf hit unless it's needed. |
I'm not sure I'm able to picture the whole design. Let me try:
Is that it? |
You would also need to monitor the repo (e.g. The posh-git use case is pretty simple - if anything interesting (either in repo, or in workdir and not ignored) changed, fetch a full status update. Other consumers might be interested in more fine-grained events (e.g. |
Perhaps first start out with factoring out any .gitignore filter predicates so that consumers of the library can compose them with a watcher as they see fit.... SRP/SoC |
…ory were using the current location to update the status, which corrupted the status
fixing test/command synchronisation issue
while it would be tied to the 'console' host of PowerShell, I was wondering if it seems reasonable to have something similar to this approach with status on a timer, but having it update the console async to the prompt? Since I currently have my prompt put the git status on its own line, it seems reasonable that at prompt rendering time, just store off the current cursor position (where the git status should be written) in a global variable (maybe $global:StatusTargetLocation = [console]::CursorTop) and then fire off the git status job/timer thingy. When it returns, we can write the status string we calculated out to that location in the console. We could likely use (as-is or close) the WriteTo-Pos function from this blog post (and potentially other bits/tricks from the post as well :) http://blogs.technet.com/b/heyscriptingguy/archive/2010/03/26/hey-scripting-guy-march-26-2010.aspx It would definitely depend on the status being on its own line (since we won't know ahead of time how long the status string will end up being and definitely don't want to either overwrite or shift whatever the rest of the contents of their prompt), and would only work in the console host, but does this seem like it would work? Similar to the previous async approach, you'd want to ensure there was only one outstanding status call at a time instead of hitting enter 10 times firing off git status 10 times :) Thanks! |
Yeah, I actually tried to get this working too. I couldn't figure out a way On Tuesday, November 13, 2012, James Manning wrote:
|
Cursor manipulation makes me pretty nervous...seems like it would be really difficult to test sufficiently to have confidence that it will "just work". |
How about putting it into the prompts window title? Is that feasible? That wouldn't force cursor magic, and doesn't interrupt the user. Prompt could display branch, title displays revision and status info Sent from my Windows Phone From: Keith Dahlbymailto:notifications@github.com Cursor manipulation makes me pretty nervous...seems like it would be really difficult to test sufficiently to have confidence that it will "just work". — |
these changes speed up the git prompt, with the side effect that the prompt will be eventually consistent
Start-Prompt turns the asynchronous prompt on
Stop-Prompt turns the asynchronous prompt off