Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
refactor(tests): deny network transports for in-process git, consolidate fixtures (#3620)
Maximilian Roos9cb128328f17
diff --git a/Taskfile.yaml b/Taskfile.yamlindex 2347ee68a..9c78ecf40 100644--- a/Taskfile.yaml+++ b/Taskfile.yaml@@ -218,87 +218,6 @@ tasks:echo "Done:"ls -lh "$OUTPUT_DIR"/*.png- test:create-standard-fixture:- desc: Create/recreate the standard test fixture (repo + worktrees + remote)- dir: "{{.REPO_ROOT}}"- cmds:- - |- set -euo pipefail-- FIXTURE_DIR="tests/fixtures/standard"- TIMESTAMP="2025-01-01T00:00:00"-- echo "Creating standard test fixture..."-- # Clean slate- rm -rf "$FIXTURE_DIR"- mkdir -p "$FIXTURE_DIR"- cd "$FIXTURE_DIR"-- # Create the main repo- git init repo- cd repo-- # Configure for deterministic output (disable GPG signing)- git config user.name "Test User"- git config user.email "[email protected]"- git config commit.gpgsign false-- # Initial commit on main- echo "initial content" > file.txt- cat > .gitattributes << 'EOF'- * text=auto eol=lf- EOF- git add -A- GIT_AUTHOR_DATE="$TIMESTAMP" GIT_COMMITTER_DATE="$TIMESTAMP" \- git commit -m "Initial commit"-- # Create bare remote and push- cd ..- git clone --bare repo origin.git- cd repo- git remote add origin ../origin.git- git push -u origin main-- # Create worktrees with commits- for branch in feature-a feature-b feature-c; do- git worktree add -b "$branch" "../repo.$branch"- echo "$branch content" > "../repo.$branch/$branch.txt"- git -C "../repo.$branch" add "$branch.txt"- GIT_AUTHOR_DATE="$TIMESTAMP" GIT_COMMITTER_DATE="$TIMESTAMP" \- git -C "../repo.$branch" commit -m "Add $branch file"- done-- cd ..-- # Rename .git directories to _git to avoid git treating fixture as repo- mv repo/.git repo/_git- mv origin.git origin_git- for wt in repo.feature-a repo.feature-b repo.feature-c; do- # Worktrees have .git files pointing to main repo, rename those too- mv "$wt/.git" "$wt/_git"- done-- # Update worktree gitdir references (they point to .git, need to point to _git)- for wt in feature-a feature-b feature-c; do- # Fix the gitdir file in worktree (it's a file, not a directory)- sed -i.bak 's/\.git/_git/g' "repo.$wt/_git"- rm -f "repo.$wt/_git.bak"- # Fix the worktree config in main repo (worktree dir is repo.$wt)- sed -i.bak 's/\.git/_git/g' "repo/_git/worktrees/repo.$wt/gitdir"- rm -f "repo/_git/worktrees/repo.$wt/gitdir.bak"- done-- # Fix remote URL (origin.git -> origin_git)- sed -i.bak 's/origin\.git/origin_git/g' "repo/_git/config"- rm -f "repo/_git/config.bak"-- echo ""- echo "Created fixture structure:"- find . -maxdepth 2 -type d | head -20- echo ""- echo "Done! Fixture at: tests/fixtures/standard/"-bench-llm-commits:desc: Benchmark LLM commit message tools (claude, llm, aichat, codex, opencode)silent: truediff --git a/src/testing/mod.rs b/src/testing/mod.rsindex 7bac9932f..8acab99dd 100644--- a/src/testing/mod.rs+++ b/src/testing/mod.rs@@ -17,6 +17,8 @@//! - [`TestRepo::bare()`] — bare repository (`git init --bare`). No working tree.//! - [`TestRepo::at(path)`](TestRepo::at) — repo at a caller-specified path.//! For tests needing multiple repos in a shared directory.+//! - [`TestRepo::bare_at(path)`](TestRepo::bare_at) — bare repo at a+//! caller-specified path (e.g. the `project/.git` clone layout).//! - [`TestRepo::standard()`] — copies pre-built fixture with remote + worktrees.//! For integration tests (used by the `repo()` rstest fixture).//! - [`TestRepo::empty()`] — `git init` with no commits, no branches.@@ -80,11 +82,17 @@ pub fn workspace_bin(name: &str) -> PathBuf {}use tempfile::TempDir;-/// Path to the standard fixture (relative to crate root).-/// Contains repo/, repo.feature-a/, repo.feature-b/, repo.feature-c/, origin_git/.-fn standard_fixture_path() -> PathBuf {- PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/standard")-}+/// Bump when [`build_standard_fixture`] changes, so stale templates under+/// `target/` are abandoned rather than reused.+const STANDARD_FIXTURE_VERSION: u32 = 1;++/// Timestamp for the template's commits, author and committer alike.+///+/// The `-08:00` offset looks arbitrary but is load-bearing: commit SHAs+/// derive from it, and the fixture's SHAs (`05a4a45`, `1b87d47`, ...) appear+/// in ~170 committed snapshots. This value reproduces them exactly; the+/// guard is `test_standard_fixture_template_reproduces_pinned_shas`.+const STANDARD_FIXTURE_COMMIT_DATE: &str = "2025-01-01T00:00:00-08:00";/// Worktree info returned from fixture copy.struct FixtureWorktrees {@@ -92,12 +100,114 @@ struct FixtureWorktrees {remote: PathBuf,}-/// Copy the standard fixture to create a new test repo with worktrees and remote.-///-/// The fixture contains:-/// - Main repo on `main` branch with one commit-/// - Remote (origin) bare repository-/// - Three feature worktrees (feature-a, feature-b, feature-c) each with one commit+/// Get-or-create the standard fixture template under `target/<profile>/`.+///+/// The template is built by real git once per target directory, then copied+/// per test ([`copy_standard_fixture`]): building per test would cost+/// ~300 ms under nextest's process-per-test model, copying costs ~20 ms.+/// `cargo clean` removes the template with everything else.+fn standard_fixture_template() -> PathBuf {+ let mut base = std::env::current_exe().expect("failed to get test executable path");+ base.pop(); // test binary name+ base.pop(); // deps/+ let fixtures = base.join("wt-test-fixtures");+ let dir = fixtures.join(format!("standard-v{STANDARD_FIXTURE_VERSION}"));+ if !dir.exists() {+ claim_template(&fixtures, &dir, build_standard_fixture);+ }+ dir+}++/// Build into a private scratch directory under `parent`, then rename it to+/// `dir` — the atomic claim that makes concurrent cold-cache builders race+/// benignly. `TempDir::new_in` names the scratch uniquely per call, so+/// builders can't collide on it whether they're separate nextest processes+/// or threads of one `cargo test` process; the first rename into place wins+/// and losers discard their build.+fn claim_template(parent: &Path, dir: &Path, build: impl FnOnce(&Path)) {+ std::fs::create_dir_all(parent).unwrap();+ let scratch = TempDir::new_in(parent).expect("create template build dir");+ build(scratch.path());++ // Disarm auto-cleanup: from here the scratch either becomes `dir` or is+ // removed explicitly on losing the race.+ let scratch = scratch.keep();+ match std::fs::rename(&scratch, dir) {+ Ok(()) => {}+ Err(_) if dir.exists() => {+ // Another builder won the race; use its template.+ std::fs::remove_dir_all(&scratch).ok();+ }+ Err(e) => panic!(+ "failed to move template into place at {}: {e}",+ dir.display()+ ),+ }+}++/// Build the standard fixture at `root`: `repo/` on `main` with one commit,+/// a bare `origin.git` remote (init + push, so the template records no+/// back-pointing remote), and three feature worktrees with one commit each.+fn build_standard_fixture(root: &Path) {+ let git = |dir: &Path| {+ configure_git_env(Cmd::new("git"), test_gitconfig_path())+ .env("GIT_AUTHOR_DATE", STANDARD_FIXTURE_COMMIT_DATE)+ .env("GIT_COMMITTER_DATE", STANDARD_FIXTURE_COMMIT_DATE)+ .current_dir(dir)+ };+ let run = |cmd: Cmd, what: &str| {+ let output = cmd.run().unwrap();+ check_git_status(&output, what);+ };++ let repo = root.join("repo");+ run(git(root).args(["init", "-q", "-b", "main", "repo"]), "init");+ std::fs::write(repo.join("file.txt"), "initial content\n").unwrap();+ std::fs::write(repo.join(".gitattributes"), "* text=auto eol=lf\n").unwrap();+ run(git(&repo).args(["add", "-A"]), "add -A");+ run(+ git(&repo).args(["commit", "-q", "-m", "Initial commit"]),+ "commit",+ );++ run(+ git(root).args(["init", "-q", "--bare", "-b", "main", "origin.git"]),+ "init --bare origin.git",+ );+ run(+ git(&repo).args(["remote", "add", "origin", "../origin.git"]),+ "remote add",+ );+ run(+ git(&repo).args(["push", "-q", "-u", "origin", "main"]),+ "push -u origin main",+ );++ for branch in ["feature-a", "feature-b", "feature-c"] {+ let worktree = root.join(format!("repo.{branch}"));+ run(+ git(&repo).args([+ "worktree",+ "add",+ "-q",+ "-b",+ branch,+ &format!("../repo.{branch}"),+ ]),+ "worktree add",+ );+ let file = format!("{branch}.txt");+ std::fs::write(worktree.join(&file), format!("{branch} content\n")).unwrap();+ run(git(&worktree).args(["add", &file]), "add");+ run(+ git(&worktree).args(["commit", "-q", "-m", &format!("Add {branch} file")]),+ "commit",+ );+ }+}++/// Copy the standard fixture template to create a new test repo with+/// worktrees and remote.////// Pure Rust recursive copy - 2.5x faster than spawning cp/robocopy./// Benchmarked at 21ms vs 53ms per fixture copy on macOS.@@ -118,53 +228,15 @@ fn copy_standard_fixture(dest: &Path) -> FixtureWorktrees {}}- let fixture = standard_fixture_path();- copy_dir_recursive(&fixture, dest);-- // Verify essential directories exist after copy- let essential = ["repo/_git", "origin_git", "repo.feature-a/_git"];- for path in essential {- let full_path = dest.join(path);- assert!(- full_path.exists(),- "Essential fixture path missing after copy: {:?}",- full_path- );- }-- // Rename _git to .git in all locations- let renames = [- ("repo/_git", "repo/.git"),- ("origin_git", "origin.git"),- ("repo.feature-a/_git", "repo.feature-a/.git"),- ("repo.feature-b/_git", "repo.feature-b/.git"),- ("repo.feature-c/_git", "repo.feature-c/.git"),- ];- for (from, to) in renames {- let from_path = dest.join(from);- let to_path = dest.join(to);- if from_path.exists() {- std::fs::rename(&from_path, &to_path).unwrap_or_else(|e| {- panic!("Failed to rename {:?} to {:?}: {}", from_path, to_path, e)- });- }- }-- // Verify origin.git is a valid bare repository- let origin_git = dest.join("origin.git");- assert!(- origin_git.join("HEAD").exists(),- "origin.git is not a valid git repository (missing HEAD): {:?}",- origin_git- );+ copy_dir_recursive(&standard_fixture_template(), dest);// Canonicalize dest for worktrees map (on macOS /var -> /private/var)let canonical_dest = canonicalize(dest).unwrap();- // Fix gitdir files: the fixture uses _git which we rename to .git, and- // each copied repo needs links that point at its own tempdir. Use absolute- // paths, matching `git worktree add`, so `git worktree list` does not- // interpret fixture-relative paths from the wrong base on some Git builds.+ // The template's worktree links are absolute paths into the template;+ // point each copy's links at its own location. Use absolute paths,+ // matching `git worktree add`, so `git worktree list` does not interpret+ // relative paths from the wrong base on some Git builds.for wt in ["feature-a", "feature-b", "feature-c"] {let worktree_path = canonical_dest.join(format!("repo.{wt}"));let worktree_gitdir = worktree_path.join(".git").to_slash_lossy().into_owned();@@ -176,24 +248,16 @@ fn copy_standard_fixture(dest: &Path) -> FixtureWorktrees {.to_slash_lossy().into_owned();- let gitdir_path = dest.join(format!("repo.{wt}/.git"));- if gitdir_path.exists() {- std::fs::write(&gitdir_path, format!("gitdir: {main_worktree_gitdir}\n")).unwrap();- }-- // Fix main repo's worktree gitdir reference- let main_gitdir = dest.join(format!("repo/.git/worktrees/repo.{wt}/gitdir"));- if main_gitdir.exists() {- std::fs::write(&main_gitdir, format!("{worktree_gitdir}\n")).unwrap();- }- }-- // Fix remote URL in config (origin_git -> origin.git)- let config_path = dest.join("repo/.git/config");- if config_path.exists() {- let content = std::fs::read_to_string(&config_path).unwrap();- let fixed = content.replace("origin_git", "origin.git");- std::fs::write(&config_path, fixed).unwrap();+ std::fs::write(+ dest.join(format!("repo.{wt}/.git")),+ format!("gitdir: {main_worktree_gitdir}\n"),+ )+ .unwrap();+ std::fs::write(+ dest.join(format!("repo/.git/worktrees/repo.{wt}/gitdir")),+ format!("{worktree_gitdir}\n"),+ )+ .unwrap();}// Build worktrees map using canonical paths@@ -207,17 +271,67 @@ fn copy_standard_fixture(dest: &Path) -> FixtureWorktrees {FixtureWorktrees { worktrees, remote }}-/// Write a gitconfig file for tests.-fn write_test_gitconfig(path: &Path) {- std::fs::write(- path,- "[user]\n\tname = Test User\n\temail = [email protected]\n\- [advice]\n\tmergeConflict = false\n\tresolveConflict = false\n\- [init]\n\tdefaultBranch = main\n\- [commit]\n\tgpgsign = false\n\- [rerere]\n\tenabled = true\n",- )- .unwrap();+/// The gitconfig that harness-built commands point `GIT_CONFIG_GLOBAL` at+/// (see [`configure_git_env`]). The content is identical for every test, so+/// one file per process serves them all — created lazily like+/// `isolated_test_cwd`, reaped by the OS after the process exits. Settings+/// that must also hold for git spawned in-process go in `LOCAL_TEST_CONFIG`+/// instead.+pub fn test_gitconfig_path() -> &'static Path {+ static GITCONFIG: std::sync::LazyLock<(TempDir, PathBuf)> = std::sync::LazyLock::new(|| {+ let dir = TempDir::new().expect("create test gitconfig dir");+ let path = dir.path().join("test-gitconfig");+ std::fs::write(+ &path,+ "[user]\n\tname = Test User\n\temail = [email protected]\n\+ [advice]\n\tmergeConflict = false\n\tresolveConflict = false\n\+ [init]\n\tdefaultBranch = main\n\+ [commit]\n\tgpgsign = false\n\+ [rerere]\n\tenabled = true\n",+ )+ .expect("write test gitconfig");+ (dir, path)+ });+ &GITCONFIG.1+}++/// Settings written into every test repo's own config by+/// [`write_local_test_config`].+///+/// A unit test driving the library in-process — `Repository::run_command` and+/// everything layered on it — gets a `git` carrying the *test process's*+/// environment, so none of [`configure_git_env`]'s isolation applies: no+/// `GIT_CONFIG_GLOBAL`, meaning the developer's own `~/.gitconfig`, and no+/// `GIT_ALLOW_PROTOCOL`. The repo's own config is the one layer such a command+/// still reads, so whatever must hold for it lives here.+///+/// `protocol.allow = never` with a `file` exception is the config spelling of+/// `GIT_ALLOW_PROTOCOL=file` (see [`GIT_ALLOWED_PROTOCOLS`] for why the suite+/// stays off the wire). Identity and `commit.gpgsign` make an in-process commit+/// work, and work the same way, on a machine that signs commits by default.+const LOCAL_TEST_CONFIG: &str = r#"[user]+ name = Test User+ email = [email protected]+[commit]+ gpgsign = false+[protocol]+ allow = never+[protocol "file"]+ allow = always+"#;++/// Append [`LOCAL_TEST_CONFIG`] to `repo`'s own config file.+///+/// Linked worktrees share the common dir's config, so this reaches every+/// worktree a test later adds.+fn write_local_test_config(repo: &Repository) {+ let path = repo.git_common_dir().join("config");+ let mut file = std::fs::OpenOptions::new()+ .append(true)+ .open(&path)+ .unwrap_or_else(|e| panic!("failed to open {} for append: {e}", path.display()));+ std::io::Write::write_all(&mut file, LOCAL_TEST_CONFIG.as_bytes())+ .unwrap_or_else(|e| panic!("failed to write {}: {e}", path.display()));}/// Canonicalize a path without Windows verbatim prefix (`\\?\`).@@ -244,8 +358,9 @@ pub const TEST_EPOCH: u64 = 1735776000;const BG_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(60);/// Value for `GIT_ALLOW_PROTOCOL` on every git process a test spawns, whether-/// directly or as a child of `wt`: local paths and `file://` only, so the-/// suite cannot reach the wire.+/// directly or as a child of `wt`: local paths and `file://` only. A git a test+/// starts in-process carries none of this environment and is denied by+/// [`LOCAL_TEST_CONFIG`] instead; between them the suite cannot reach the wire.////// Tests point remotes at real hosts (`https://github.com/test-owner/…`) to/// drive forge detection, and `Repository::default_branch()` is allowed to@@ -341,8 +456,6 @@ pub const PTY_TEST_ENV_VARS: &[(&str, &str)] = &[/// The paths an isolated wt subprocess is pointed at — everything in its/// environment that varies per fixture. See [`pty_env_vars`].pub struct TestEnvPaths<'a> {- /// `GIT_CONFIG_GLOBAL`.- pub git_config: &'a Path,/// `HOME`, with `XDG_CONFIG_HOME` beneath it.pub home: &'a Path,/// `WORKTRUNK_CONFIG_PATH`.@@ -360,26 +473,28 @@ pub struct TestEnvPaths<'a> {/// [`configure_cli_command`]. Every fixture that spawns one builds it here, so/// a new variable reaches all of them.pub fn pty_env_vars(paths: TestEnvPaths<'_>) -> Vec<(String, String)> {+ // Baselines, then the git isolation set ([`git_test_env`] — its+ // LC_ALL/LANG/GIT_ALLOW_PROTOCOL repeat STATIC_TEST_ENV_VARS entries+ // with identical values; the later pair wins, harmlessly), then the+ // fixture's paths.let mut vars: Vec<(String, String)> = STATIC_TEST_ENV_VARS.iter().chain(PTY_TEST_ENV_VARS).map(|&(k, v)| (k.to_string(), v.to_string())).collect();+ vars.extend(+ git_test_env(test_gitconfig_path())+ .into_iter()+ .map(|(k, v)| (k.to_string(), v)),+ );vars.extend([- ("GIT_CONFIG_GLOBAL", paths.git_config.display().to_string()),- ("GIT_CONFIG_SYSTEM", NULL_DEVICE.to_string()),- ("GIT_AUTHOR_DATE", "2025-01-01T00:00:00Z".to_string()),- ("GIT_COMMITTER_DATE", "2025-01-01T00:00:00Z".to_string()),- // Prevent git from prompting for credentials when running under a TTY- ("GIT_TERMINAL_PROMPT", "0".to_string()),("HOME", paths.home.display().to_string()),("XDG_CONFIG_HOME",paths.home.join(".config").display().to_string(),),- ("WORKTRUNK_TEST_EPOCH", TEST_EPOCH.to_string()),("WORKTRUNK_CONFIG_PATH",paths.wt_config.display().to_string(),@@ -691,14 +806,30 @@ pub fn configure_cli_command(cmd: &mut Command) {// callers get the same defense; nothing extra needed here.}+/// The environment for a directly-spawned test `git`: isolated config,+/// deterministic timestamps and locale, no terminal prompts, no network+/// transports (`GIT_ALLOWED_PROTOCOLS`).+///+/// Single home for these settings — [`configure_git_cmd`] (Command),+/// [`configure_git_env`] (`Cmd`), and [`pty_env_vars`] (PTY) all+/// consume it, so the three spellings cannot drift.+pub fn git_test_env(git_config_path: &Path) -> [(&'static str, String); 9] {+ [+ ("GIT_CONFIG_GLOBAL", git_config_path.display().to_string()),+ ("GIT_CONFIG_SYSTEM", NULL_DEVICE.to_string()),+ ("GIT_AUTHOR_DATE", "2025-01-01T00:00:00Z".to_string()),+ ("GIT_COMMITTER_DATE", "2025-01-01T00:00:00Z".to_string()),+ ("LC_ALL", "C".to_string()),+ ("LANG", "C".to_string()),+ ("WORKTRUNK_TEST_EPOCH", TEST_EPOCH.to_string()),+ ("GIT_TERMINAL_PROMPT", "0".to_string()),+ ("GIT_ALLOW_PROTOCOL", GIT_ALLOWED_PROTOCOLS.to_string()),+ ]+}+/// Configure a git command with isolated environment for testing.///-/// Sets environment variables for:-/// - Isolated git config (using provided path or /dev/null)-/// - Deterministic commit timestamps-/// - Consistent locale settings-/// - No terminal prompts-/// - No network transports (`GIT_ALLOWED_PROTOCOLS`)+/// Applies [`git_test_env`].////// # Arguments/// * `cmd` - The git Command to configure@@ -709,15 +840,9 @@ pub fn configure_git_cmd(cmd: &mut Command, git_config_path: &Path) {// test that spawns `git` from an unprepared parent shouldn't be vulnerable// to an inherited relative `GIT_DIR` redirecting discovery.scrub_git_path_vars(cmd);- cmd.env("GIT_CONFIG_GLOBAL", git_config_path);- cmd.env("GIT_CONFIG_SYSTEM", NULL_DEVICE);- cmd.env("GIT_AUTHOR_DATE", "2025-01-01T00:00:00Z");- cmd.env("GIT_COMMITTER_DATE", "2025-01-01T00:00:00Z");- cmd.env("LC_ALL", "C");- cmd.env("LANG", "C");- cmd.env("WORKTRUNK_TEST_EPOCH", TEST_EPOCH.to_string());- cmd.env("GIT_TERMINAL_PROMPT", "0");- cmd.env("GIT_ALLOW_PROTOCOL", GIT_ALLOWED_PROTOCOLS);+ for (key, value) in git_test_env(git_config_path) {+ cmd.env(key, value);+ }}/// Configure a `Cmd`-based git command with isolated environment for testing.@@ -729,15 +854,9 @@ pub fn configure_git_env(cmd: Cmd, git_config_path: &Path) -> Cmd {let cmd = INHERITED_GIT_PATH_VARS.iter().fold(cmd, |acc, var| acc.env_remove(var));- cmd.env("GIT_CONFIG_GLOBAL", git_config_path)- .env("GIT_CONFIG_SYSTEM", NULL_DEVICE)- .env("GIT_AUTHOR_DATE", "2025-01-01T00:00:00Z")- .env("GIT_COMMITTER_DATE", "2025-01-01T00:00:00Z")- .env("LC_ALL", "C")- .env("LANG", "C")- .env("WORKTRUNK_TEST_EPOCH", TEST_EPOCH.to_string())- .env("GIT_TERMINAL_PROMPT", "0")- .env("GIT_ALLOW_PROTOCOL", GIT_ALLOWED_PROTOCOLS)+ git_test_env(git_config_path)+ .into_iter()+ .fold(cmd, |acc, (key, value)| acc.env(key, value))}/// Shared interface for test repository fixtures.@@ -926,6 +1045,23 @@ pub fn check_git_status(output: &std::process::Output, cmd_desc: &str) {}}+/// The isolated per-test config files a [`TestRepo`] carries, both rooted in+/// one temp directory. (The test gitconfig is not here: its content is+/// per-process constant, so it lives at [`test_gitconfig_path`].)+struct TestConfigPaths {+ wt: PathBuf,+ approvals: PathBuf,+}++impl TestConfigPaths {+ fn in_dir(dir: &Path) -> Self {+ Self {+ wt: dir.join("test-config.toml"),+ approvals: dir.join("test-approvals.toml"),+ }+ }+}+pub struct TestRepo {temp_dir: TempDir, // Must keep to ensure cleanup on droproot: PathBuf,@@ -937,8 +1073,6 @@ pub struct TestRepo {test_config_path: PathBuf,/// Isolated approvals file for this test (prevents pollution of user's approvals)test_approvals_path: PathBuf,- /// Git config file with test settings (advice disabled, etc.)- git_config_path: PathBuf,/// Path to mock bin directory for gh/glab commandsmock_bin_path: Option<PathBuf>,/// Whether Claude CLI should be treated as installed@@ -964,16 +1098,7 @@ impl TestRepo {/// commands), use [`standard()`](Self::standard) instead.#[allow(clippy::new_without_default)]pub fn new() -> Self {- let repo = Self::init_repo(&["init", "-b", "main"]);- // Also set identity in local config so unit tests that commit via- // repo.run_command() work without GIT_CONFIG_GLOBAL.- repo.repo- .run_command(&["config", "user.name", "Test User"])- .unwrap();- repo.repo- .run_command(&["config", "user.email", "[email protected]"])- .unwrap();- repo+ Self::init_repo(&["init", "-b", "main"])}/// Create a repo with one initial commit on `main`.@@ -1012,8 +1137,8 @@ impl TestRepo {/// - Remote (origin) bare repository/// - Three feature worktrees (feature-a, feature-b, feature-c) each with one commit///- /// Uses a pre-started fixture for fast initialization - copies the fixture- /// from `tests/fixtures/standard/` instead of running git commands.+ /// Copies the once-per-target-dir template ([`standard_fixture_template`])+ /// instead of running git commands, for fast initialization.////// Also sets up mock gh/glab commands that appear authenticated to prevent/// CI status hints from appearing in test output.@@ -1023,33 +1148,12 @@ impl TestRepo {// Copy from standard fixture (includes worktrees and remote)let fixture = copy_standard_fixture(temp_dir.path());- // Canonicalize to resolve symlinks (important on macOS where /var is symlink to /private/var)- let root = canonicalize(&temp_dir.path().join("repo")).unwrap();-- // Create isolated config path for this test- let test_config_path = temp_dir.path().join("test-config.toml");- let test_approvals_path = temp_dir.path().join("test-approvals.toml");- let git_config_path = temp_dir.path().join("test-gitconfig");+ let paths = TestConfigPaths::in_dir(temp_dir.path());+ let root = temp_dir.path().join("repo");- // Write gitconfig for tests- write_test_gitconfig(&git_config_path);-- let mut repo = Self {- temp_dir,- root: root.clone(),- repo: Repository::at(&root).unwrap(),- worktrees: fixture.worktrees,- remote: Some(fixture.remote),- test_config_path,- test_approvals_path,- git_config_path,- mock_bin_path: None,- claude_installed: false,- codex_installed: false,- opencode_installed: false,- gemini_installed: false,- detect_clis_via_path: false,- };+ let mut repo = Self::assemble(temp_dir, &root, paths);+ repo.worktrees = fixture.worktrees;+ repo.remote = Some(fixture.remote);// Mock gh/glab as authenticated to prevent CI hints in test outputrepo.setup_mock_gh();@@ -1066,43 +1170,33 @@ impl TestRepo {/// Use for tests that need multiple repos in a shared directory/// (e.g., sibling worktrees, multi-repo recovery tests).pub fn at(path: &Path) -> Self {+ Self::at_with(path, &["init", "-b", "main", "--quiet"])+ }++ /// [`at()`](Self::at) for a bare repository (`git init --bare`).+ ///+ /// Use for caller-shaped bare layouts, e.g. the `git clone --bare <url>+ /// project/.git` pattern where the bare dir sits inside a project+ /// directory the test owns.+ pub fn bare_at(path: &Path) -> Self {+ Self::at_with(path, &["init", "--bare", "--quiet"])+ }++ /// Shared initializer for [`at()`](Self::at) and [`bare_at()`](Self::bare_at):+ /// runs `git init` with the given arguments at a caller-managed path.+ fn at_with(path: &Path, git_args: &[&str]) -> Self {std::fs::create_dir_all(path).unwrap();let config_dir = TempDir::new().unwrap();- let test_config_path = config_dir.path().join("test-config.toml");- let test_approvals_path = config_dir.path().join("test-approvals.toml");- let git_config_path = config_dir.path().join("test-gitconfig");- write_test_gitconfig(&git_config_path);+ let paths = TestConfigPaths::in_dir(config_dir.path());- configure_git_env(Cmd::new("git"), &git_config_path)- .args(["init", "-b", "main", "--quiet"])+ configure_git_env(Cmd::new("git"), test_gitconfig_path())+ .args(git_args.iter().copied()).current_dir(path).run().unwrap();- let root = canonicalize(path).unwrap();- let repo = Repository::at(&root).unwrap();- repo.run_command(&["config", "user.name", "Test User"])- .unwrap();- repo.run_command(&["config", "user.email", "[email protected]"])- .unwrap();-- Self {- temp_dir: config_dir,- root: root.clone(),- repo,- worktrees: HashMap::new(),- remote: None,- test_config_path,- test_approvals_path,- git_config_path,- mock_bin_path: None,- claude_installed: false,- codex_installed: false,- opencode_installed: false,- gemini_installed: false,- detect_clis_via_path: false,- }+ Self::assemble(config_dir, path, paths)}/// Create an empty test repository (no commits, no branches).@@ -1113,38 +1207,44 @@ impl TestRepo {Self::init_repo(&["init", "-q"])}- /// Shared initializer for `new()` and `empty()`.- ///- /// Creates a tempdir, writes gitconfig, runs `git init` with the given- /// arguments, and returns a `TestRepo` with no commits and no identity- /// in local config. Callers add identity or other setup as needed.+ /// Shared initializer for `new()`, `bare()`, and `empty()`: makes a tempdir+ /// and runs `git init` with the given arguments inside it.fn init_repo(git_args: &[&str]) -> Self {let temp_dir = TempDir::new().unwrap();let root = temp_dir.path().join("repo");std::fs::create_dir(&root).unwrap();- let test_config_path = temp_dir.path().join("test-config.toml");- let test_approvals_path = temp_dir.path().join("test-approvals.toml");- let git_config_path = temp_dir.path().join("test-gitconfig");- write_test_gitconfig(&git_config_path);+ let paths = TestConfigPaths::in_dir(temp_dir.path());- configure_git_env(Cmd::new("git"), &git_config_path)+ configure_git_env(Cmd::new("git"), test_gitconfig_path()).args(git_args.iter().copied()).current_dir(&root).run().unwrap();- let root = canonicalize(&root).unwrap();+ Self::assemble(temp_dir, &root, paths)+ }++ /// Assemble a `TestRepo` around a git repo that already exists at `root`.+ ///+ /// Every constructor lands here, which is what lets+ /// [`write_local_test_config`] be unconditional: a repo built by a future+ /// constructor carries those settings by construction rather than by+ /// remembering to ask for them.+ fn assemble(temp_dir: TempDir, root: &Path, paths: TestConfigPaths) -> Self {+ // Canonicalize to resolve symlinks (on macOS /var is a symlink to /private/var)+ let root = canonicalize(root).unwrap();+ let repo = Repository::at(&root).unwrap();+ write_local_test_config(&repo);Self {temp_dir,- root: root.clone(),- repo: Repository::at(&root).unwrap(),+ root,+ repo,worktrees: HashMap::new(),remote: None,- test_config_path,- test_approvals_path,- git_config_path,+ test_config_path: paths.wt,+ test_approvals_path: paths.approvals,mock_bin_path: None,claude_installed: false,codex_installed: false,@@ -1159,7 +1259,7 @@ impl TestRepo {/// This sets environment variables only for the specific command,/// ensuring thread-safety and test isolation.pub fn configure_git_cmd(&self, cmd: &mut Command) {- configure_git_cmd(cmd, &self.git_config_path);+ configure_git_cmd(cmd, test_gitconfig_path());}/// This repo's environment for a PTY-spawned wt subprocess.@@ -1170,7 +1270,6 @@ impl TestRepo {#[cfg_attr(windows, allow(dead_code))] // Used only by unix PTY testspub fn test_env_vars(&self) -> Vec<(String, String)> {pty_env_vars(TestEnvPaths {- git_config: &self.git_config_path,home: self.home_path(),wt_config: self.test_config_path(),approvals: self.test_approvals_path(),@@ -1205,7 +1304,7 @@ impl TestRepo {/// ```#[must_use]pub fn git_command(&self) -> Cmd {- configure_git_env(Cmd::new("git"), &self.git_config_path).current_dir(&self.root)+ configure_git_env(Cmd::new("git"), test_gitconfig_path()).current_dir(&self.root)}/// Run a git command in the repo root, panicking on failure.@@ -1369,8 +1468,7 @@ impl TestRepo {/// ```text/// home_path()//// ├── repo/ # The git repository (root_path())- /// ├── test-config.toml # WORKTRUNK_CONFIG_PATH target- /// └── test-gitconfig # GIT_CONFIG_GLOBAL target+ /// └── test-config.toml # WORKTRUNK_CONFIG_PATH target/// ```pub fn home_path(&self) -> &Path {self.temp_dir.path()@@ -1408,7 +1506,7 @@ impl TestRepo {/// Get the project identifier (canonical path) for this test repo.////// Returns the full canonical path of the repository. The standard fixture uses a local- /// path remote (`../origin_git`) which doesn't parse as a proper git URL, causing+ /// path remote (`../origin.git`) which doesn't parse as a proper git URL, causing/// worktrunk to fall back to the full canonical path.////// Use with TOML literal strings (single quotes) to avoid backslash escaping:@@ -2594,7 +2692,7 @@ impl TestRepo {impl TestRepoBase for TestRepo {fn git_config_path(&self) -> &Path {- &self.git_config_path+ test_gitconfig_path()}}@@ -2603,12 +2701,17 @@ impl TestRepoBase for TestRepo {/// Bare repositories are useful for testing scenarios where you need worktrees/// for the default branch (which isn't possible with normal repos since the/// main worktree already has it checked out).+///+/// A thin composition over [`TestRepo::bare()`], so construction routes+/// through `TestRepo::assemble` and inherits everything it guarantees+/// (canonicalized root, `LOCAL_TEST_CONFIG`). What it adds is the bare+/// fixture style: worktrees created *inside* the repo directory (via the+/// `worktree-path` template), and `wt` commands that keep the terminal's+/// plain output (`configure_wt_cmd` strips `CLICOLOR_FORCE`, sets no temp+/// home, and leaves the working directory to the caller) — the style the+/// bare-repo snapshot suite is written against.pub struct BareRepoTest {- temp_dir: tempfile::TempDir,- bare_repo_path: PathBuf,- test_config_path: PathBuf,- test_approvals_path: PathBuf,- git_config_path: PathBuf,+ repo: TestRepo,}impl BareRepoTest {@@ -2618,71 +2721,39 @@ impl BareRepoTest {/// to be created as subdirectories (e.g., `repo/main`, `repo/feature`).#[allow(clippy::new_without_default)]pub fn new() -> Self {- let temp_dir = tempfile::TempDir::new().unwrap();- // Bare repo without .git suffix - worktrees go inside as subdirectories- let bare_repo_path = temp_dir.path().join("repo");- let test_config_path = temp_dir.path().join("test-config.toml");- let test_approvals_path = temp_dir.path().join("test-approvals.toml");- let git_config_path = temp_dir.path().join("test-gitconfig");-- write_test_gitconfig(&git_config_path);-- let mut test = Self {- temp_dir,- bare_repo_path,- test_config_path,- test_approvals_path,- git_config_path,- };-- // Create bare repository- let output = configure_git_env(Cmd::new("git"), &test.git_config_path)- .args(["init", "--bare", "--initial-branch", "main"])- .arg(test.bare_repo_path.to_str().unwrap())- .run()- .unwrap();-- if !output.status.success() {- panic!(- "Failed to init bare repo:\nstdout: {}\nstderr: {}",- String::from_utf8_lossy(&output.stdout),- String::from_utf8_lossy(&output.stderr)- );- }-- // Canonicalize path (using dunce to avoid \\?\ prefix on Windows)- test.bare_repo_path = canonicalize(&test.bare_repo_path).unwrap();-- // Write config with template for worktrees inside bare repo+ let repo = TestRepo::bare();// Template {{ branch }} creates worktrees as subdirectories: repo/main, repo/feature- std::fs::write(&test.test_config_path, "worktree-path = \"{{ branch }}\"\n").unwrap();-- test+ std::fs::write(+ repo.test_config_path(),+ "worktree-path = \"{{ branch }}\"\n",+ )+ .unwrap();+ Self { repo }}/// Get the path to the bare repository.pub fn bare_repo_path(&self) -> &Path {- &self.bare_repo_path+ self.repo.path()}/// Get the path to the test config file.pub fn config_path(&self) -> &Path {- &self.test_config_path+ self.repo.test_config_path()}/// Get the temp directory path.pub fn temp_path(&self) -> &Path {- self.temp_dir.path()+ self.repo.home_path()}/// Create a worktree from the bare repository.////// Worktrees are created inside the bare repo directory: repo/main, repo/featurepub fn create_worktree(&self, branch: &str, worktree_name: &str) -> PathBuf {- let worktree_path = self.bare_repo_path.join(worktree_name);+ let worktree_path = self.repo.path().join(worktree_name);let output = self- .git_command(&self.bare_repo_path)+ .git_command(self.repo.path()).args(["worktree","add",@@ -2707,12 +2778,12 @@ impl BareRepoTest {/// Configure a wt command with test environment.pub fn configure_wt_cmd(&self, cmd: &mut Command) {self.configure_git_cmd(cmd);- cmd.env("WORKTRUNK_CONFIG_PATH", &self.test_config_path)+ cmd.env("WORKTRUNK_CONFIG_PATH", self.repo.test_config_path()).env("WORKTRUNK_SYSTEM_CONFIG_PATH","/etc/xdg/worktrunk/config.toml",)- .env("WORKTRUNK_APPROVALS_PATH", &self.test_approvals_path)+ .env("WORKTRUNK_APPROVALS_PATH", self.repo.test_approvals_path()).env_remove("NO_COLOR").env_remove("CLICOLOR_FORCE");}@@ -2727,7 +2798,7 @@ impl BareRepoTest {impl TestRepoBase for BareRepoTest {fn git_config_path(&self) -> &Path {- &self.git_config_path+ test_gitconfig_path()}}@@ -3208,6 +3279,128 @@ mod tests {);}+ /// The env deny above rides on `Cmd`s the harness builds. A unit test that+ /// drives the library directly — `Repository::run_command` and everything+ /// layered on it — spawns git with the *test process's* environment, which+ /// carries no `GIT_ALLOW_PROTOCOL`, so that deny has to be in the repo's+ /// own config to reach it (see [`LOCAL_TEST_CONFIG`]).+ ///+ /// That environment includes the host locale, so the assertions can't+ /// match git's message text (`transport 'https' not allowed` translates —+ /// e.g. `Übertragungsart 'https' nicht erlaubt`). What is locale-stable is+ /// the URL: a refusal never names the host, while a real connect attempt+ /// interpolates it verbatim (`konnte nicht auf 'https://127.0.0.1:1/…'+ /// zugreifen: Failed to connect…`) — port 1 keeps that pre-fix path+ /// offline and instant.+ #[test]+ fn test_in_process_git_allows_local_paths_only() {+ let repo = TestRepo::with_initial_commit();+ let ls_remote = |url: &str| {+ repo.repo+ .current_worktree()+ .run_command_output(&["ls-remote", "--symref", url, "HEAD"])+ .unwrap()+ };++ // `protocol.allow = never` would take local remotes down with the+ // network ones without the `file` exception beside it.+ let local = ls_remote(&path_slash::PathExt::to_slash_lossy(repo.root_path()));+ let local_stderr = String::from_utf8_lossy(&local.stderr);+ assert!(+ local.status.success(),+ "local-path remote must still resolve: {local_stderr}"+ );++ let remote = ls_remote("https://127.0.0.1:1/test-owner/test-repo.git");+ let stderr = String::from_utf8_lossy(&remote.stderr);+ assert!(+ !remote.status.success(),+ "https transport must be refused in-process"+ );+ assert!(+ !stderr.contains("127.0.0.1"),+ "git walked to the wire instead of refusing the transport: {stderr}"+ );+ }++ /// Both outcomes of the template claim: an uncontested build renames the+ /// scratch into place, and a builder that loses the race — the final dir+ /// appears while it builds, the exact timing two cold-cache builders+ /// produce — keeps the winner's template and removes its own scratch.+ #[test]+ fn test_claim_template_winner_and_loser() {+ let parent = TempDir::new().unwrap();+ let dir = parent.path().join("template-v1");++ claim_template(parent.path(), &dir, |scratch| {+ std::fs::write(scratch.join("marker"), "winner").unwrap();+ });+ assert_eq!(+ std::fs::read_to_string(dir.join("marker")).unwrap(),+ "winner"+ );++ // Losing builder: `dir` exists by the time it renames.+ let dir2 = parent.path().join("template-v2");+ claim_template(parent.path(), &dir2, |scratch| {+ std::fs::create_dir(&dir2).unwrap();+ std::fs::write(dir2.join("marker"), "winner").unwrap();+ std::fs::write(scratch.join("marker"), "loser").unwrap();+ });+ assert_eq!(+ std::fs::read_to_string(dir2.join("marker")).unwrap(),+ "winner"+ );++ // Only the two templates remain — both scratch dirs are gone.+ let entries: Vec<_> = std::fs::read_dir(parent.path())+ .unwrap()+ .map(|e| e.unwrap().file_name().into_string().unwrap())+ .collect();+ let mut sorted = entries.clone();+ sorted.sort();+ assert_eq!(+ sorted,+ ["template-v1", "template-v2"],+ "scratch dirs must not linger"+ );+ }++ /// The template must reproduce the exact commits the committed snapshots+ /// were recorded against: ~170 snapshots embed these SHAs in short form+ /// (via `wt list` output and mock CI payloads). If this fails after+ /// editing [`build_standard_fixture`], the fixture's history changed:+ /// bump [`STANDARD_FIXTURE_VERSION`], update these SHAs, and regenerate+ /// the affected snapshots.+ #[test]+ fn test_standard_fixture_template_reproduces_pinned_shas() {+ let repo = standard_fixture_template().join("repo");+ let rev_parse = |rev: &str| {+ let output = configure_git_env(Cmd::new("git"), test_gitconfig_path())+ .args(["rev-parse", rev])+ .current_dir(&repo)+ .run()+ .unwrap();+ String::from_utf8(output.stdout).unwrap().trim().to_string()+ };+ assert_eq!(+ rev_parse("main"),+ "05a4a45d0b981dad5c27db59dca482836d59f89e"+ );+ assert_eq!(+ rev_parse("feature-a"),+ "1b87d4731ea707905d15a726e193531c20affa14"+ );+ assert_eq!(+ rev_parse("feature-b"),+ "f62940fcec424585adf98625e722fdf990810614"+ );+ assert_eq!(+ rev_parse("feature-c"),+ "345c7c93ad7c3d8f5b08380898d78e024019599c"+ );+ }+#[test]fn test_unix_to_iso8601() {// 2025-01-01T00:00:00Zdiff --git a/tests/CLAUDE.md b/tests/CLAUDE.mdindex ea4934725..b4f4997c0 100644--- a/tests/CLAUDE.md+++ b/tests/CLAUDE.md@@ -103,10 +103,11 @@ call `.current_dir(...)` explicitly.### Where a new environment variable goes-A test child's environment is three layers, each with one home in+A test child's environment is four layers, each with one home in`src/testing/mod.rs`: `STATIC_TEST_ENV_VARS` for a determinism knob every child-needs, `PTY_TEST_ENV_VARS` for one only a terminal triggers, and `pty_env_vars`-for a path that varies per fixture. `configure_cli_command` and+needs, `git_test_env` for git isolation (config, timestamps, the transport+deny), `PTY_TEST_ENV_VARS` for a knob only a terminal triggers, and+`pty_env_vars` for a path that varies per fixture. `configure_cli_command` and`configure_pty_command` apply them by transport, so a variable added to theright layer reaches every test that spawns `wt`. A per-builder copy reaches onlythe tests that happen to use that builder, and the ones it misses fail later,@@ -149,6 +150,17 @@ approvals.approve_command(project, command, &approvals_path).unwrap();</good></example>+Git needs the same care. An in-process `Repository::run_command()` spawns git+with the test process's environment, so it reads the developer's real+`~/.gitconfig` and none of `configure_git_env`'s variables — no+`GIT_CONFIG_GLOBAL`, no `GIT_ALLOW_PROTOCOL`. The repo's own config is the one+layer such a command still reads, so every `TestRepo` constructor appends+`LOCAL_TEST_CONFIG` (identity, `commit.gpgsign`, and the `protocol.allow`+transport deny) to it. `TestRepo::assemble` is the single call site; a new+constructor routes through it and inherits the settings, and the bare+fixtures (`BareRepoTest`, `NestedBareRepoTest`) get them by composing over+`TestRepo`.+`approvals_path()` panics when `WORKTRUNK_APPROVALS_PATH` is unset, but`#[cfg(test)]` makes that guard fire only for `worktrunk` lib-crate tests. Abin-crate test (anything under `src/commands/`) links the lib in non-testdiff --git a/tests/fixtures/standard/.gitattributes b/tests/fixtures/standard/.gitattributesdeleted file mode 100644index 49768657b..000000000--- a/tests/fixtures/standard/.gitattributes+++ /dev/null@@ -1,7 +0,0 @@-# Ensure git internal files always use LF line endings-# These files are part of the test fixture and must not have CRLF-**/packed-refs text eol=lf-**/HEAD text eol=lf-**/config text eol=lf-**/_git text eol=lf-**/gitdir text eol=lfdiff --git a/tests/fixtures/standard/origin_git/HEAD b/tests/fixtures/standard/origin_git/HEADdeleted file mode 100644index b870d8262..000000000--- a/tests/fixtures/standard/origin_git/HEAD+++ /dev/null@@ -1 +0,0 @@-ref: refs/heads/maindiff --git a/tests/fixtures/standard/origin_git/config b/tests/fixtures/standard/origin_git/configdeleted file mode 100644index e6da23157..000000000--- a/tests/fixtures/standard/origin_git/config+++ /dev/null@@ -1,6 +0,0 @@-[core]- repositoryformatversion = 0- filemode = true- bare = true- ignorecase = true- precomposeunicode = truediff --git a/tests/fixtures/standard/origin_git/objects/05/a4a45d0b981dad5c27db59dca482836d59f89e b/tests/fixtures/standard/origin_git/objects/05/a4a45d0b981dad5c27db59dca482836d59f89edeleted file mode 100644index b325244fc..000000000--- a/tests/fixtures/standard/origin_git/objects/05/a4a45d0b981dad5c27db59dca482836d59f89e+++ /dev/null@@ -1,3 +0,0 @@-x��K-1D]�}%��dq�^�O��dZ��<�����*�Z�Zԁ;����e:)�٢�'G*��$Kθ ����Ýv��N�<�>��V:�V/ÊzQv���J)F;�x����m+\�-?��ß7O\ No newline at end of filediff --git a/tests/fixtures/standard/origin_git/objects/36/c83deb35b9f3b5d103f838429e1f626d8e969b b/tests/fixtures/standard/origin_git/objects/36/c83deb35b9f3b5d103f838429e1f626d8e969bdeleted file mode 100644index 49332c870..000000000Binary files a/tests/fixtures/standard/origin_git/objects/36/c83deb35b9f3b5d103f838429e1f626d8e969b and /dev/null differdiff --git a/tests/fixtures/standard/origin_git/objects/63/13b56c57848efce05faa7aa7e901ccfc2886ea b/tests/fixtures/standard/origin_git/objects/63/13b56c57848efce05faa7aa7e901ccfc2886eadeleted file mode 100644index 18ba92c92..000000000Binary files a/tests/fixtures/standard/origin_git/objects/63/13b56c57848efce05faa7aa7e901ccfc2886ea and /dev/null differdiff --git a/tests/fixtures/standard/origin_git/objects/f2/376e2bab6c5194410bd8a55630f83f933d2f34 b/tests/fixtures/standard/origin_git/objects/f2/376e2bab6c5194410bd8a55630f83f933d2f34deleted file mode 100644index 758356d63..000000000Binary files a/tests/fixtures/standard/origin_git/objects/f2/376e2bab6c5194410bd8a55630f83f933d2f34 and /dev/null differdiff --git a/tests/fixtures/standard/origin_git/objects/info/.gitkeep b/tests/fixtures/standard/origin_git/objects/info/.gitkeepdeleted file mode 100644index e69de29bb..000000000diff --git a/tests/fixtures/standard/origin_git/objects/pack/.gitkeep b/tests/fixtures/standard/origin_git/objects/pack/.gitkeepdeleted file mode 100644index e69de29bb..000000000diff --git a/tests/fixtures/standard/origin_git/packed-refs b/tests/fixtures/standard/origin_git/packed-refsdeleted file mode 100644index 2c6b05039..000000000--- a/tests/fixtures/standard/origin_git/packed-refs+++ /dev/null@@ -1,2 +0,0 @@-# pack-refs with: peeled fully-peeled sorted-05a4a45d0b981dad5c27db59dca482836d59f89e refs/heads/maindiff --git a/tests/fixtures/standard/origin_git/refs/heads/.gitkeep b/tests/fixtures/standard/origin_git/refs/heads/.gitkeepdeleted file mode 100644index e69de29bb..000000000diff --git a/tests/fixtures/standard/origin_git/refs/tags/.gitkeep b/tests/fixtures/standard/origin_git/refs/tags/.gitkeepdeleted file mode 100644index e69de29bb..000000000diff --git a/tests/fixtures/standard/repo.feature-a/.gitattributes b/tests/fixtures/standard/repo.feature-a/.gitattributesdeleted file mode 100644index 6313b56c5..000000000--- a/tests/fixtures/standard/repo.feature-a/.gitattributes+++ /dev/null@@ -1 +0,0 @@-* text=auto eol=lfdiff --git a/tests/fixtures/standard/repo.feature-a/_git b/tests/fixtures/standard/repo.feature-a/_gitdeleted file mode 100644index 0c7059880..000000000--- a/tests/fixtures/standard/repo.feature-a/_git+++ /dev/null@@ -1 +0,0 @@-gitdir: ../repo/_git/worktrees/repo.feature-adiff --git a/tests/fixtures/standard/repo.feature-a/feature-a.txt b/tests/fixtures/standard/repo.feature-a/feature-a.txtdeleted file mode 100644index b65f36274..000000000--- a/tests/fixtures/standard/repo.feature-a/feature-a.txt+++ /dev/null@@ -1 +0,0 @@-feature-a contentdiff --git a/tests/fixtures/standard/repo.feature-a/file.txt b/tests/fixtures/standard/repo.feature-a/file.txtdeleted file mode 100644index f2376e2ba..000000000--- a/tests/fixtures/standard/repo.feature-a/file.txt+++ /dev/null@@ -1 +0,0 @@-initial contentdiff --git a/tests/fixtures/standard/repo.feature-b/.gitattributes b/tests/fixtures/standard/repo.feature-b/.gitattributesdeleted file mode 100644index 6313b56c5..000000000--- a/tests/fixtures/standard/repo.feature-b/.gitattributes+++ /dev/null@@ -1 +0,0 @@-* text=auto eol=lfdiff --git a/tests/fixtures/standard/repo.feature-b/_git b/tests/fixtures/standard/repo.feature-b/_gitdeleted file mode 100644index 60fcb4cfb..000000000--- a/tests/fixtures/standard/repo.feature-b/_git+++ /dev/null@@ -1 +0,0 @@-gitdir: ../repo/_git/worktrees/repo.feature-bdiff --git a/tests/fixtures/standard/repo.feature-b/feature-b.txt b/tests/fixtures/standard/repo.feature-b/feature-b.txtdeleted file mode 100644index 50bf5f908..000000000--- a/tests/fixtures/standard/repo.feature-b/feature-b.txt+++ /dev/null@@ -1 +0,0 @@-feature-b contentdiff --git a/tests/fixtures/standard/repo.feature-b/file.txt b/tests/fixtures/standard/repo.feature-b/file.txtdeleted file mode 100644index f2376e2ba..000000000--- a/tests/fixtures/standard/repo.feature-b/file.txt+++ /dev/null@@ -1 +0,0 @@-initial contentdiff --git a/tests/fixtures/standard/repo.feature-c/.gitattributes b/tests/fixtures/standard/repo.feature-c/.gitattributesdeleted file mode 100644index 6313b56c5..000000000--- a/tests/fixtures/standard/repo.feature-c/.gitattributes+++ /dev/null@@ -1 +0,0 @@-* text=auto eol=lfdiff --git a/tests/fixtures/standard/repo.feature-c/_git b/tests/fixtures/standard/repo.feature-c/_gitdeleted file mode 100644index 58b82dbd5..000000000--- a/tests/fixtures/standard/repo.feature-c/_git+++ /dev/null@@ -1 +0,0 @@-gitdir: ../repo/_git/worktrees/repo.feature-cdiff --git a/tests/fixtures/standard/repo.feature-c/feature-c.txt b/tests/fixtures/standard/repo.feature-c/feature-c.txtdeleted file mode 100644index c52c448c9..000000000--- a/tests/fixtures/standard/repo.feature-c/feature-c.txt+++ /dev/null@@ -1 +0,0 @@-feature-c contentdiff --git a/tests/fixtures/standard/repo.feature-c/file.txt b/tests/fixtures/standard/repo.feature-c/file.txtdeleted file mode 100644index f2376e2ba..000000000--- a/tests/fixtures/standard/repo.feature-c/file.txt+++ /dev/null@@ -1 +0,0 @@-initial contentdiff --git a/tests/fixtures/standard/repo/.gitattributes b/tests/fixtures/standard/repo/.gitattributesdeleted file mode 100644index 6313b56c5..000000000--- a/tests/fixtures/standard/repo/.gitattributes+++ /dev/null@@ -1 +0,0 @@-* text=auto eol=lfdiff --git a/tests/fixtures/standard/repo/_git/COMMIT_EDITMSG b/tests/fixtures/standard/repo/_git/COMMIT_EDITMSGdeleted file mode 100644index 5852f4463..000000000--- a/tests/fixtures/standard/repo/_git/COMMIT_EDITMSG+++ /dev/null@@ -1 +0,0 @@-Initial commitdiff --git a/tests/fixtures/standard/repo/_git/HEAD b/tests/fixtures/standard/repo/_git/HEADdeleted file mode 100644index b870d8262..000000000--- a/tests/fixtures/standard/repo/_git/HEAD+++ /dev/null@@ -1 +0,0 @@-ref: refs/heads/maindiff --git a/tests/fixtures/standard/repo/_git/MERGE_RR b/tests/fixtures/standard/repo/_git/MERGE_RRdeleted file mode 100644index e69de29bb..000000000diff --git a/tests/fixtures/standard/repo/_git/config b/tests/fixtures/standard/repo/_git/configdeleted file mode 100644index c7b21ac31..000000000--- a/tests/fixtures/standard/repo/_git/config+++ /dev/null@@ -1,18 +0,0 @@-[core]- repositoryformatversion = 0- filemode = true- bare = false- logallrefupdates = true- ignorecase = true- precomposeunicode = true-[user]- name = Test User- email = [email protected]-[commit]- gpgsign = false-[remote "origin"]- url = ../origin_git- fetch = +refs/heads/*:refs/remotes/origin/*-[branch "main"]- remote = origin- merge = refs/heads/maindiff --git a/tests/fixtures/standard/repo/_git/index b/tests/fixtures/standard/repo/_git/indexdeleted file mode 100644index c5b6ba4b6..000000000Binary files a/tests/fixtures/standard/repo/_git/index and /dev/null differdiff --git a/tests/fixtures/standard/repo/_git/logs/HEAD b/tests/fixtures/standard/repo/_git/logs/HEADdeleted file mode 100644index 6a8e3979a..000000000--- a/tests/fixtures/standard/repo/_git/logs/HEAD+++ /dev/null@@ -1 +0,0 @@-0000000000000000000000000000000000000000 05a4a45d0b981dad5c27db59dca482836d59f89e Test User <[email protected]> 1735718400 -0800 commit (initial): Initial commitdiff --git a/tests/fixtures/standard/repo/_git/logs/refs/heads/feature-a b/tests/fixtures/standard/repo/_git/logs/refs/heads/feature-adeleted file mode 100644index 107380906..000000000--- a/tests/fixtures/standard/repo/_git/logs/refs/heads/feature-a+++ /dev/null@@ -1,2 +0,0 @@-0000000000000000000000000000000000000000 05a4a45d0b981dad5c27db59dca482836d59f89e Test User <[email protected]> 1768425029 -0800 branch: Created from HEAD-05a4a45d0b981dad5c27db59dca482836d59f89e 1b87d4731ea707905d15a726e193531c20affa14 Test User <[email protected]> 1735718400 -0800 commit: Add feature-a filediff --git a/tests/fixtures/standard/repo/_git/logs/refs/heads/feature-b b/tests/fixtures/standard/repo/_git/logs/refs/heads/feature-bdeleted file mode 100644index 45e10a634..000000000--- a/tests/fixtures/standard/repo/_git/logs/refs/heads/feature-b+++ /dev/null@@ -1,2 +0,0 @@-0000000000000000000000000000000000000000 05a4a45d0b981dad5c27db59dca482836d59f89e Test User <[email protected]> 1768425030 -0800 branch: Created from HEAD-05a4a45d0b981dad5c27db59dca482836d59f89e f62940fcec424585adf98625e722fdf990810614 Test User <[email protected]> 1735718400 -0800 commit: Add feature-b filediff --git a/tests/fixtures/standard/repo/_git/logs/refs/heads/feature-c b/tests/fixtures/standard/repo/_git/logs/refs/heads/feature-cdeleted file mode 100644index 514104a97..000000000--- a/tests/fixtures/standard/repo/_git/logs/refs/heads/feature-c+++ /dev/null@@ -1,2 +0,0 @@-0000000000000000000000000000000000000000 05a4a45d0b981dad5c27db59dca482836d59f89e Test User <[email protected]> 1768425030 -0800 branch: Created from HEAD-05a4a45d0b981dad5c27db59dca482836d59f89e 345c7c93ad7c3d8f5b08380898d78e024019599c Test User <[email protected]> 1735718400 -0800 commit: Add feature-c filediff --git a/tests/fixtures/standard/repo/_git/logs/refs/heads/main b/tests/fixtures/standard/repo/_git/logs/refs/heads/maindeleted file mode 100644index 6a8e3979a..000000000--- a/tests/fixtures/standard/repo/_git/logs/refs/heads/main+++ /dev/null@@ -1 +0,0 @@-0000000000000000000000000000000000000000 05a4a45d0b981dad5c27db59dca482836d59f89e Test User <[email protected]> 1735718400 -0800 commit (initial): Initial commitdiff --git a/tests/fixtures/standard/repo/_git/logs/refs/remotes/origin/main b/tests/fixtures/standard/repo/_git/logs/refs/remotes/origin/maindeleted file mode 100644index e241a8e0c..000000000--- a/tests/fixtures/standard/repo/_git/logs/refs/remotes/origin/main+++ /dev/null@@ -1 +0,0 @@-0000000000000000000000000000000000000000 05a4a45d0b981dad5c27db59dca482836d59f89e Test User <[email protected]> 1768425029 -0800 update by pushdiff --git a/tests/fixtures/standard/repo/_git/objects/05/a4a45d0b981dad5c27db59dca482836d59f89e b/tests/fixtures/standard/repo/_git/objects/05/a4a45d0b981dad5c27db59dca482836d59f89edeleted file mode 100644index b325244fc..000000000--- a/tests/fixtures/standard/repo/_git/objects/05/a4a45d0b981dad5c27db59dca482836d59f89e+++ /dev/null@@ -1,3 +0,0 @@-x��K-1D]�}%��dq�^�O��dZ��<�����*�Z�Zԁ;����e:)�٢�'G*��$Kθ ����Ýv��N�<�>��V:�V/ÊzQv���J)F;�x����m+\�-?��ß7O\ No newline at end of filediff --git a/tests/fixtures/standard/repo/_git/objects/06/64db7d9288255732c25f781d12776b2a1dacd3 b/tests/fixtures/standard/repo/_git/objects/06/64db7d9288255732c25f781d12776b2a1dacd3deleted file mode 100644index e96723649..000000000Binary files a/tests/fixtures/standard/repo/_git/objects/06/64db7d9288255732c25f781d12776b2a1dacd3 and /dev/null differdiff --git a/tests/fixtures/standard/repo/_git/objects/0a/c7152205cb4a7515a71568e8d6f811ef1862e1 b/tests/fixtures/standard/repo/_git/objects/0a/c7152205cb4a7515a71568e8d6f811ef1862e1deleted file mode 100644index 5850e9dc1..000000000Binary files a/tests/fixtures/standard/repo/_git/objects/0a/c7152205cb4a7515a71568e8d6f811ef1862e1 and /dev/null differdiff --git a/tests/fixtures/standard/repo/_git/objects/1b/87d4731ea707905d15a726e193531c20affa14 b/tests/fixtures/standard/repo/_git/objects/1b/87d4731ea707905d15a726e193531c20affa14deleted file mode 100644index 60877e43c..000000000--- a/tests/fixtures/standard/repo/_git/objects/1b/87d4731ea707905d15a726e193531c20affa14+++ /dev/null@@ -1,2 +0,0 @@-x��Q-�0��)��d�m�;���-�-1��7W�ox̃)ۺ. ��UU��d��1%$����1��.���U_ ,q�@b��*e�,�C��G�<���?��U�����N��E���O=�m=����K�Zl����n��3W��ۧ��0/O5?�E�\ No newline at end of filediff --git a/tests/fixtures/standard/repo/_git/objects/34/5c7c93ad7c3d8f5b08380898d78e024019599c b/tests/fixtures/standard/repo/_git/objects/34/5c7c93ad7c3d8f5b08380898d78e024019599cdeleted file mode 100644index 3aee59357..000000000--- a/tests/fixtures/standard/repo/_git/objects/34/5c7c93ad7c3d8f5b08380898d78e024019599c+++ /dev/null@@ -1 +0,0 @@-x��Qj1D��S� ��Zk������L�lp���+�o�1���v��t��PK&���I3�賸�\��+���S�?: k�Ć�"dj\b��+�$�4/U�����:\^����=�~*�� �'�$ �(�a�����p6����͏������E�\ No newline at end of filediff --git a/tests/fixtures/standard/repo/_git/objects/36/c83deb35b9f3b5d103f838429e1f626d8e969b b/tests/fixtures/standard/repo/_git/objects/36/c83deb35b9f3b5d103f838429e1f626d8e969bdeleted file mode 100644index 49332c870..000000000Binary files a/tests/fixtures/standard/repo/_git/objects/36/c83deb35b9f3b5d103f838429e1f626d8e969b and /dev/null differdiff --git a/tests/fixtures/standard/repo/_git/objects/50/bf5f908b3a3d39dfbd19d219c265bc1c8471df b/tests/fixtures/standard/repo/_git/objects/50/bf5f908b3a3d39dfbd19d219c265bc1c8471dfdeleted file mode 100644index dac82f9be..000000000Binary files a/tests/fixtures/standard/repo/_git/objects/50/bf5f908b3a3d39dfbd19d219c265bc1c8471df and /dev/null differdiff --git a/tests/fixtures/standard/repo/_git/objects/63/13b56c57848efce05faa7aa7e901ccfc2886ea b/tests/fixtures/standard/repo/_git/objects/63/13b56c57848efce05faa7aa7e901ccfc2886eadeleted file mode 100644index 18ba92c92..000000000Binary files a/tests/fixtures/standard/repo/_git/objects/63/13b56c57848efce05faa7aa7e901ccfc2886ea and /dev/null differdiff --git a/tests/fixtures/standard/repo/_git/objects/b6/5f3627464edc75c2a61f859bb0799d215495e3 b/tests/fixtures/standard/repo/_git/objects/b6/5f3627464edc75c2a61f859bb0799d215495e3deleted file mode 100644index 5c1023a68..000000000Binary files a/tests/fixtures/standard/repo/_git/objects/b6/5f3627464edc75c2a61f859bb0799d215495e3 and /dev/null differdiff --git a/tests/fixtures/standard/repo/_git/objects/c5/2c448c99cf63bd4934e45cb759d4b57637b921 b/tests/fixtures/standard/repo/_git/objects/c5/2c448c99cf63bd4934e45cb759d4b57637b921deleted file mode 100644index 7e2ae56c4..000000000Binary files a/tests/fixtures/standard/repo/_git/objects/c5/2c448c99cf63bd4934e45cb759d4b57637b921 and /dev/null differdiff --git a/tests/fixtures/standard/repo/_git/objects/eb/0a17dea104217bd4169f79b56e2d7c736fe94c b/tests/fixtures/standard/repo/_git/objects/eb/0a17dea104217bd4169f79b56e2d7c736fe94cdeleted file mode 100644index 0bcea3432..000000000Binary files a/tests/fixtures/standard/repo/_git/objects/eb/0a17dea104217bd4169f79b56e2d7c736fe94c and /dev/null differdiff --git a/tests/fixtures/standard/repo/_git/objects/f2/376e2bab6c5194410bd8a55630f83f933d2f34 b/tests/fixtures/standard/repo/_git/objects/f2/376e2bab6c5194410bd8a55630f83f933d2f34deleted file mode 100644index 758356d63..000000000Binary files a/tests/fixtures/standard/repo/_git/objects/f2/376e2bab6c5194410bd8a55630f83f933d2f34 and /dev/null differdiff --git a/tests/fixtures/standard/repo/_git/objects/f6/2940fcec424585adf98625e722fdf990810614 b/tests/fixtures/standard/repo/_git/objects/f6/2940fcec424585adf98625e722fdf990810614deleted file mode 100644index 4a2c109f3..000000000--- a/tests/fixtures/standard/repo/_git/objects/f6/2940fcec424585adf98625e722fdf990810614+++ /dev/null@@ -1,2 +0,0 @@-x��[-�0E��*f�ɫI@D���d&X���)�|��.�s��e����So" I����S )�Q��X%��Vj�逞9ϘS�L� �}�B.�hG���$���Z<d��ܤ���&_���2_A냎���ǻ~��u��U��M�uz��=�Fm\ No newline at end of filediff --git a/tests/fixtures/standard/repo/_git/objects/info/.gitkeep b/tests/fixtures/standard/repo/_git/objects/info/.gitkeepdeleted file mode 100644index e69de29bb..000000000diff --git a/tests/fixtures/standard/repo/_git/objects/pack/.gitkeep b/tests/fixtures/standard/repo/_git/objects/pack/.gitkeepdeleted file mode 100644index e69de29bb..000000000diff --git a/tests/fixtures/standard/repo/_git/refs/heads/feature-a b/tests/fixtures/standard/repo/_git/refs/heads/feature-adeleted file mode 100644index a9335a56e..000000000--- a/tests/fixtures/standard/repo/_git/refs/heads/feature-a+++ /dev/null@@ -1 +0,0 @@-1b87d4731ea707905d15a726e193531c20affa14diff --git a/tests/fixtures/standard/repo/_git/refs/heads/feature-b b/tests/fixtures/standard/repo/_git/refs/heads/feature-bdeleted file mode 100644index 9e2fdee43..000000000--- a/tests/fixtures/standard/repo/_git/refs/heads/feature-b+++ /dev/null@@ -1 +0,0 @@-f62940fcec424585adf98625e722fdf990810614diff --git a/tests/fixtures/standard/repo/_git/refs/heads/feature-c b/tests/fixtures/standard/repo/_git/refs/heads/feature-cdeleted file mode 100644index 81f33695b..000000000--- a/tests/fixtures/standard/repo/_git/refs/heads/feature-c+++ /dev/null@@ -1 +0,0 @@-345c7c93ad7c3d8f5b08380898d78e024019599cdiff --git a/tests/fixtures/standard/repo/_git/refs/heads/main b/tests/fixtures/standard/repo/_git/refs/heads/maindeleted file mode 100644index 345edbeba..000000000--- a/tests/fixtures/standard/repo/_git/refs/heads/main+++ /dev/null@@ -1 +0,0 @@-05a4a45d0b981dad5c27db59dca482836d59f89ediff --git a/tests/fixtures/standard/repo/_git/refs/remotes/origin/main b/tests/fixtures/standard/repo/_git/refs/remotes/origin/maindeleted file mode 100644index 345edbeba..000000000--- a/tests/fixtures/standard/repo/_git/refs/remotes/origin/main+++ /dev/null@@ -1 +0,0 @@-05a4a45d0b981dad5c27db59dca482836d59f89ediff --git a/tests/fixtures/standard/repo/_git/refs/tags/.gitkeep b/tests/fixtures/standard/repo/_git/refs/tags/.gitkeepdeleted file mode 100644index e69de29bb..000000000diff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/COMMIT_EDITMSG b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/COMMIT_EDITMSGdeleted file mode 100644index e3a15ad6c..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/COMMIT_EDITMSG+++ /dev/null@@ -1 +0,0 @@-Add feature-a filediff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/HEAD b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/HEADdeleted file mode 100644index 8791ff63a..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/HEAD+++ /dev/null@@ -1 +0,0 @@-ref: refs/heads/feature-adiff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/MERGE_RR b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/MERGE_RRdeleted file mode 100644index e69de29bb..000000000diff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/ORIG_HEAD b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/ORIG_HEADdeleted file mode 100644index 345edbeba..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/ORIG_HEAD+++ /dev/null@@ -1 +0,0 @@-05a4a45d0b981dad5c27db59dca482836d59f89ediff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/commondir b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/commondirdeleted file mode 100644index aab0408ce..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/commondir+++ /dev/null@@ -1 +0,0 @@-../..diff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/gitdir b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/gitdirdeleted file mode 100644index ec20442f4..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/gitdir+++ /dev/null@@ -1 +0,0 @@-../../../../repo.feature-a/_gitdiff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/index b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/indexdeleted file mode 100644index 5b322a651..000000000Binary files a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/index and /dev/null differdiff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/logs/HEAD b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/logs/HEADdeleted file mode 100644index 41c8a4a8f..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-a/logs/HEAD+++ /dev/null@@ -1,3 +0,0 @@-0000000000000000000000000000000000000000 05a4a45d0b981dad5c27db59dca482836d59f89e Test User <[email protected]> 1768425029 -0800-05a4a45d0b981dad5c27db59dca482836d59f89e 05a4a45d0b981dad5c27db59dca482836d59f89e Test User <[email protected]> 1768425029 -0800 reset: moving to HEAD-05a4a45d0b981dad5c27db59dca482836d59f89e 1b87d4731ea707905d15a726e193531c20affa14 Test User <[email protected]> 1735718400 -0800 commit: Add feature-a filediff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/COMMIT_EDITMSG b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/COMMIT_EDITMSGdeleted file mode 100644index 7739cd356..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/COMMIT_EDITMSG+++ /dev/null@@ -1 +0,0 @@-Add feature-b filediff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/HEAD b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/HEADdeleted file mode 100644index 6c83ec9df..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/HEAD+++ /dev/null@@ -1 +0,0 @@-ref: refs/heads/feature-bdiff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/MERGE_RR b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/MERGE_RRdeleted file mode 100644index e69de29bb..000000000diff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/ORIG_HEAD b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/ORIG_HEADdeleted file mode 100644index 345edbeba..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/ORIG_HEAD+++ /dev/null@@ -1 +0,0 @@-05a4a45d0b981dad5c27db59dca482836d59f89ediff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/commondir b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/commondirdeleted file mode 100644index aab0408ce..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/commondir+++ /dev/null@@ -1 +0,0 @@-../..diff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/gitdir b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/gitdirdeleted file mode 100644index 98fce501a..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/gitdir+++ /dev/null@@ -1 +0,0 @@-../../../../repo.feature-b/_gitdiff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/index b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/indexdeleted file mode 100644index c056666c9..000000000Binary files a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/index and /dev/null differdiff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/logs/HEAD b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/logs/HEADdeleted file mode 100644index 7b3cecc3c..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-b/logs/HEAD+++ /dev/null@@ -1,3 +0,0 @@-0000000000000000000000000000000000000000 05a4a45d0b981dad5c27db59dca482836d59f89e Test User <[email protected]> 1768425030 -0800-05a4a45d0b981dad5c27db59dca482836d59f89e 05a4a45d0b981dad5c27db59dca482836d59f89e Test User <[email protected]> 1768425030 -0800 reset: moving to HEAD-05a4a45d0b981dad5c27db59dca482836d59f89e f62940fcec424585adf98625e722fdf990810614 Test User <[email protected]> 1735718400 -0800 commit: Add feature-b filediff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/COMMIT_EDITMSG b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/COMMIT_EDITMSGdeleted file mode 100644index dda93e2b7..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/COMMIT_EDITMSG+++ /dev/null@@ -1 +0,0 @@-Add feature-c filediff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/HEAD b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/HEADdeleted file mode 100644index 0150b9032..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/HEAD+++ /dev/null@@ -1 +0,0 @@-ref: refs/heads/feature-cdiff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/MERGE_RR b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/MERGE_RRdeleted file mode 100644index e69de29bb..000000000diff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/ORIG_HEAD b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/ORIG_HEADdeleted file mode 100644index 345edbeba..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/ORIG_HEAD+++ /dev/null@@ -1 +0,0 @@-05a4a45d0b981dad5c27db59dca482836d59f89ediff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/commondir b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/commondirdeleted file mode 100644index aab0408ce..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/commondir+++ /dev/null@@ -1 +0,0 @@-../..diff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/gitdir b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/gitdirdeleted file mode 100644index bec8f1ece..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/gitdir+++ /dev/null@@ -1 +0,0 @@-../../../../repo.feature-c/_gitdiff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/index b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/indexdeleted file mode 100644index 2bab158c2..000000000Binary files a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/index and /dev/null differdiff --git a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/logs/HEAD b/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/logs/HEADdeleted file mode 100644index b83b88cc1..000000000--- a/tests/fixtures/standard/repo/_git/worktrees/repo.feature-c/logs/HEAD+++ /dev/null@@ -1,3 +0,0 @@-0000000000000000000000000000000000000000 05a4a45d0b981dad5c27db59dca482836d59f89e Test User <[email protected]> 1768425030 -0800-05a4a45d0b981dad5c27db59dca482836d59f89e 05a4a45d0b981dad5c27db59dca482836d59f89e Test User <[email protected]> 1768425030 -0800 reset: moving to HEAD-05a4a45d0b981dad5c27db59dca482836d59f89e 345c7c93ad7c3d8f5b08380898d78e024019599c Test User <[email protected]> 1735718400 -0800 commit: Add feature-c filediff --git a/tests/fixtures/standard/repo/file.txt b/tests/fixtures/standard/repo/file.txtdeleted file mode 100644index f2376e2ba..000000000--- a/tests/fixtures/standard/repo/file.txt+++ /dev/null@@ -1 +0,0 @@-initial contentdiff --git a/tests/integration_tests/bare_repository.rs b/tests/integration_tests/bare_repository.rsindex f340f8018..ae0f04b29 100644--- a/tests/integration_tests/bare_repository.rs+++ b/tests/integration_tests/bare_repository.rs@@ -1,8 +1,8 @@use crate::common::{BareRepoTest, SLEEP_FOR_ABSENCE_CHECK, TestRepo, TestRepoBase, canonicalize,configure_directive_files, configure_git_cmd, configure_git_env, directive_files, repo,- setup_temp_snapshot_settings, wait_for_file, wait_for_file_content, wait_for_worktree_removed,- wt_command,+ setup_temp_snapshot_settings, test_gitconfig_path, wait_for_file, wait_for_file_content,+ wait_for_worktree_removed, wt_command,};use insta_cmd::assert_cmd_snapshot;use rstest::rstest;@@ -401,21 +401,16 @@ fn test_repo_path_via_real_git_alias_bare_dot_git_layout() {let temp_dir = tempfile::TempDir::new().unwrap();let temp_path = canonicalize(temp_dir.path()).unwrap();- // Isolated gitconfig so we don't leak the user's real git settings.- let git_config_path = temp_path.join("test-gitconfig");- fs::write(- &git_config_path,- "[user]\n\tname = Test User\n\temail = [email protected]\n\- [init]\n\tdefaultBranch = main\n",- )- .unwrap();+ // Isolated gitconfig (shared, read-only) so we don't leak the user's+ // real git settings.+ let git_config_path = test_gitconfig_path();// Layout: repo/.git (bare) + repo/main (linked worktree).let repo_dir = temp_path.join("repo");fs::create_dir(&repo_dir).unwrap();let bare_git = repo_dir.join(".git");- let git = |dir: &Path| configure_git_env(Cmd::new("git"), &git_config_path).current_dir(dir);+ let git = |dir: &Path| configure_git_env(Cmd::new("git"), git_config_path).current_dir(dir);git(&temp_path).args(["init", "--bare", "--initial-branch", "main"])@@ -468,7 +463,7 @@ fn test_repo_path_via_real_git_alias_bare_dot_git_layout() {// Shared wt env applied to both the direct and aliased invocations.let apply_wt_env = |cmd: &mut Command| {- configure_git_cmd(cmd, &git_config_path);+ configure_git_cmd(cmd, git_config_path);cmd.env("WORKTRUNK_CONFIG_PATH", &user_config).env("WORKTRUNK_SYSTEM_CONFIG_PATH",@@ -1404,82 +1399,48 @@ fn test_bare_repo_slashed_branch_with_sanitize() {////// This tests the pattern from GitHub issue #313 where users clone with:/// `git clone --bare <url> project/.git`+///+/// Composes over [`TestRepo::bare_at`], which owns the repo plumbing+/// (canonicalized root, isolated config paths, `LOCAL_TEST_CONFIG`); this+/// struct owns the project directory the bare repo nests in, plus the+/// sibling-worktree template (`../{{ branch }}`).struct NestedBareRepoTest {+ /// Owns project/; must outlive `repo`, whose path lives inside it.temp_dir: tempfile::TempDir,/// Path to the parent directory (project/)project_path: PathBuf,- /// Path to the bare repo (project/.git/)- bare_repo_path: PathBuf,+ /// Config lives in `temp_dir`, not in `repo`'s internal config dir:+ /// snapshots print this path, and their filters cover `temp_path()`.test_config_path: PathBuf,- git_config_path: PathBuf,+ repo: TestRepo,}impl NestedBareRepoTest {fn new() -> Self {let temp_dir = tempfile::TempDir::new().unwrap();- // Create project directory+ // Create project directory with the bare repo inside as .gitlet project_path = temp_dir.path().join("project");- fs::create_dir(&project_path).unwrap();+ let repo = TestRepo::bare_at(&project_path.join(".git"));+ let project_path = canonicalize(&project_path).unwrap();- // Bare repo inside project directory as .git- let bare_repo_path = project_path.join(".git");+ // Worktrees as siblings to .git: project/main, project/featurelet test_config_path = temp_dir.path().join("test-config.toml");- let git_config_path = temp_dir.path().join("test-gitconfig");-- // Write git config with user settings (like TestRepo)- fs::write(- &git_config_path,- "[user]\n\tname = Test User\n\temail = [email protected]\n\- [advice]\n\tmergeConflict = false\n\tresolveConflict = false\n\- [init]\n\tdefaultBranch = main\n",- )- .unwrap();+ fs::write(&test_config_path, "worktree-path = \"../{{ branch }}\"\n").unwrap();- let mut test = Self {+ Self {temp_dir,project_path,- bare_repo_path,test_config_path,- git_config_path,- };-- // Create bare repository at project/.git- let output = configure_git_env(Cmd::new("git"), &test.git_config_path)- .args(["init", "--bare", "--initial-branch", "main"])- .arg(test.bare_repo_path.to_str().unwrap())- .run()- .unwrap();-- if !output.status.success() {- panic!(- "Failed to init nested bare repo:\nstdout: {}\nstderr: {}",- String::from_utf8_lossy(&output.stdout),- String::from_utf8_lossy(&output.stderr)- );+ repo,}-- // Canonicalize paths- test.project_path = canonicalize(&test.project_path).unwrap();- test.bare_repo_path = canonicalize(&test.bare_repo_path).unwrap();-- // Write config with template for worktrees as siblings to .git- // For nested bare repos (project/.git), we use "../{{ branch }}" to create- // worktrees at project/main, project/feature (siblings to .git)- fs::write(- &test.test_config_path,- "worktree-path = \"../{{ branch }}\"\n",- )- .unwrap();-- test}- fn project_path(&self) -> &PathBuf {+ fn project_path(&self) -> &Path {&self.project_path}- fn bare_repo_path(&self) -> &PathBuf {- &self.bare_repo_path+ fn bare_repo_path(&self) -> &Path {+ self.repo.path()}fn config_path(&self) -> &Path {@@ -1509,7 +1470,6 @@ impl NestedBareRepoTest {std::fs::create_dir_all(&home).ok();pty_env_vars(TestEnvPaths {- git_config: &self.git_config_path,home: &home,wt_config: &self.test_config_path,approvals: &self.temp_dir.path().join("test-approvals.toml"),@@ -1519,7 +1479,7 @@ impl NestedBareRepoTest {impl TestRepoBase for NestedBareRepoTest {fn git_config_path(&self) -> &Path {- &self.git_config_path+ test_gitconfig_path()}}@@ -1719,18 +1679,12 @@ fn test_bare_repo_bootstrap_first_worktree() {#[test]fn test_clone_bare_repo_list_no_status_errors() {let temp_dir = tempfile::TempDir::new().unwrap();- let git_config_path = temp_dir.path().join("test-gitconfig");+ let git_config_path = test_gitconfig_path();let test_config_path = temp_dir.path().join("test-config.toml");- fs::write(- &git_config_path,- "[user]\n\tname = Test User\n\temail = [email protected]\n\- [init]\n\tdefaultBranch = main\n",- )- .unwrap();fs::write(&test_config_path, "").unwrap();let run_git = |dir: &Path, args: &[&str]| {- let output = configure_git_env(Cmd::new("git"), &git_config_path)+ let output = configure_git_env(Cmd::new("git"), git_config_path).args(args.iter().copied()).current_dir(dir).run()@@ -1780,7 +1734,7 @@ fn test_clone_bare_repo_list_no_status_errors() {// Run wt list from the bare repo directory (the reported scenario)let mut cmd = wt_command();- configure_git_cmd(&mut cmd, &git_config_path);+ configure_git_cmd(&mut cmd, git_config_path);cmd.env("WORKTRUNK_CONFIG_PATH", &test_config_path).arg("list").current_dir(&bare_path);diff --git a/tests/snapshots/integration__integration_tests__for_each__for_each_single_worktree.snap b/tests/snapshots/integration__integration_tests__for_each__for_each_single_worktree.snapindex 0b8b63fd8..2d1f5ef01 100644--- a/tests/snapshots/integration__integration_tests__for_each__for_each_single_worktree.snap+++ b/tests/snapshots/integration__integration_tests__for_each__for_each_single_worktree.snap@@ -11,8 +11,10 @@ info:- "--short"env:APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"CLICOLOR_FORCE: "1"COLUMNS: "500"+ GIT_ALLOW_PROTOCOL: fileGIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"@@ -39,6 +41,7 @@ info:WORKTRUNK_TEST_GEMINI_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"+ WORKTRUNK_TEST_PARENT_SHELL: ""WORKTRUNK_TEST_POWERSHELL_ENV: "0"WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"@@ -51,12 +54,8 @@ exit_code: 0----- stderr -----[36m◎[39m [36mRunning in [1mmain[22m...[39m-[0mwarning: untracked cache is disabled on this system or location-[36m◎[39m [36mRunning in [1mfeature-a[22m...[39m-[0mwarning: untracked cache is disabled on this system or location-[36m◎[39m [36mRunning in [1mfeature-b[22m...[39m-[0mwarning: untracked cache is disabled on this system or location-[36m◎[39m [36mRunning in [1mfeature-c[22m...[39m-[0mwarning: untracked cache is disabled on this system or location-+[0m[36m◎[39m [36mRunning in [1mfeature-a[22m...[39m+[0m[36m◎[39m [36mRunning in [1mfeature-b[22m...[39m+[0m[36m◎[39m [36mRunning in [1mfeature-c[22m...[39m+[0m[32m✓[39m [32mCompleted in 4 worktrees[39mdiff --git a/tests/snapshots/integration__integration_tests__for_each__for_each_with_detached_head.snap b/tests/snapshots/integration__integration_tests__for_each__for_each_with_detached_head.snapindex 90f2a7a18..8b69051fc 100644--- a/tests/snapshots/integration__integration_tests__for_each__for_each_with_detached_head.snap+++ b/tests/snapshots/integration__integration_tests__for_each__for_each_with_detached_head.snap@@ -11,8 +11,10 @@ info:- "--short"env:APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"CLICOLOR_FORCE: "1"COLUMNS: "500"+ GIT_ALLOW_PROTOCOL: fileGIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"@@ -39,6 +41,7 @@ info:WORKTRUNK_TEST_GEMINI_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"+ WORKTRUNK_TEST_PARENT_SHELL: ""WORKTRUNK_TEST_POWERSHELL_ENV: "0"WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"@@ -51,13 +54,9 @@ exit_code: 0----- stderr -----[36m◎[39m [36mRunning in [1mmain[22m...[39m-[0mwarning: untracked cache is disabled on this system or location-[36m◎[39m [36mRunning in [1mrepo.detached-test[22m (detached)...[39m+[0m[36m◎[39m [36mRunning in [1mrepo.detached-test[22m (detached)...[39m[0m[36m◎[39m [36mRunning in [1mfeature-a[22m...[39m-[0mwarning: untracked cache is disabled on this system or location-[36m◎[39m [36mRunning in [1mfeature-b[22m...[39m-[0mwarning: untracked cache is disabled on this system or location-[36m◎[39m [36mRunning in [1mfeature-c[22m...[39m-[0mwarning: untracked cache is disabled on this system or location-+[0m[36m◎[39m [36mRunning in [1mfeature-b[22m...[39m+[0m[36m◎[39m [36mRunning in [1mfeature-c[22m...[39m+[0m[32m✓[39m [32mCompleted in 5 worktrees[39m