Harden background Git operations and avoid bundle reload for worktree changes #68
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
state: Done
state: New
state: To Do
type: Bug
type: Feature
type: Task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Christoph/Gitty!68
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/background-refresh-and-locks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This change hardens background Git network operations, reduces unnecessary full-bundle reloads when only the working tree changes, and includes several related correctness and performance fixes.
Summary
Background remote ops: Introduces a unified
run_remote_git_outputandrun_git_with_timeoutflow used for network-facing commands. Background runs:GIT_TERMINAL_PROMPT=0,SSH_ASKPASS_REQUIRE=never) so they never block on passphrase/host-key dialogs.GIT_OPTIONAL_LOCKS=0).BACKGROUND_REMOTE_TIMEOUT) and forcibly kill the Git process tree if it hangs; helpers are also terminated on Unix via a process-group kill (useslibc::killbehind cfg(unix)).GIT_HTTP_LOW_SPEED_*).API and callsites:
fetch(sync) andfetch_commit_notesgained an optionalbackground: Option<bool>parameter to request the no-dialog/timeout behavior; callers/tests were updated accordingly.working_tree_snapshot(path)returns a compact snapshot (status, files, and arefs_fingerprint) used by the UI to detect working-tree-only changes.Refresh behavior / bundle reloads:
refs_fingerprint(HEAD + all refs). The periodic refresh can request a working-tree snapshot and, whenrefs_fingerprintmatches the last bundle, update status and explorer files without reloading the full bundle.Commit paging cap:
MAX_COMMIT_PAGE = 5_000and used it when bounding commit limits for bundle/page queries (keeps requested page sizes consistent across bundle and paged history).Commit notes / credentials handling:
fetch_commit_notes_for_reponow routes throughrun_remote_git_output, acceptsbackground, and centralizes authenticated vs unauthenticated remote handling. Errors from credentialed fetches now add anAUTH_FAILED:prefix when appropriate.Performance and correctness improvements:
StatusLookupthat builds a single HashMap for many path lookups (avoids n² scanning when staging lots of files).worktree_blob_hashesnow caches computed hashes for untracked/changed files (bounded cache) and avoids repeated hashing when file size and mtime are unchanged; it uses a small settle window before caching to avoid racy writes.status_files_for_pathsnow uses a HashSet to test presence rather than re-scanning the list per-file.Build change:
libcadded as a dependency on Unix targets (Cargo.toml/Cargo.lock updated) to support process-group kill.Files / behavior highlights (cohesive view, not exhaustive):
src-tauri/src/git/process.rs(run_remote_git_output,run_git_with_timeout, env settings).src-tauri/src/git/sync.rsandsrc-tauri/src/git/notes.rsacceptbackgroundand use the new runner.src-tauri/src/git/repository.rsaddsWorkingTreeSnapshot,refs_fingerprint, andworking_tree_snapshotcommand; repository bundles includerefs_fingerprint.src-tauri/src/git/staging.rs(StatusLookup),src-tauri/src/git/status.rs(worktree hash cache), and related changes.scripts/status-refresh.test.mjs) updated/added to assert no bundle reload for worktree-only changes; several Rust regression/unit tests updated/added to exercise background timeout and signature changes; adjusted script credential tests to account for extra args passed to the remote runner.Testing
Recommended manual checks for reviewers:
AUTH_FAILED:in the error string where applicable.Compatibility / reviewer notes
fetchandfetch_commit_notesaccept an additional optionalbackgroundboolean. Front-end and any other callers were updated in this branch, but reviewers should scan for other callsites in dependent code.libc::kill(unsafe block) but is gated with#[cfg(unix)].working_tree_snapshotwas introduced; callers that expect a bundle to be reloaded on every refresh should be aware this adds a non-bundle refresh path.No test execution results were provided.