Version control for agents

restore-uses-stat-cache

restore-uses-stat-cacheOpeninto main

1 commit · 4 files · ~4 modified · 1 behind main

Description

Restore only reads the files that may have changed

oak restore read every tracked file twice; it now uses the stat cache the way oak status does, and rewrites only what differs. oak reset plans the same way and still rewrites the whole tree. Tracked symlinks are compared as links: one to a directory used to fail both commands ("Is a directory"), and one to a file was always listed as reverted.

On a 65,000-file repo: restore after one edit 4.2 s to 0.6 s, after 10,000 edits 5.3 s to 2.1 s.

Commits1

cli/src/commands/commit.rsmodifiedView file

@@ -724,13 +724,13 @@
724724 /// path, matching what git records as a symlink blob (and what
725725 /// `git_clone::copy_tree_to_oak` imports). Never follows the link.
726726 #[cfg(unix)]
727-fn symlink_target_bytes(path: &std::path::Path) -> Result<Vec<u8>> {
727+pub(crate) fn symlink_target_bytes(path: &std::path::Path) -> Result<Vec<u8>> {
728728 use std::os::unix::ffi::OsStrExt;
729729 Ok(fs::read_link(path)?.as_os_str().as_bytes().to_vec())
730730 }
731731
732732 #[cfg(not(unix))]
733-fn symlink_target_bytes(path: &std::path::Path) -> Result<Vec<u8>> {
733+pub(crate) fn symlink_target_bytes(path: &std::path::Path) -> Result<Vec<u8>> {
734734 Ok(fs::read_link(path)?
735735 .to_string_lossy()
736736 .into_owned()