Skip to content

Commit 5a43fa7

Browse files
committed
doctor: report git object store health
Codex writes snapshot trees and refs/codex/* refs into the repository as it works, and nothing packs or prunes them unless git gc or git maintenance runs. A write that is interrupted part-way also leaves tmp_obj_* and tmp_pack_* files behind that git gc reports as garbage but never removes. Over time a workspace can carry hundreds of megabytes of loose objects that slow every status, diff and snapshot command, and nothing in the doctor report points at it. Add a "git objects" check to codex doctor that inspects the object store of the working directory's repository from the filesystem, without executing git, in keeping with the existing git check: - loose object count and size, pack file count and size - leftover tmp_obj_* / tmp_pack_* / tmp_idx_* files - number of refs under refs/codex/, including packed refs - whether the repository is registered for git maintenance in the global config (linked worktrees are matched by their main worktree) It warns when garbage files exist or when loose objects exceed git's own gc.auto threshold (6700 objects) or 200 MiB, and the remedy names git maintenance register / start or a one-off git gc.
1 parent 79be2e2 commit 5a43fa7

3 files changed

Lines changed: 704 additions & 2 deletions

File tree

‎codex-rs/cli/src/doctor.rs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ mod desktop;
7878
mod disk;
7979
mod filesystem_paths;
8080
mod git;
81+
mod git_objects;
8182
mod network;
8283
mod output;
8384
mod progress;
@@ -428,6 +429,7 @@ async fn build_report(
428429
sandbox_check,
429430
terminal_check,
430431
git_check,
432+
git_objects_check,
431433
terminal_title_check,
432434
state_check,
433435
thread_inventory_check,
@@ -480,6 +482,11 @@ async fn build_report(
480482
async {
481483
run_sync_check("git", progress.clone(), || git_check(config.cwd.as_path()))
482484
},
485+
async {
486+
run_sync_check("git objects", progress.clone(), || {
487+
git_objects::check(config.cwd.as_path())
488+
})
489+
},
483490
async {
484491
run_sync_check("terminal title", progress.clone(), || {
485492
terminal_title_check(config)
@@ -519,6 +526,7 @@ async fn build_report(
519526
filesystem_paths_check,
520527
terminal_check,
521528
git_check,
529+
git_objects_check,
522530
terminal_title_check,
523531
state_check,
524532
thread_inventory_check,
@@ -533,6 +541,7 @@ async fn build_report(
533541
network_check,
534542
terminal_check,
535543
git_check,
544+
git_objects_check,
536545
state_check,
537546
reachability_check,
538547
) = tokio::join!(
@@ -548,6 +557,9 @@ async fn build_report(
548557
})
549558
},
550559
async { run_sync_check("git", progress.clone(), || git_check(&cwd)) },
560+
async {
561+
run_sync_check("git objects", progress.clone(), || git_objects::check(&cwd))
562+
},
551563
async { run_sync_check("state", progress.clone(), fallback_state_check) },
552564
run_async_check(
553565
"provider reachability",
@@ -560,6 +572,7 @@ async fn build_report(
560572
network_check,
561573
terminal_check,
562574
git_check,
575+
git_objects_check,
563576
state_check,
564577
reachability_check,
565578
]);

0 commit comments

Comments
 (0)