altsem / gitu

A TUI Git client inspired by Magit
MIT License
1.7k stars 88 forks source link

Async git push, pull, fetch, etc #97

Closed TheLostLambda closed 4 months ago

TheLostLambda commented 4 months ago

At some point, it might be nice to make the calls to git push, git pull, and git fetch (anything that relies on the network) asynchronous! I'm stuck on a quite slow connection, so when I go to push my changes, the UI freezes up for a while!

I could just wait to do all of my pushing at once (after staging and committing everything outstanding), but it might be a nice quality of life feature to decouple the UI responsiveness from network access!

altsem commented 4 months ago

This sounds reasonable! I realized things may become complicated, as you don't want to make the cursor move unexpectedly after e.g. a Pull.

I guess Fetch and Push are easier?

TheLostLambda commented 4 months ago

I agree there would have to be some thinking about where to place the cursor post-pull, but how is that currently done with reloading after pressing g?

I might still find it less jarring to have the cursor / view change post pull (it does when I press g already) than to have it hang during a pull, but perhaps I'm just not 100% understanding what you mean (I'm sure there is more nuance on the code-side)!

altsem commented 4 months ago

There's two aspects I think.

  1. the cursor might move unexpectedly on a refresh
  2. A refresh might happen unexpectedly

edit: I do agree this is a good idea, perhaps it is a non-issue. And it can be made clear by showing some kind of status that a pull is ongoing! An alternative might be to inform the user that they can refresh (is it really needed?).

It would require some refactoring to support async commands.

altsem commented 4 months ago

@TheLostLambda I implemented this (I think) :) I'll leave it on this PR for a while in case you or anyone like to test it out, or have any input.

108

TheLostLambda commented 4 months ago

Exciting! I'll take a look and kick the tires!