Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

fix(prune): age branches without a reflog by when git last wrote their ref (#4154)

Maximilian Roos1ab21aba909a
diff --git a/docs/src/content/docs/step.md b/docs/src/content/docs/step.md
index e7cebe52b..b0dd0a992 100644
--- a/docs/src/content/docs/step.md
+++ b/docs/src/content/docs/step.md
@@ -841,7 +841,7 @@ Locked worktrees and the main worktree are always skipped. The current worktree
### Min-age guard
-Candidates younger than `--min-age` (default: 1 day) are skipped. A worktree's age comes from its creation time, and a branch with no worktree takes its age from its oldest reflog entry. This prevents removing a worktree just created from the default branch: it looks "merged" because its branch points at the same commit.
+Candidates younger than `--min-age` (default: 1 day) are skipped. A worktree's age comes from its creation time. A branch with no worktree takes its age from its oldest reflog entry, or, when it has none (common in bare repositories), from when git last wrote its ref. Operations such as `git gc` or deleting a branch can rewrite many refs at once, so afterwards older branches without a reflog are skipped until `--min-age` has passed. This prevents removing a worktree just created from the default branch: it looks "merged" because its branch points at the same commit.
```console
$ wt step prune --min-age=0s # no age guard
diff --git a/plugins/worktrunk/skills/worktrunk/reference/step.md b/plugins/worktrunk/skills/worktrunk/reference/step.md
index eee45c739..f9e82024e 100644
--- a/plugins/worktrunk/skills/worktrunk/reference/step.md
+++ b/plugins/worktrunk/skills/worktrunk/reference/step.md
@@ -829,7 +829,7 @@ Locked worktrees and the main worktree are always skipped. The current worktree
### Min-age guard
-Candidates younger than `--min-age` (default: 1 day) are skipped. A worktree's age comes from its creation time, and a branch with no worktree takes its age from its oldest reflog entry. This prevents removing a worktree just created from the default branch: it looks "merged" because its branch points at the same commit.
+Candidates younger than `--min-age` (default: 1 day) are skipped. A worktree's age comes from its creation time. A branch with no worktree takes its age from its oldest reflog entry, or, when it has none (common in bare repositories), from when git last wrote its ref. Operations such as `git gc` or deleting a branch can rewrite many refs at once, so afterwards older branches without a reflog are skipped until `--min-age` has passed. This prevents removing a worktree just created from the default branch: it looks "merged" because its branch points at the same commit.
```console
$ wt step prune --min-age=0s # no age guard
diff --git a/skills/worktrunk/reference/step.md b/skills/worktrunk/reference/step.md
index eee45c739..f9e82024e 100644
--- a/skills/worktrunk/reference/step.md
+++ b/skills/worktrunk/reference/step.md
@@ -829,7 +829,7 @@ Locked worktrees and the main worktree are always skipped. The current worktree
### Min-age guard
-Candidates younger than `--min-age` (default: 1 day) are skipped. A worktree's age comes from its creation time, and a branch with no worktree takes its age from its oldest reflog entry. This prevents removing a worktree just created from the default branch: it looks "merged" because its branch points at the same commit.
+Candidates younger than `--min-age` (default: 1 day) are skipped. A worktree's age comes from its creation time. A branch with no worktree takes its age from its oldest reflog entry, or, when it has none (common in bare repositories), from when git last wrote its ref. Operations such as `git gc` or deleting a branch can rewrite many refs at once, so afterwards older branches without a reflog are skipped until `--min-age` has passed. This prevents removing a worktree just created from the default branch: it looks "merged" because its branch points at the same commit.
```console
$ wt step prune --min-age=0s # no age guard
diff --git a/src/cli/step.rs b/src/cli/step.rs
index 4917f91b7..44d35f3f6 100644
--- a/src/cli/step.rs
+++ b/src/cli/step.rs
@@ -643,7 +643,7 @@ Locked worktrees and the main worktree are always skipped. The current worktree
## Min-age guard
-Candidates younger than `--min-age` (default: 1 day) are skipped. A worktree's age comes from its creation time, and a branch with no worktree takes its age from its oldest reflog entry. This prevents removing a worktree just created from the default branch: it looks "merged" because its branch points at the same commit.
+Candidates younger than `--min-age` (default: 1 day) are skipped. A worktree's age comes from its creation time. A branch with no worktree takes its age from its oldest reflog entry, or, when it has none (common in bare repositories), from when git last wrote its ref. Operations such as `git gc` or deleting a branch can rewrite many refs at once, so afterwards older branches without a reflog are skipped until `--min-age` has passed. This prevents removing a worktree just created from the default branch: it looks "merged" because its branch points at the same commit.
```console
$ wt step prune --min-age=0s # no age guard
diff --git a/src/commands/step/prune.rs b/src/commands/step/prune.rs
index c21835ad4..68c53660b 100644
--- a/src/commands/step/prune.rs
+++ b/src/commands/step/prune.rs
@@ -16,7 +16,7 @@
//! current worktree is removed last, after the fan-out, because its removal
//! cd's the shell to the primary.
-use std::collections::HashSet;
+use std::collections::{HashMap, HashSet};
use std::fs;
use std::path::{Path, PathBuf};
use std::sync::RwLock;
@@ -432,6 +432,7 @@ fn check_one(
worktrees: &[WorktreeInfo],
current_path: &Path,
min_age_duration: Duration,
+ ref_write_times: &RefWriteTimes,
now_secs: u64,
) -> anyhow::Result<CheckOutcome> {
let _span = Span::new(format!("prune-check:{}", item.integration_ref));
@@ -492,7 +493,12 @@ fn check_one(
let age = if min_age_duration > Duration::ZERO {
match &item.source {
CheckSource::Linked { wt_idx } => worktree_age(repo, &worktrees[*wt_idx], now_secs)?,
- CheckSource::Orphan => orphan_branch_age(repo, &item.integration_ref, now_secs),
+ CheckSource::Orphan => Some(orphan_branch_age(
+ repo,
+ &item.integration_ref,
+ ref_write_times,
+ now_secs,
+ )?),
CheckSource::Prunable { .. } => None,
}
} else {
@@ -697,34 +703,126 @@ fn worktree_age(
/// `--date=unix` renders each entry's selector as `<name>@{<epoch>}`, and git
/// forbids `@{` inside a ref name, so the last `@{` opens the timestamp.
///
-/// Returns `None` if the reflog is missing or unparsable — callers treat
-/// "unknown age" as "old enough". `core.logAllRefUpdates` defaults to whether
-/// the repository is bare as seen from where the command runs, so a ref
-/// written from a bare directory has no reflog and no min-age guard:
-/// `git clone --bare` writes none for the branches it brings down, and
-/// neither does a later `git fetch` into `refs/heads/*`. A linked worktree is
-/// not bare, so a branch created or updated from one — every branch `wt`
-/// itself creates — is aged normally.
-fn orphan_branch_age(repo: &Repository, branch: &str, now_secs: u64) -> Option<Duration> {
+/// A branch with no reflog entries is aged by [`RefWriteTimes`] instead.
+/// `core.logAllRefUpdates` defaults to whether the repository is bare as seen
+/// from where git runs, so in a bare repository only a ref written from inside
+/// a linked worktree gets a reflog: `git clone --bare`, a `git fetch` into
+/// `refs/heads/*`, and `wt switch --create` run from the bare directory all
+/// leave none. Expiry (`git gc`) can also empty a reflog.
+fn orphan_branch_age(
+ repo: &Repository,
+ branch: &str,
+ ref_write_times: &RefWriteTimes,
+ now_secs: u64,
+) -> anyhow::Result<Duration> {
let ref_name = format!("refs/heads/{branch}");
- let stdout = repo
- .run_command(&[
- "reflog",
- "show",
- "--no-show-signature",
- "--date=unix",
- "--format=%gd",
- &ref_name,
- ])
- .ok()?;
- let created_epoch = stdout
- .trim()
- .lines()
- .last()
- .and_then(|selector| selector.rsplit_once("@{"))
- .and_then(|(_, epoch)| epoch.strip_suffix('}'))
- .and_then(|epoch| epoch.parse::<u64>().ok())?;
- Some(Duration::from_secs(now_secs.saturating_sub(created_epoch)))
+ let stdout = repo.run_command(&[
+ "reflog",
+ "show",
+ "--no-show-signature",
+ "--date=unix",
+ "--format=%gd",
+ &ref_name,
+ "--",
+ ])?;
+ let created_epoch = match stdout.trim().lines().last() {
+ Some(selector) => selector
+ .rsplit_once("@{")
+ .and_then(|(_, epoch)| epoch.strip_suffix('}'))
+ .and_then(|epoch| epoch.parse::<u64>().ok())
+ .with_context(|| format!("parsing reflog selector {selector:?}"))?,
+ None => ref_write_times.epoch(branch)?,
+ };
+ Ok(Duration::from_secs(now_secs.saturating_sub(created_epoch)))
+}
+
+/// When git last wrote the storage holding each orphan branch's ref, read
+/// once before the scan fans out.
+///
+/// Git replaces ref storage by renaming a new file into place, so a file's
+/// mtime is its last write, and the branch it holds existed by then. An age
+/// measured from it is never older than the branch, so the guard errs toward
+/// keeping it. Which file holds the ref depends on the backend:
+///
+/// - **files** (the default): a loose `refs/heads/<branch>` shadows
+/// `packed-refs`. Creating or updating a ref writes it loose, including from
+/// `git fetch`, while `git clone` writes `packed-refs`. `git pack-refs` (run
+/// by `git gc`) and deleting any packed ref rewrite `packed-refs` whole,
+/// which makes every packed branch young again and delays its pruning by up
+/// to `--min-age`.
+/// - **reftable**: tables hold many refs, and every ref update rewrites
+/// `reftable/tables.list`, so a branch counts as no older than the
+/// repository's last ref update.
+///
+/// Prune's own removals are among those rewrites, and they run while the scan
+/// is still checking later candidates, so the times are captured before any
+/// removal starts. The loose refs are read before the shared file: a
+/// concurrent `git pack-refs` that packs a loose ref in between leaves that
+/// branch dated by the rewritten `packed-refs`, never by an older one.
+struct RefWriteTimes {
+ /// Loose `refs/heads/<branch>` mtimes, for the orphan branches that have one.
+ loose: HashMap<String, u64>,
+ /// The `packed-refs` or `reftable/tables.list` mtime, if the file exists.
+ shared: Option<u64>,
+}
+
+impl RefWriteTimes {
+ fn capture(repo: &Repository, check_items: &[CheckItem]) -> anyhow::Result<Self> {
+ let reftable = repo.config_value("extensions.refStorage")?.as_deref() == Some("reftable");
+ let orphans = check_items
+ .iter()
+ .filter(|item| matches!(item.source, CheckSource::Orphan))
+ .map(|item| item.integration_ref.as_str());
+ Self::read(repo.git_common_dir(), reftable, orphans)
+ }
+
+ /// Read the times for `branches` from a git common directory whose refs
+ /// use the reftable backend if `reftable`, else the files backend.
+ fn read<'a>(
+ common_dir: &Path,
+ reftable: bool,
+ branches: impl IntoIterator<Item = &'a str>,
+ ) -> anyhow::Result<Self> {
+ let mut loose = HashMap::new();
+ if !reftable {
+ for branch in branches {
+ if let Some(epoch) = mtime_epoch(&common_dir.join("refs/heads").join(branch))? {
+ loose.insert(branch.to_string(), epoch);
+ }
+ }
+ }
+ let shared = if reftable {
+ common_dir.join("reftable").join("tables.list")
+ } else {
+ common_dir.join("packed-refs")
+ };
+ Ok(Self {
+ loose,
+ shared: mtime_epoch(&shared)?,
+ })
+ }
+
+ /// The Unix epoch of the last write to `branch`'s ref storage.
+ fn epoch(&self, branch: &str) -> anyhow::Result<u64> {
+ self.loose
+ .get(branch)
+ .copied()
+ .or(self.shared)
+ .with_context(|| format!("finding the ref storage for branch {branch}"))
+ }
+}
+
+/// A file's mtime as a Unix epoch, or `None` if the file doesn't exist.
+fn mtime_epoch(path: &Path) -> anyhow::Result<Option<u64>> {
+ match fs::metadata(path).and_then(|metadata| metadata.modified()) {
+ Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(None),
+ modified => {
+ let modified = modified.with_context(|| format!("reading {}", path.display()))?;
+ Ok(Some(
+ modified.duration_since(std::time::UNIX_EPOCH)?.as_secs(),
+ ))
+ }
+ }
}
/// Render dry-run output (text or JSON) and the `Skipped (younger than ...)`
@@ -923,6 +1021,10 @@ pub fn step_prune(
let _span = Span::new("prune-gather");
gather_check_items(&repo, worktrees, default_branch.as_deref())?
};
+ // Read before any removal, since prune's own deletions rewrite the files
+ // these times come from.
+ let ref_write_times =
+ RefWriteTimes::capture(&repo, &check_items).context("reading ref write times")?;
let mut skipped_young: Vec<String> = Vec::new();
@@ -943,6 +1045,7 @@ pub fn step_prune(
let integration_target_ref = integration_target.as_str();
let current_path_ref = current_root.as_path();
let check_lock_ref = &check_lock;
+ let ref_write_times_ref = &ref_write_times;
s.spawn(move || {
check_items_ref
.par_iter()
@@ -958,6 +1061,7 @@ pub fn step_prune(
worktrees,
current_path_ref,
min_age_duration,
+ ref_write_times_ref,
now_secs,
)
};
@@ -1119,6 +1223,7 @@ pub fn step_prune(
let integration_target_ref = integration_target.as_str();
let current_path_ref = current_root.as_path();
let check_lock_ref = &check_lock;
+ let ref_write_times_ref = &ref_write_times;
s.spawn(move || {
check_items_ref
.par_iter()
@@ -1134,6 +1239,7 @@ pub fn step_prune(
worktrees,
current_path_ref,
min_age_duration,
+ ref_write_times_ref,
now_secs,
)
};
@@ -1432,6 +1538,41 @@ mod tests {
}
}
+ #[test]
+ fn ref_write_times_follow_the_ref_backend() {
+ let dir = tempfile::tempdir().unwrap();
+ let write = |relative: &str, epoch: u64| {
+ let path = dir.path().join(relative);
+ fs::create_dir_all(path.parent().unwrap()).unwrap();
+ fs::File::create(&path)
+ .unwrap()
+ .set_modified(std::time::UNIX_EPOCH + Duration::from_secs(epoch))
+ .unwrap();
+ };
+ write("packed-refs", 100);
+ write("refs/heads/loose", 200);
+ write("refs/heads/nested/loose", 300);
+ write("reftable/tables.list", 400);
+
+ // A loose ref shadows `packed-refs`, which dates every other branch.
+ let files =
+ RefWriteTimes::read(dir.path(), false, ["loose", "nested/loose", "packed"]).unwrap();
+ let epochs = ["loose", "nested/loose", "packed"].map(|branch| files.epoch(branch).unwrap());
+ assert_eq!(epochs, [200, 300, 100]);
+
+ // Reftable keeps no per-ref files, so a stray loose file is not read.
+ let reftable = RefWriteTimes::read(dir.path(), true, ["loose"]).unwrap();
+ assert_eq!(reftable.epoch("loose").unwrap(), 400);
+
+ // With neither a loose ref nor shared storage, nothing dates the branch.
+ let empty = tempfile::tempdir().unwrap();
+ let none = RefWriteTimes::read(empty.path(), false, ["gone"]).unwrap();
+ assert_eq!(
+ none.epoch("gone").unwrap_err().to_string(),
+ "finding the ref storage for branch gone"
+ );
+ }
+
#[test]
fn removal_context_distinguishes_branch_only_from_worktree() {
assert_eq!(
diff --git a/tests/integration_tests/step_prune.rs b/tests/integration_tests/step_prune.rs
index 700951566..c78411c25 100644
--- a/tests/integration_tests/step_prune.rs
+++ b/tests/integration_tests/step_prune.rs
@@ -1,7 +1,8 @@
//! Integration tests for `wt step prune`
use crate::common::{
- BareRepoTest, TestRepo, make_snapshot_cmd, repo, repo_with_remote, setup_temp_snapshot_settings,
+ BareRepoTest, TEST_EPOCH, TestRepo, make_snapshot_cmd, repo, repo_with_remote,
+ setup_temp_snapshot_settings,
};
use ansi_str::AnsiStr;
use insta::assert_snapshot;
@@ -420,6 +421,125 @@ fn test_prune_orphan_branch_min_age(repo: TestRepo) {
assert_cmd_snapshot!(cmd);
}
+/// Bare-clone `repo` into `clone.git` beside it. Like any `git clone --bare`,
+/// the clone stores its branches in `packed-refs` and writes them no reflogs.
+fn bare_clone(repo: &TestRepo) -> std::path::PathBuf {
+ let clone = repo.home_path().join("clone.git");
+ repo.run_git(&["clone", "--bare", ".", clone.to_str().unwrap()]);
+ clone
+}
+
+/// Set a file's mtime to `age_secs` before `TEST_EPOCH`.
+fn set_age(path: &std::path::Path, age_secs: u64) {
+ let written = std::time::UNIX_EPOCH + std::time::Duration::from_secs(TEST_EPOCH - age_secs);
+ std::fs::File::options()
+ .write(true)
+ .open(path)
+ .unwrap()
+ .set_modified(written)
+ .unwrap();
+}
+
+/// Orphan branches without a reflog are aged by when their ref was last written.
+///
+/// `git clone --bare` writes no reflogs and stores the branches it brings down
+/// in `packed-refs`; a later fetch into `refs/heads/*` writes a new branch as a
+/// loose ref, also without a reflog. The two files are dated a month and an
+/// hour before TEST_EPOCH, so each branch's age shows which file it was read
+/// from: `cloned` is a candidate, and `fetched` is skipped as younger than 1d.
+#[rstest]
+fn test_prune_orphan_branch_min_age_without_reflog(repo: TestRepo) {
+ repo.create_branch("cloned");
+ let clone = bare_clone(&repo);
+ repo.run_git_in(
+ &clone,
+ &[
+ "config",
+ "remote.origin.fetch",
+ "+refs/heads/*:refs/heads/*",
+ ],
+ );
+ repo.create_branch("fetched");
+ repo.run_git_in(&clone, &["fetch", "origin"]);
+
+ for branch in ["cloned", "fetched"] {
+ let ref_name = format!("refs/heads/{branch}");
+ let output = repo
+ .git_command()
+ .args(["reflog", "exists", &ref_name])
+ .current_dir(&clone)
+ .run()
+ .unwrap();
+ assert!(!output.status.success(), "{branch} should have no reflog");
+ }
+
+ set_age(&clone.join("packed-refs"), 30 * 24 * 60 * 60);
+ set_age(&clone.join("refs/heads/fetched"), 60 * 60);
+
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "step",
+ &["prune", "--dry-run"],
+ Some(&clone)
+ ));
+}
+
+/// Prune's own removals don't re-date the branches it has yet to check.
+///
+/// Deleting a packed branch rewrites `packed-refs`, which dates every branch
+/// without a reflog, and removals run while the scan is still checking later
+/// candidates. Two month-old packed branches in a bare clone go through a
+/// `git` shim that holds `packed-b`'s reflog read until `packed-a`'s deletion
+/// has finished, so `packed-b` is aged after that rewrite; both must still be
+/// removed. Unix-only for the same `CreateProcess` shim reason as the canary
+/// below.
+#[cfg(unix)]
+#[rstest]
+fn test_prune_removals_keep_packed_branch_ages(repo: TestRepo) {
+ repo.create_branch("packed-a");
+ repo.create_branch("packed-b");
+ let clone = bare_clone(&repo);
+ set_age(&clone.join("packed-refs"), 30 * 24 * 60 * 60);
+
+ let mut cmd = repo.wt_command();
+ // Two scan threads, so `packed-a`'s check can finish while `packed-b`'s
+ // waits in the shim whichever order the scan takes them in.
+ cmd.current_dir(&clone).env("RAYON_NUM_THREADS", "2");
+ let git_wrapper_dir = repo.home_path().join("git-wrapper");
+ std::fs::create_dir_all(&git_wrapper_dir).unwrap();
+ write_deletion_ordering_git_wrapper(&git_wrapper_dir, &which::which("git").unwrap());
+ prepend_path(&mut cmd, &git_wrapper_dir);
+ let barrier_dir = repo.home_path().join("barrier");
+ std::fs::create_dir_all(&barrier_dir).unwrap();
+ cmd.env("WT_TEST_BARRIER_DIR", &barrier_dir);
+
+ let output = cmd.args(["step", "prune", "--yes"]).output().unwrap();
+ let stderr = String::from_utf8_lossy(&output.stderr);
+
+ assert!(output.status.success(), "prune should succeed:\n{stderr}");
+ assert!(
+ barrier_dir.join("deleted-packed-a").exists(),
+ "the shim never saw packed-a deleted:\n{stderr}"
+ );
+ assert!(
+ !barrier_dir.join("timeout").exists(),
+ "packed-b's reflog read waited out the shim, so it was aged before packed-a's deletion:\n{stderr}"
+ );
+ let output = repo
+ .git_command()
+ .args(["branch", "--format=%(refname:short)"])
+ .current_dir(&clone)
+ .run()
+ .unwrap();
+ let branches = String::from_utf8_lossy(&output.stdout);
+ for name in ["packed-a", "packed-b"] {
+ assert!(
+ !branches.lines().any(|branch| branch == name),
+ "{name} should have been pruned:\n{stderr}"
+ );
+ }
+}
+
/// Prune can remove a mix of branch-only and worktree candidates in one run.
#[rstest]
fn test_prune_mixed_worktree_and_orphan_branch(mut repo: TestRepo) {
@@ -2045,6 +2165,48 @@ exec {real_git} "$@"
std::fs::set_permissions(&path, permissions).unwrap();
}
+/// A `git` shim that holds the reflog read for `refs/heads/packed-b` until
+/// `update-ref -d refs/heads/packed-a` has finished (see
+/// `test_prune_removals_keep_packed_branch_ages`); everything else passes
+/// through to the real git.
+#[cfg(unix)]
+fn write_deletion_ordering_git_wrapper(dir: &std::path::Path, real_git: &std::path::Path) {
+ use std::os::unix::fs::PermissionsExt;
+
+ let real_git = shell_escape::unix::escape(real_git.to_string_lossy());
+ let script = format!(
+ r#"#!/bin/sh
+if [ "$1 $2 $3" = "update-ref -d refs/heads/packed-a" ]; then
+ {real_git} "$@"
+ status=$?
+ : > "$WT_TEST_BARRIER_DIR/deleted-packed-a"
+ exit $status
+fi
+if [ "$1 $2" = "reflog show" ]; then
+ case " $* " in
+ *" refs/heads/packed-b "*)
+ i=0
+ while [ ! -e "$WT_TEST_BARRIER_DIR/deleted-packed-a" ]; do
+ i=$((i+1))
+ if [ "$i" -gt 300 ]; then
+ : > "$WT_TEST_BARRIER_DIR/timeout"
+ break
+ fi
+ sleep 0.05
+ done
+ ;;
+ esac
+fi
+exec {real_git} "$@"
+"#
+ );
+ let path = dir.join("git");
+ std::fs::write(&path, script).unwrap();
+ let mut permissions = std::fs::metadata(&path).unwrap().permissions();
+ permissions.set_mode(0o755);
+ std::fs::set_permissions(&path, permissions).unwrap();
+}
+
/// A `git` shim whose `update-ref -d refs/heads/para-{a,b}` arms rendezvous
/// with each other (see `test_prune_removals_run_concurrently`); everything
/// else passes through to the real git.
diff --git a/tests/snapshots/integration__integration_tests__step_prune__prune_orphan_branch_min_age_without_reflog.snap b/tests/snapshots/integration__integration_tests__step_prune__prune_orphan_branch_min_age_without_reflog.snap
new file mode 100644
index 000000000..b23d82caf
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_prune__prune_orphan_branch_min_age_without_reflog.snap
@@ -0,0 +1,65 @@
+---
+source: tests/integration_tests/step_prune.rs
+info:
+ program: wt
+ args:
+ - step
+ - prune
+ - "--dry-run"
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_ALLOW_PROTOCOL: file
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_AUTHOR_EMAIL: [email protected]
+ GIT_AUTHOR_NAME: Test User
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_EMAIL: [email protected]
+ GIT_COMMITTER_NAME: Test User
+ GIT_CONFIG_COUNT: "2"
+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig
+ GIT_CONFIG_KEY_0: user.useConfigOnly
+ GIT_CONFIG_KEY_1: rerere.enabled
+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig
+ GIT_CONFIG_VALUE_0: "true"
+ GIT_CONFIG_VALUE_1: "false"
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_BASH_INSTALLED: "0"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_CODEX_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_FISH_INSTALLED: "0"
+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"
+ WORKTRUNK_TEST_MOCK_CONFIG_DIR: "[TEST_MOCK_CONFIG]"
+ 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_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WORKTRUNK_TEST_ZSH_INSTALLED: "0"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+○ cloned (branch only) — same commit as main
+↳ 1 branch would be removed (dry run)
+
+----- stderr -----
+○ Skipped fetched (younger than 1d)