Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
perf(config): route fsmonitor and pager reads through bulk cache (#2346)
Maximilian Roosdd2aaf37d498
diff --git a/src/git/repository/mod.rs b/src/git/repository/mod.rsindex 0c12f6f8f..667759a4c 100644--- a/src/git/repository/mod.rs+++ b/src/git/repository/mod.rs@@ -818,12 +818,16 @@ impl Repository {/// Check if git's builtin fsmonitor daemon is enabled.///- /// Returns true only for `core.fsmonitor=true` (the builtin daemon).- /// Returns false for Watchman hooks, disabled, or unset.+ /// Returns true for any git-bool truthy value (`true/1/yes/on`), which+ /// matches how git itself routes the bool-or-string `core.fsmonitor`+ /// config to the builtin daemon. Returns false for Watchman hook paths,+ /// disabled, or unset.pub fn is_builtin_fsmonitor_enabled(&self) -> bool {- self.run_command(&["config", "--get", "core.fsmonitor"])+ self.config_last("core.fsmonitor").ok()- .map(|s| s.trim() == "true")+ .flatten()+ .as_deref()+ .map(parse_git_bool).unwrap_or(false)}diff --git a/src/git/repository/tests.rs b/src/git/repository/tests.rsindex 83ba6c320..fa19c9d69 100644--- a/src/git/repository/tests.rs+++ b/src/git/repository/tests.rs@@ -527,3 +527,48 @@ fn extract_failed_command_from_other_error() {assert_eq!(output, "some other error");assert!(cmd.is_none());}++#[test]+fn is_builtin_fsmonitor_enabled_variants() {+ use super::RepoCache;+ use indexmap::IndexMap;+ use std::sync::{Arc, RwLock};++ fn repo_with_fsmonitor(value: Option<&str>) -> super::Repository {+ let cache = RepoCache::default();+ let mut map: IndexMap<String, Vec<String>> = IndexMap::new();+ if let Some(v) = value {+ map.insert("core.fsmonitor".to_string(), vec![v.to_string()]);+ }+ cache.all_config.set(RwLock::new(map)).unwrap();+ super::Repository {+ discovery_path: PathBuf::from("/nonexistent/repo"),+ git_common_dir: PathBuf::from("/nonexistent/.git"),+ cache: Arc::new(cache),+ }+ }++ // Builtin daemon: any git-bool truthy value enables it.+ for truthy in ["true", "1", "yes", "on", "TRUE"] {+ assert!(+ repo_with_fsmonitor(Some(truthy)).is_builtin_fsmonitor_enabled(),+ "{truthy} should enable builtin fsmonitor"+ );+ }++ // Watchman hook path is NOT the builtin daemon — must return false even+ // though the value is non-empty and truthy in the colloquial sense.+ assert!(+ !repo_with_fsmonitor(Some("/usr/local/bin/git-fsmonitor-watchman.sh"))+ .is_builtin_fsmonitor_enabled()+ );++ // Explicitly disabled and unset both report false.+ for falsy in ["false", "0", "no", "off"] {+ assert!(+ !repo_with_fsmonitor(Some(falsy)).is_builtin_fsmonitor_enabled(),+ "{falsy} should disable builtin fsmonitor"+ );+ }+ assert!(!repo_with_fsmonitor(None).is_builtin_fsmonitor_enabled());+}diff --git a/src/pager.rs b/src/pager.rsindex add32ff20..b6d9a80d9 100644--- a/src/pager.rs+++ b/src/pager.rs@@ -9,7 +9,8 @@ pub(crate) fn parse_pager_value(value: &str) -> Option<String> {/// Read `core.pager` from git config, returning None if unset or invalid.pub(crate) fn git_config_pager() -> Option<String> {let repo = Repository::current().ok()?;- repo.run_command(&["config", "--get", "core.pager"])+ repo.config_value("core.pager").ok()+ .flatten().and_then(|output| parse_pager_value(&output))}