Skip to content

Run local git actions without blocking the main thread #732

Open

Description

@goneng

GitX runs its local git actions synchronously on the main thread, so a slow command freezes the window until git finishes, or until PBTask gives up after 30 seconds.

Where it happens

  • PBGitRepository runs checkout, merge, cherry-pick, reset, rebase, stash, branch and tag creation, ref deletion, and the worktree actions (lock, unlock, prune, add, remove, repair) through outputOfTaskWithArguments:, which ends in PBTask's blocking launchTask:.
  • Only fetch, pull and push already run off the main thread.
  • launchTask: terminates any command after 30 seconds and reports a timeout, so a long checkout or git worktree add in a large repository can be killed part way through.

What a fix involves

  • An asynchronous path for local actions that delivers success or the error back on the main queue.
  • A busy state while a command runs, so the same action cannot be started twice.
  • Revisiting the 30-second limit for commands whose duration grows with the repository.
  • Refreshing refs, the index and the worktree list once the command completes.

Testing

Callers assume the result is there when the call returns, so each action's flow (sheets, errors, refresh) needs checking end to end, not only through unit tests.

Raised by Copilot on #723 and #727; both PRs follow the existing synchronous pattern and leave this change to its own PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions