Skip to content

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

Use `cp -cR` for CoW seeding on macOS

Maximilian Roosf3fcc78c36d1
diff --git a/.config/wt.toml b/.config/wt.toml
index bd549dcd6..c652fe7ca 100644
--- a/.config/wt.toml
+++ b/.config/wt.toml
@@ -10,6 +10,7 @@ post-start-commands = [
# Seed target/ from base worktree using CoW (copy-on-write)
# Each worktree gets its own target/ (avoids incremental build corruption)
# but seeded from base to warm-start builds (low disk usage)
- # rsync --reflink=auto works on both macOS and Linux
- "[ -d {repo_root}/target ] && [ ! -e {worktree}/target ] && rsync -a --reflink=auto {repo_root}/target/ {worktree}/target/ && echo '✓ CoW seeded target/'"
+ # macOS: uses cp -c (clonefile on APFS)
+ # Linux: would need cp --reflink=auto (GNU coreutils) or rsync 3.2.3+ with --reflink
+ "[ -d {repo_root}/target ] && [ ! -e {worktree}/target ] && cp -cR {repo_root}/target/. {worktree}/target/ && echo '✓ CoW seeded target/'"
]
diff --git a/src/commands/worktree.rs b/src/commands/worktree.rs
index f82ab16f8..6b1daa70b 100644
--- a/src/commands/worktree.rs
+++ b/src/commands/worktree.rs
@@ -595,8 +595,11 @@ fn execute_post_start_commands(
expand_command_template(command, repo_name, branch, worktree_path, &repo_root);
use anstyle::{AnsiColor, Color};
+ use std::io::Write;
let cyan = AnstyleStyle::new().fg_color(Some(Color::Ansi(AnsiColor::Cyan)));
eprintln!("🔄 {cyan}Executing: {expanded_command}{cyan:#}");
+ // Flush stderr to ensure message is displayed before command execution
+ let _ = std::io::stderr().flush();
if let Err(e) = execute_command_in_worktree(worktree_path, &expanded_command) {
eprintln!("{WARNING_EMOJI} {WARNING}Command failed: {e}{WARNING:#}");
// Continue with other commands even if one fails
@@ -604,6 +607,11 @@ fn execute_post_start_commands(
}
}
+ // Flush all output before returning to ensure proper display order
+ use std::io::Write;
+ let _ = std::io::stdout().flush();
+ let _ = std::io::stderr().flush();
+
Ok(())
}