Skip to content

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

Report whether copy-ignored reflinked or copied in full (#4025)

Maximilian Roosacc0fd06d8e8
diff --git a/docs/src/content/docs/step.md b/docs/src/content/docs/step.md
index aec54033f..af2bbe93a 100644
--- a/docs/src/content/docs/step.md
+++ b/docs/src/content/docs/step.md
@@ -620,7 +620,7 @@ Files are reflinked where the filesystem supports it: APFS (macOS), btrfs and XF
| `cp -R` (full copy) | 2m | 14GB |
| `cp -Rc` / `wt step copy-ignored` | 20s | ~0 |
-On ext4 and NTFS, which have no reflink, every file is copied in full.
+On ext4 and NTFS, which have no reflink, every file is copied in full. The same byte count therefore costs nothing on one filesystem and 14GB on the other, so the summary says which happened: `Copied 4,812 files · 14.0 GB (reflinked, no extra disk)`, against `(full copy)` where those bytes were written out.
Reflinks are per file (like `cp -Rc`), so copy time scales with file count.
diff --git a/plugins/worktrunk/skills/worktrunk/reference/step.md b/plugins/worktrunk/skills/worktrunk/reference/step.md
index 54a8e5a97..2e4e128f5 100644
--- a/plugins/worktrunk/skills/worktrunk/reference/step.md
+++ b/plugins/worktrunk/skills/worktrunk/reference/step.md
@@ -608,7 +608,7 @@ Files are reflinked where the filesystem supports it: APFS (macOS), btrfs and XF
| `cp -R` (full copy) | 2m | 14GB |
| `cp -Rc` / `wt step copy-ignored` | 20s | ~0 |
-On ext4 and NTFS, which have no reflink, every file is copied in full.
+On ext4 and NTFS, which have no reflink, every file is copied in full. The same byte count therefore costs nothing on one filesystem and 14GB on the other, so the summary says which happened: `Copied 4,812 files · 14.0 GB (reflinked, no extra disk)`, against `(full copy)` where those bytes were written out.
Reflinks are per file (like `cp -Rc`), so copy time scales with file count.
diff --git a/skills/worktrunk/reference/step.md b/skills/worktrunk/reference/step.md
index 54a8e5a97..2e4e128f5 100644
--- a/skills/worktrunk/reference/step.md
+++ b/skills/worktrunk/reference/step.md
@@ -608,7 +608,7 @@ Files are reflinked where the filesystem supports it: APFS (macOS), btrfs and XF
| `cp -R` (full copy) | 2m | 14GB |
| `cp -Rc` / `wt step copy-ignored` | 20s | ~0 |
-On ext4 and NTFS, which have no reflink, every file is copied in full.
+On ext4 and NTFS, which have no reflink, every file is copied in full. The same byte count therefore costs nothing on one filesystem and 14GB on the other, so the summary says which happened: `Copied 4,812 files · 14.0 GB (reflinked, no extra disk)`, against `(full copy)` where those bytes were written out.
Reflinks are per file (like `cp -Rc`), so copy time scales with file count.
diff --git a/src/cli/step.rs b/src/cli/step.rs
index eb915fefd..1844d2321 100644
--- a/src/cli/step.rs
+++ b/src/cli/step.rs
@@ -388,7 +388,7 @@ Files are reflinked where the filesystem supports it: APFS (macOS), btrfs and XF
| `cp -R` (full copy) | 2m | 14GB |
| `cp -Rc` / `wt step copy-ignored` | 20s | ~0 |
-On ext4 and NTFS, which have no reflink, every file is copied in full.
+On ext4 and NTFS, which have no reflink, every file is copied in full. The same byte count therefore costs nothing on one filesystem and 14GB on the other, so the summary says which happened: `Copied 4,812 files · 14.0 GB (reflinked, no extra disk)`, against `(full copy)` where those bytes were written out.
Reflinks are per file (like `cp -Rc`), so copy time scales with file count.
diff --git a/src/commands/step/copy_ignored.rs b/src/commands/step/copy_ignored.rs
index 18234d42b..19eb57fa1 100644
--- a/src/commands/step/copy_ignored.rs
+++ b/src/commands/step/copy_ignored.rs
@@ -8,7 +8,7 @@ use color_print::cformat;
use worktrunk::copy::{copy_dir_recursive, copy_leaf};
use worktrunk::git::Repository;
use worktrunk::path::format_path_for_display;
-use worktrunk::progress::{Progress, format_bytes};
+use worktrunk::progress::{Progress, format_bytes, format_reflink_paren};
use worktrunk::styling::{
eprintln, format_with_gutter, hint_message, info_message, println, success_message, verbosity,
};
@@ -17,6 +17,23 @@ use crate::output::print_json;
use super::shared::{list_and_filter_ignored_entries, resolve_copy_ignored_config};
+/// Add the four counts a result payload reports, all zero, to an exit that
+/// copied nothing.
+///
+/// A `--dry-run` payload takes none of them. It reports what *would* be
+/// copied, so a file count and a reflink split have nothing to describe, and
+/// leaving them out is what keeps `outcome: "planned"` one shape whether or
+/// not anything matched — the two early returns below reach it with an empty
+/// entry list, the main path with a full one.
+fn insert_empty_counts(payload: &mut serde_json::Value) {
+ let obj = payload
+ .as_object_mut()
+ .expect("the json! macro above produced an object");
+ for key in ["files", "bytes", "reflinked", "written"] {
+ obj.insert(key.to_string(), serde_json::json!(0));
+ }
+}
+
/// Handle `wt step copy-ignored` command
///
/// Copies gitignored files from a source worktree to a destination worktree.
@@ -70,14 +87,13 @@ pub fn step_copy_ignored(
if source_path == dest_path {
if json_mode {
- let payload = serde_json::json!({
+ let mut payload = serde_json::json!({
"outcome": "same_worktree",
"from": source_path,
"to": dest_path,
"entries": Vec::<serde_json::Value>::new(),
- "files": 0,
- "bytes": 0,
});
+ insert_empty_counts(&mut payload);
print_json(&payload)?;
} else {
eprintln!(
@@ -100,16 +116,17 @@ pub fn step_copy_ignored(
// when nothing copies.
if require_include && !source_path.join(".worktreeinclude").exists() {
if json_mode {
- let payload = serde_json::json!({
+ let mut payload = serde_json::json!({
"outcome": if dry_run { "planned" } else { "copied" },
"dry_run": dry_run,
"from": source_path,
"to": dest_path,
"reason": "require-include-no-worktreeinclude",
"entries": Vec::<serde_json::Value>::new(),
- "files": 0,
- "bytes": 0,
});
+ if !dry_run {
+ insert_empty_counts(&mut payload);
+ }
print_json(&payload)?;
} else {
eprintln!(
@@ -137,15 +154,16 @@ pub fn step_copy_ignored(
if entries_to_copy.is_empty() {
if json_mode {
- let payload = serde_json::json!({
+ let mut payload = serde_json::json!({
"outcome": if dry_run { "planned" } else { "copied" },
"dry_run": dry_run,
"from": source_path,
"to": dest_path,
"entries": Vec::<serde_json::Value>::new(),
- "files": 0,
- "bytes": 0,
});
+ if !dry_run {
+ insert_empty_counts(&mut payload);
+ }
print_json(&payload)?;
} else {
eprintln!("{}", info_message("No matching files to copy"));
@@ -257,18 +275,24 @@ pub fn step_copy_ignored(
)
})?;
}
- if let Some(bytes) = copy_leaf(src_entry, &dest_entry, Some(&dest_path), force)? {
- progress.record(bytes);
+ if let Some((bytes, data)) = copy_leaf(src_entry, &dest_entry, Some(&dest_path), force)?
+ {
+ progress.record(bytes, data);
}
}
}
let (copied_count, copied_bytes) = progress.totals();
+ let (reflinked, written) = progress.copy_split();
progress.finish();
if json_mode {
// `entries` mirrors dry-run: the top-level units selected for copy
// (files and dirs). `files` counts the actual leaves written
- // (recursive + skipping pre-existing files), `bytes` sums their size.
+ // (recursive + skipping pre-existing files), `bytes` sums their size,
+ // and `reflinked`/`written` split those leaves by whether the
+ // filesystem shared the source's extents. `insert_empty_counts` carries
+ // all four through the exits that copy nothing, so a consumer never
+ // branches on a key's presence.
let entries: Vec<_> = entries_to_copy
.iter()
.map(|(src_entry, is_dir)| {
@@ -289,6 +313,8 @@ pub fn step_copy_ignored(
"entries": entries,
"files": copied_count,
"bytes": copied_bytes,
+ "reflinked": reflinked,
+ "written": written,
});
print_json(&payload)?;
} else {
@@ -300,6 +326,7 @@ pub fn step_copy_ignored(
"Copied {copied_count} {file_word} · {}",
format_bytes(copied_bytes)
))
+ .append(&format_reflink_paren(reflinked, written))
);
}
diff --git a/src/copy.rs b/src/copy.rs
index 2547244ef..cbcc74156 100644
--- a/src/copy.rs
+++ b/src/copy.rs
@@ -12,11 +12,19 @@
//! Callers that want low-priority I/O (e.g. `step_copy_ignored`) should call
//! [`crate::priority::lower_current_process`] before starting work.
//!
-//! Every successful leaf copy calls `progress.record(bytes)` on the caller's
+//! Every successful leaf copy calls `progress.record(..)` on the caller's
//! [`Progress`], which both feeds the TTY spinner (when enabled) and
//! accumulates the `(files, bytes)` totals the caller reads back via
//! [`Progress::totals`]. Non-interactive callers pass [`Progress::disabled`]
//! to skip the spinner; counting still happens.
+//!
+//! Each record carries a [`DataCopy`] saying whether the filesystem shared the
+//! source's extents or wrote the bytes out, so a caller can report what the
+//! copy actually cost on disk. `reflink_or_copy` returns that for free: `None`
+//! when the platform's clone syscall succeeded, `Some(bytes)` when it fell
+//! through to `fs::copy`. The signal is exact per file but says only that a
+//! clone did not happen, never why — an unsupported filesystem and a
+//! cross-device copy are indistinguishable here.
use std::fs;
use std::io::ErrorKind;
@@ -28,7 +36,39 @@ use anyhow::Context;
use rayon::prelude::*;
use crate::path::{canonicalize_with_parents, format_path_for_display};
-use crate::progress::Progress;
+use crate::progress::{DataCopy, Progress};
+
+/// Pins the reflink classification so snapshot tests can assert the summary
+/// line: `1` reports every copied file as reflinked, `0` as written in full.
+///
+/// Whether a clone succeeds is a property of the filesystem under the test's
+/// temp directory, and CI spans APFS, ext4, and NTFS — so without this seam no
+/// single snapshot could hold on all three, and the branch a given run took
+/// would be invisible. It overrides only the label; the copy itself still
+/// attempts a reflink and behaves identically either way.
+static FORCED_DATA_COPY: LazyLock<Option<DataCopy>> =
+ LazyLock::new(
+ || match std::env::var("WORKTRUNK_TEST_REFLINK").as_deref() {
+ Ok("1") => Some(DataCopy::Reflinked),
+ Ok("0") => Some(DataCopy::Written),
+ _ => None,
+ },
+ );
+
+/// Read `reflink_or_copy`'s success value, which reports the *fallback*: `None`
+/// is the platform's clone syscall having succeeded, `Some(bytes)` the byte copy
+/// that stood in for it.
+///
+/// A named function rather than an inline `if`, because no filesystem exercises
+/// both arms — a run on APFS never sees the fallback, one on ext4 never sees the
+/// clone — so the mapping is pinned by a unit test rather than by whichever
+/// runner happens to execute it.
+fn classify_copy(fallback: Option<u64>) -> DataCopy {
+ match fallback {
+ None => DataCopy::Reflinked,
+ Some(_) => DataCopy::Written,
+ }
+}
/// Capped at 4 threads to avoid saturating the CPU — the global rayon pool is
/// much larger (2× CPU cores, tuned for network I/O in `wt list`).
@@ -41,12 +81,16 @@ static COPY_POOL: LazyLock<rayon::ThreadPool> = LazyLock::new(|| {
/// Copy a single file or symlink, using reflink (COW) when possible.
///
-/// Detects symlinks via `symlink_metadata` on the source. Returns `Some(bytes)`
-/// when the entry was copied (reporting the source's logical byte size), or
-/// `None` if skipped because the destination already exists, or because the
-/// source vanished after the caller's directory walk collected it (e.g. a
-/// concurrent build deleting/replacing a build artifact). When `force` is
-/// true, existing entries are removed before copying.
+/// Detects symlinks via `symlink_metadata` on the source. Returns
+/// `Some((bytes, data))` when the entry was copied — the source's logical byte
+/// size, and whether the filesystem shared its extents — or `None` if skipped
+/// because the destination already exists, or because the source vanished after
+/// the caller's directory walk collected it (e.g. a concurrent build
+/// deleting/replacing a build artifact). A symlink reports
+/// [`DataCopy::Neither`]: its content is a path, so there are no extents either
+/// to share or to write, and counting it on either side would make a tree full
+/// of symlinks read as a partial reflink failure. When `force` is true,
+/// existing entries are removed before copying.
///
/// The vanished-source skip never costs the destination a file: the source is
/// stat'd before `force` removes anything, so a source that is already gone
@@ -68,7 +112,7 @@ pub fn copy_leaf(
dest: &Path,
root: Option<&Path>,
force: bool,
-) -> anyhow::Result<Option<u64>> {
+) -> anyhow::Result<Option<(u64, DataCopy)>> {
if let Some(root) = root {
ensure_path_within_root(dest.parent().unwrap_or(dest), root)?;
}
@@ -105,7 +149,7 @@ pub fn copy_leaf(
let is_symlink = src_meta.file_type().is_symlink();
let bytes = src_meta.len();
- if is_symlink {
+ let data = if is_symlink {
let target = match fs::read_link(src) {
Ok(target) => target,
// The source vanished after the stat above. If `force` removed a
@@ -121,9 +165,10 @@ pub fn copy_leaf(
}
};
create_symlink(&target, src, dest)?;
+ DataCopy::Neither
} else {
match reflink_copy::reflink_or_copy(src, dest) {
- Ok(_) => {
+ Ok(fallback) => {
// Preserve file permissions (especially the execute bit) —
// needed on Linux, skipped on macOS.
//
@@ -142,6 +187,7 @@ pub fn copy_leaf(
fs::set_permissions(dest, src_meta.permissions())
.context("setting destination file permissions")?;
}
+ FORCED_DATA_COPY.unwrap_or(classify_copy(fallback))
}
Err(e) if e.kind() == ErrorKind::AlreadyExists => {
tracing::debug!(path = %dest.display(), "skipping existing destination: {}", dest.display());
@@ -160,8 +206,8 @@ pub fn copy_leaf(
return Err(anyhow::Error::from(e).context(format!("copying {}", src.display())));
}
}
- }
- Ok(Some(bytes))
+ };
+ Ok(Some((bytes, data)))
}
fn ensure_path_within_root(path: &Path, root: &Path) -> anyhow::Result<()> {
@@ -301,7 +347,7 @@ pub fn copy_dir_recursive(
.par_iter()
.try_for_each(|leaf| -> anyhow::Result<()> {
match copy_leaf(&leaf.src, &leaf.dest, None, force)? {
- Some(bytes) => progress.record(bytes),
+ Some((bytes, data)) => progress.record(bytes, data),
None => {
skipped_leaves.fetch_add(1, Ordering::Relaxed);
}
@@ -449,6 +495,15 @@ mod tests {
assert_eq!(fs::read(&dest).unwrap(), b"pre-existing content");
}
+ #[test]
+ fn test_classify_copy_reads_the_fallback() {
+ // `reflink_or_copy` reports what it fell back to, so the absent value
+ // is the successful clone. Asserted here because a filesystem only ever
+ // produces one of the two.
+ assert_eq!(classify_copy(None), DataCopy::Reflinked);
+ assert_eq!(classify_copy(Some(4096)), DataCopy::Written);
+ }
+
#[test]
fn test_copy_leaf_force_replaces_existing_destination() {
// The counterpart: with `force` the destination is removed and the
@@ -461,7 +516,12 @@ mod tests {
let result = copy_leaf(&src, &dest, None, true).unwrap();
- assert_eq!(result, Some(b"source content".len() as u64));
+ // Only the byte half is asserted: whether the copy reflinked depends on
+ // the filesystem under the temp dir, which varies across CI runners.
+ assert_eq!(
+ result.map(|(bytes, _)| bytes),
+ Some(b"source content".len() as u64)
+ );
assert_eq!(fs::read(&dest).unwrap(), b"source content");
}
diff --git a/src/progress.rs b/src/progress.rs
index f643a3387..31b4a83f7 100644
--- a/src/progress.rs
+++ b/src/progress.rs
@@ -20,6 +20,10 @@
//! Counts accumulate for the lifetime of the reporter, so each counted
//! operation (or batch reported as one) gets its own `Progress`.
//!
+//! Every [`Progress::record`] also classifies the file by [`DataCopy`], so a
+//! copy can report how much of it shared the source's extents rather than
+//! costing disk. [`Progress::copy_split`] reads that pair back.
+//!
//! `start` is named deliberately (not `new`) because it spawns a ticker thread
//! as a side effect — `Default`-style semantics would be misleading. The verb
//! (`"Copying"`, `"Removing"`) is fixed for the lifetime of the spinner.
@@ -30,14 +34,33 @@
//! The spinner machinery (crossterm, the ticker thread, the render loop) is
//! gated on the `cli` feature. Without `cli`, [`Progress`] keeps the counters
//! but never renders. Pure formatting helpers ([`format_bytes`],
-//! [`format_stats_paren`]) are always available since callers in both modes
-//! want them.
+//! [`format_stats_paren`], [`format_reflink_paren`]) are always available since
+//! callers in both modes want them.
use color_print::cformat;
pub use imp::Progress;
pub use imp::Watchdog;
+/// How a recorded file's data reached its destination, which is what decides
+/// whether the file cost disk.
+///
+/// [`Progress`] counts [`Self::Reflinked`] and [`Self::Written`] separately so
+/// `wt step copy-ignored` can report the split; [`Self::Neither`] contributes
+/// to the file and byte totals only. Only a filesystem clone distinguishes the
+/// first two, so everything that moves no file extents — a symlink, whose
+/// content is a path, and a removal, which frees them — records `Neither`.
+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
+pub enum DataCopy {
+ /// The filesystem cloned the source's extents. The destination shares them
+ /// until one side writes, so the copy costs no data blocks.
+ Reflinked,
+ /// The bytes were written out, costing the file's full size on disk.
+ Written,
+ /// Neither — the record moved no file extents.
+ Neither,
+}
+
#[cfg(feature = "cli")]
mod imp {
use std::io::{IsTerminal, Write};
@@ -91,6 +114,8 @@ mod imp {
struct Shared {
files: AtomicUsize,
bytes: AtomicU64,
+ reflinked: AtomicUsize,
+ written: AtomicUsize,
done: AtomicBool,
rendered: AtomicBool,
}
@@ -100,6 +125,8 @@ mod imp {
Self {
files: AtomicUsize::new(0),
bytes: AtomicU64::new(0),
+ reflinked: AtomicUsize::new(0),
+ written: AtomicUsize::new(0),
done: AtomicBool::new(false),
rendered: AtomicBool::new(false),
}
@@ -174,10 +201,17 @@ mod imp {
}
}
- /// Record that a file (or symlink) was processed. Safe to call from any thread.
- pub fn record(&self, bytes: u64) {
+ /// Record that a file (or symlink) was processed, classified by whether
+ /// its data cost disk. Safe to call from any thread.
+ pub fn record(&self, bytes: u64, data: super::DataCopy) {
self.shared.files.fetch_add(1, Ordering::Relaxed);
self.shared.bytes.fetch_add(bytes, Ordering::Relaxed);
+ let counter = match data {
+ super::DataCopy::Reflinked => &self.shared.reflinked,
+ super::DataCopy::Written => &self.shared.written,
+ super::DataCopy::Neither => return,
+ };
+ counter.fetch_add(1, Ordering::Relaxed);
}
/// Running `(files, bytes)` totals recorded so far.
@@ -191,6 +225,15 @@ mod imp {
)
}
+ /// Running `(reflinked, written)` file counts. Their sum is at most
+ /// `totals().0` — the gap is the files that moved no extents.
+ pub fn copy_split(&self) -> (usize, usize) {
+ (
+ self.shared.reflinked.load(Ordering::Relaxed),
+ self.shared.written.load(Ordering::Relaxed),
+ )
+ }
+
/// Stop the spinner and clear the progress line.
pub fn finish(self) {
// Drop runs the same shutdown logic — no need to duplicate it here.
@@ -592,8 +635,8 @@ mod imp {
#[test]
fn test_enabled_lifecycle_counters_propagate() {
let p = Progress::enabled("Copying");
- p.record(1024);
- p.record(2048);
+ p.record(1024, super::super::DataCopy::Reflinked);
+ p.record(2048, super::super::DataCopy::Written);
assert_eq!(p.totals(), (2, 3072));
p.finish();
}
@@ -621,7 +664,7 @@ mod imp {
// be starved past under load: `rendered` is the background work we're
// verifying, so wait on it directly.
let p = Progress::enabled_with_delays("Removing", Duration::from_millis(10));
- p.record(100);
+ p.record(100, super::super::DataCopy::Neither);
let timeout = Duration::from_secs(5);
let start = Instant::now();
while start.elapsed() < timeout {
@@ -818,6 +861,8 @@ mod imp {
pub struct Progress {
files: AtomicUsize,
bytes: AtomicU64,
+ reflinked: AtomicUsize,
+ written: AtomicUsize,
}
impl Progress {
@@ -829,12 +874,20 @@ mod imp {
Self {
files: AtomicUsize::new(0),
bytes: AtomicU64::new(0),
+ reflinked: AtomicUsize::new(0),
+ written: AtomicUsize::new(0),
}
}
- pub fn record(&self, bytes: u64) {
+ pub fn record(&self, bytes: u64, data: super::DataCopy) {
self.files.fetch_add(1, Ordering::Relaxed);
self.bytes.fetch_add(bytes, Ordering::Relaxed);
+ let counter = match data {
+ super::DataCopy::Reflinked => &self.reflinked,
+ super::DataCopy::Written => &self.written,
+ super::DataCopy::Neither => return,
+ };
+ counter.fetch_add(1, Ordering::Relaxed);
}
pub fn totals(&self) -> (usize, u64) {
@@ -844,6 +897,13 @@ mod imp {
)
}
+ pub fn copy_split(&self) -> (usize, usize) {
+ (
+ self.reflinked.load(Ordering::Relaxed),
+ self.written.load(Ordering::Relaxed),
+ )
+ }
+
pub fn finish(self) {}
}
@@ -914,6 +974,33 @@ pub fn format_stats_paren(files: usize, bytes: u64) -> String {
)
}
+/// Format the reflink split as a gray parenthetical, for a copy summary that
+/// has already reported its file and byte counts.
+///
+/// Takes the two halves of [`Progress::copy_split`]. Only the reflinked wording
+/// carries a gloss, since that is the term a reader won't know; the contrast
+/// then tells them what a full copy cost, without repeating the byte count the
+/// summary just gave.
+///
+/// A mixed result is real, since a tree can span two filesystems, so it reports
+/// the count rather than collapsing to whichever side is larger.
+///
+/// Returns an empty string when neither half has anything in it, so a caller
+/// can concatenate it unconditionally. That covers an empty run and one that
+/// only created symlinks, neither of which has a split to report.
+pub fn format_reflink_paren(reflinked: usize, written: usize) -> String {
+ match (reflinked, written) {
+ (0, 0) => String::new(),
+ (_, 0) => cformat!(" <bright-black>(reflinked, no extra disk)</>"),
+ (0, _) => cformat!(" <bright-black>(full copy)</>"),
+ _ => cformat!(
+ " <bright-black>({} of {} reflinked)</>",
+ format_count(reflinked),
+ format_count(reflinked + written),
+ ),
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
@@ -957,14 +1044,40 @@ mod tests {
assert!(s.contains("5.0 MiB"));
}
+ // Which half is zero picks the wording, and the mixed case is the one no
+ // integration test can stage — it needs two filesystems under one tree.
+ #[test]
+ fn test_format_reflink_paren_wording() {
+ assert_eq!(format_reflink_paren(0, 0), "");
+ assert!(format_reflink_paren(3, 0).contains("(reflinked, no extra disk)"));
+ assert!(format_reflink_paren(0, 3).contains("(full copy)"));
+ assert!(format_reflink_paren(2, 1).contains("(2 of 3 reflinked)"));
+ assert!(format_reflink_paren(1_500, 500).contains("(1,500 of 2,000 reflinked)"));
+ }
+
// Not cfg-gated: covers the disabled-state counting contract in both the
// `cli` implementation and the no-`cli` stub.
#[test]
fn test_disabled_still_counts() {
let p = Progress::disabled();
- p.record(1_000_000);
- p.record(2_000_000);
+ p.record(1_000_000, DataCopy::Reflinked);
+ p.record(2_000_000, DataCopy::Written);
assert_eq!(p.totals(), (2, 3_000_000));
p.finish();
}
+
+ // The split counts only what moved extents, so `Neither` lands in the
+ // file/byte totals and in neither half — the property that keeps a tree of
+ // symlinks from reading as a partial reflink failure.
+ #[test]
+ fn test_copy_split_excludes_extentless_records() {
+ let p = Progress::disabled();
+ p.record(10, DataCopy::Reflinked);
+ p.record(20, DataCopy::Reflinked);
+ p.record(30, DataCopy::Written);
+ p.record(40, DataCopy::Neither);
+ assert_eq!(p.totals(), (4, 100));
+ assert_eq!(p.copy_split(), (2, 1));
+ p.finish();
+ }
}
diff --git a/src/remove_dir.rs b/src/remove_dir.rs
index 06cbf28d8..e1de4bb6b 100644
--- a/src/remove_dir.rs
+++ b/src/remove_dir.rs
@@ -21,7 +21,7 @@ use std::sync::LazyLock;
use rayon::prelude::*;
-use crate::progress::Progress;
+use crate::progress::{DataCopy, Progress};
/// Capped at 4 threads — same reasoning as `copy::COPY_POOL` (filesystem I/O,
/// don't oversubscribe CPU when many wt subprocesses run in parallel).
@@ -76,7 +76,9 @@ pub fn remove_dir_with_progress(path: &Path, progress: &Progress) {
// count the leaf with zero bytes.
let bytes = leaf.symlink_metadata().map(|m| m.len()).unwrap_or(0);
if fs::remove_file(leaf).is_ok() {
- progress.record(bytes);
+ // A removal frees extents rather than moving them, so it has no
+ // side of the reflink split to land on.
+ progress.record(bytes, DataCopy::Neither);
}
});
});
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 39aa0e3ce..9006b10ce 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -1286,9 +1286,9 @@ pub fn setup_temp_snapshot_settings(temp_path: &std::path::Path) -> insta::Setti
/// total is sensitive to the temp-dir prefix (macOS `/var/folders/...` vs
/// Linux `/tmp/...` vs Windows). The literal `(...files · X UNIT)` shape is
/// unique enough to leave the deterministic copy-ignored summary
-/// (`Copied N files · X B` — no surrounding parens) untouched, so the regex
-/// doesn't depend on ANSI styling and works in both colored and `NO_COLOR`
-/// test environments.
+/// (`Copied N files · X B`, whose own parenthetical carries the reflink split
+/// rather than a byte count) untouched, so the regex doesn't depend on ANSI
+/// styling and works in both colored and `NO_COLOR` test environments.
fn add_remove_stats_byte_filter(settings: &mut insta::Settings) {
settings.add_filter(
r"(\(\d+ files? · )\d+(?:\.\d+)? (B|KiB|MiB|GiB|TiB)",
diff --git a/tests/integration_tests/step_copy_ignored.rs b/tests/integration_tests/step_copy_ignored.rs
index e433125fe..a18038df1 100644
--- a/tests/integration_tests/step_copy_ignored.rs
+++ b/tests/integration_tests/step_copy_ignored.rs
@@ -5,6 +5,44 @@ use insta_cmd::assert_cmd_snapshot;
use rstest::rstest;
use std::fs;
use std::path::{Path, PathBuf};
+use std::process::Command;
+
+/// Pin the reflink half of the copy summary, which is otherwise a property of
+/// the filesystem under the test's temp directory — APFS reflinks, the ext4 and
+/// NTFS runners cannot, and no one snapshot holds on all three. The copy still
+/// attempts a reflink either way; only the reported label is fixed.
+///
+/// **Every snapshot of a copy-ignored run in this file needs this**, via
+/// [`snapshot_cmd`] / [`snapshot_cmd_with_global_flags`] or applied by hand
+/// where a test builds its own command, as `test_copy_ignored_bare_repo` does.
+/// Missing it is not silent — the snapshot passes wherever it was recorded and
+/// fails on the other runners — but it costs a CI round-trip to find out.
+///
+/// The pin lives here rather than in `STATIC_TEST_ENV_VARS`, which would reach
+/// every child and add a line to the `env:` block of all 996 snapshots that
+/// record one, to make deterministic the ~12 that show this summary.
+/// `copy_ignored_reports_a_full_copy` pins the opposite branch.
+fn pin_reflink(mut cmd: Command, reflinked: bool) -> Command {
+ cmd.env("WORKTRUNK_TEST_REFLINK", if reflinked { "1" } else { "0" });
+ cmd
+}
+
+fn snapshot_cmd(repo: &TestRepo, subcommand: &str, args: &[&str], cwd: Option<&Path>) -> Command {
+ pin_reflink(make_snapshot_cmd(repo, subcommand, args, cwd), true)
+}
+
+fn snapshot_cmd_with_global_flags(
+ repo: &TestRepo,
+ subcommand: &str,
+ args: &[&str],
+ cwd: Option<&Path>,
+ global_flags: &[&str],
+) -> Command {
+ pin_reflink(
+ make_snapshot_cmd_with_global_flags(repo, subcommand, args, cwd, global_flags),
+ true,
+ )
+}
const CUSTOM_COPY_IGNORED_EXCLUDE_CONFIG: &str = r#"[step.copy-ignored]
exclude = [".custom-cache/"]
"#;
@@ -78,7 +116,7 @@ fn setup_copy_ignored_exclude_fixture(repo: &mut TestRepo) -> PathBuf {
fn test_copy_ignored_no_worktreeinclude(mut repo: TestRepo) {
let feature_path = repo.add_worktree("feature");
// No .worktreeinclude file and no gitignored files → nothing to copy
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored"],
@@ -86,6 +124,23 @@ fn test_copy_ignored_no_worktreeinclude(mut repo: TestRepo) {
));
}
+/// What an ext4 or NTFS user sees: no reflink, so every byte is written out and
+/// the summary says so instead of repeating the line it would print on APFS.
+///
+/// Every other snapshot in this file pins the reflinked branch, so the two
+/// together cover both wordings on all three CI platforms.
+#[rstest]
+fn test_copy_ignored_reports_a_full_copy(mut repo: TestRepo) {
+ let feature_path = repo.add_worktree("feature");
+ fs::write(repo.root_path().join(".env"), "SECRET=value").unwrap();
+ fs::write(repo.root_path().join(".gitignore"), ".env\n").unwrap();
+
+ assert_cmd_snapshot!(pin_reflink(
+ make_snapshot_cmd(&repo, "step", &["copy-ignored"], Some(&feature_path)),
+ false,
+ ));
+}
+
/// Test default behavior: copies all gitignored files when no .worktreeinclude exists
#[rstest]
fn test_copy_ignored_default_copies_all(mut repo: TestRepo) {
@@ -97,7 +152,7 @@ fn test_copy_ignored_default_copies_all(mut repo: TestRepo) {
fs::write(repo.root_path().join(".gitignore"), ".env\ncache.db\n").unwrap();
// Without .worktreeinclude, all gitignored files should be copied
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored"],
@@ -167,7 +222,7 @@ fn test_copy_ignored_invalid_worktreeinclude(mut repo: TestRepo) {
fs::write(repo.root_path().join(".worktreeinclude"), "{unclosed\n").unwrap();
// Should fail with parse error
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored"],
@@ -183,7 +238,7 @@ fn test_copy_ignored_empty_intersection(mut repo: TestRepo) {
fs::write(repo.root_path().join(".worktreeinclude"), ".env\n").unwrap();
// But don't create .gitignore or .env file
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored"],
@@ -204,7 +259,7 @@ fn test_copy_ignored_not_ignored_file(mut repo: TestRepo) {
fs::write(repo.root_path().join(".worktreeinclude"), ".env\n").unwrap();
// Run from feature worktree
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored"],
@@ -313,7 +368,7 @@ fn test_copy_ignored_dry_run(mut repo: TestRepo) {
fs::write(repo.root_path().join(".worktreeinclude"), ".env\n").unwrap();
// Run with --dry-run
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored", "--dry-run"],
@@ -394,7 +449,7 @@ fn test_copy_ignored_same_worktree(repo: TestRepo) {
fs::write(repo.root_path().join(".worktreeinclude"), ".env\n").unwrap();
// Run from main worktree (source = dest = main)
- assert_cmd_snapshot!(make_snapshot_cmd(&repo, "step", &["copy-ignored"], None,));
+ assert_cmd_snapshot!(snapshot_cmd(&repo, "step", &["copy-ignored"], None,));
}
/// Test --from flag to specify source worktree
@@ -414,7 +469,7 @@ fn test_copy_ignored_from_flag(mut repo: TestRepo) {
fs::write(feature_a.join(".worktreeinclude"), ".env\n").unwrap();
// Run from feature-b, copying from feature-a
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored", "--from", "feature-a"],
@@ -540,7 +595,7 @@ fn test_copy_ignored_to_flag(mut repo: TestRepo) {
fs::write(repo.root_path().join(".worktreeinclude"), ".env\n").unwrap();
// Run from feature-a, copying from main (default) to feature-b (explicit)
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored", "--to", "feature-b"],
@@ -566,7 +621,7 @@ fn test_copy_ignored_from_nonexistent_worktree(repo: TestRepo) {
.unwrap();
// Try to copy from a branch with no worktree
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored", "--from", "orphan-branch"],
@@ -588,7 +643,7 @@ fn test_copy_ignored_to_nonexistent_worktree(repo: TestRepo) {
fs::write(repo.root_path().join(".gitignore"), ".env\n").unwrap();
// Try to copy to a branch with no worktree
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored", "--to", "orphan-branch"],
@@ -656,7 +711,9 @@ fn test_copy_ignored_bare_repo() {
cmd.args(["step", "copy-ignored"])
.current_dir(&feature_worktree);
- insta_cmd::assert_cmd_snapshot!(cmd);
+ // Builds its own command rather than going through `snapshot_cmd`, so
+ // the pin has to be applied by hand here.
+ insta_cmd::assert_cmd_snapshot!(pin_reflink(cmd, true));
});
// Verify file was copied
@@ -692,7 +749,7 @@ fn test_copy_ignored_force_overwrites(mut repo: TestRepo) {
);
// With --force: existing file SHOULD be overwritten
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored", "--force"],
@@ -716,7 +773,7 @@ fn test_copy_ignored_force_no_existing(mut repo: TestRepo) {
fs::write(repo.root_path().join(".worktreeinclude"), ".env\n").unwrap();
// --force on a fresh worktree should still copy successfully
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored", "--force"],
@@ -870,7 +927,7 @@ fn test_copy_ignored_verbose(mut repo: TestRepo) {
fs::write(repo.root_path().join(".gitignore"), ".env\n").unwrap();
// Run with -v (global verbose flag)
- assert_cmd_snapshot!(make_snapshot_cmd_with_global_flags(
+ assert_cmd_snapshot!(snapshot_cmd_with_global_flags(
&repo,
"step",
&["copy-ignored"],
@@ -893,7 +950,7 @@ fn test_copy_ignored_verbose_directory(mut repo: TestRepo) {
fs::write(target_dir.join("debug").join("output"), "binary").unwrap();
fs::write(repo.root_path().join(".gitignore"), "target/\n").unwrap();
- assert_cmd_snapshot!(make_snapshot_cmd_with_global_flags(
+ assert_cmd_snapshot!(snapshot_cmd_with_global_flags(
&repo,
"step",
&["copy-ignored"],
@@ -923,7 +980,7 @@ fn test_copy_ignored_counts_files_not_entries(mut repo: TestRepo) {
fs::write(target_dir.join("debug/deps/libbar.rlib"), "lib").unwrap();
fs::write(repo.root_path().join(".gitignore"), "target/\n").unwrap();
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored"],
@@ -1547,7 +1604,7 @@ fn test_copy_ignored_skips_nested_worktrees(mut repo: TestRepo) {
let dest_path = repo.add_worktree("destination");
// Run copy-ignored
- assert_cmd_snapshot!(make_snapshot_cmd(
+ assert_cmd_snapshot!(snapshot_cmd(
&repo,
"step",
&["copy-ignored"],
@@ -1646,6 +1703,38 @@ fn test_copy_ignored_dry_run_json(mut repo: TestRepo) {
assert_eq!(entries[0]["path"], ".env");
assert_eq!(entries[0]["kind"], "file");
+ // A plan says what would be copied, so it carries none of the four result
+ // counts — the same shape whether or not anything matched. Two early
+ // returns reach `planned` with an empty entry list and this path reaches it
+ // with a full one, so both are checked; a count appearing in either would
+ // make `jq '.reflinked + .written'` null on one plan and a number on
+ // another.
+ for key in ["files", "bytes", "reflinked", "written"] {
+ assert!(parsed[key].is_null(), "populated plan carries {key}");
+ }
+
+ fs::remove_file(repo.root_path().join(".worktreeinclude")).unwrap();
+ let output = repo
+ .wt_command()
+ .args([
+ "step",
+ "copy-ignored",
+ "--dry-run",
+ "--require-include",
+ "--format=json",
+ ])
+ .current_dir(&feature_path)
+ .output()
+ .unwrap();
+ assert!(output.status.success());
+ let empty: serde_json::Value =
+ serde_json::from_str(&String::from_utf8_lossy(&output.stdout)).expect("valid JSON");
+ assert_eq!(empty["outcome"], "planned");
+ assert_eq!(empty["entries"].as_array().expect("entries array").len(), 0);
+ for key in ["files", "bytes", "reflinked", "written"] {
+ assert!(empty[key].is_null(), "empty plan carries {key}");
+ }
+
// Dry run did not copy
assert!(!feature_path.join(".env").exists());
}
@@ -1673,6 +1762,13 @@ fn test_copy_ignored_json_summary(mut repo: TestRepo) {
assert_eq!(parsed["files"], 1);
// .env content "SECRET=value" is 12 bytes
assert_eq!(parsed["bytes"], 12);
+ // The disk-cost split. Which side the file lands on is the runner's
+ // filesystem talking, so the assertion is the invariant that holds on all
+ // of them: the two halves account for every copied file, since this tree
+ // has no symlinks.
+ let reflinked = parsed["reflinked"].as_u64().expect("reflinked count");
+ let written = parsed["written"].as_u64().expect("written count");
+ assert_eq!(reflinked + written, 1);
let entries = parsed["entries"].as_array().expect("entries array");
assert_eq!(entries.len(), 1);
assert_eq!(entries[0]["path"], ".env");
@@ -1708,6 +1804,10 @@ fn test_copy_ignored_same_worktree_json(mut repo: TestRepo) {
assert_eq!(parsed["outcome"], "same_worktree");
assert_eq!(parsed["files"], 0);
assert_eq!(parsed["bytes"], 0);
+ // Every payload reporting a result carries all four counts, so a consumer
+ // never has to branch on a key's presence.
+ assert_eq!(parsed["reflinked"], 0);
+ assert_eq!(parsed["written"], 0);
assert_eq!(
parsed["entries"].as_array().expect("entries array").len(),
0
@@ -1739,6 +1839,8 @@ fn test_copy_ignored_no_matches_json(mut repo: TestRepo) {
assert_eq!(parsed["dry_run"], false);
assert_eq!(parsed["files"], 0);
assert_eq!(parsed["bytes"], 0);
+ assert_eq!(parsed["reflinked"], 0);
+ assert_eq!(parsed["written"], 0);
assert_eq!(
parsed["entries"].as_array().expect("entries array").len(),
0
@@ -1797,6 +1899,8 @@ fn test_copy_ignored_require_include_json_reason(mut repo: TestRepo) {
serde_json::from_str(&String::from_utf8_lossy(&output.stdout)).expect("valid JSON");
assert_eq!(parsed["reason"], "require-include-no-worktreeinclude");
assert_eq!(parsed["files"], 0);
+ assert_eq!(parsed["reflinked"], 0);
+ assert_eq!(parsed["written"], 0);
assert!(!feature_path.join(".env").exists());
}
diff --git a/tests/snapshots/integration__integration_tests__help__help_step_copy_ignored.snap b/tests/snapshots/integration__integration_tests__help__help_step_copy_ignored.snap
index 0ae9cbe87..adcde47a1 100644
--- a/tests/snapshots/integration__integration_tests__help__help_step_copy_ignored.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_step_copy_ignored.snap
@@ -154,7 +154,7 @@ Files are reflinked where the filesystem supports it: APFS (macOS), btrfs and XF
cp -R (full copy) 2m 14GB
cp -Rc / wt step copy-ignored 20s ~0
-On ext4 and NTFS, which have no reflink, every file is copied in full.
+On ext4 and NTFS, which have no reflink, every file is copied in full. The same byte count therefore costs nothing on one filesystem and 14GB on the other, so the summary says which happened: Copied 4,812 files · 14.0 GB (reflinked, no extra disk), against (full copy) where those bytes were written out.
Reflinks are per file (like cp -Rc), so copy time scales with file count.
diff --git a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_bare_repo.snap b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_bare_repo.snap
index f769c51de..82bf76c31 100644
--- a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_bare_repo.snap
+++ b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_bare_repo.snap
@@ -42,6 +42,7 @@ info:
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_REFLINK: "1"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WORKTRUNK_TEST_ZSH_INSTALLED: "0"
---
@@ -50,4 +51,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-✓ Copied 1 file · 12 B
+✓ Copied 1 file · 12 B (reflinked, no extra disk)
diff --git a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_counts_files_not_entries.snap b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_counts_files_not_entries.snap
index 5aea94f1d..3e0640382 100644
--- a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_counts_files_not_entries.snap
+++ b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_counts_files_not_entries.snap
@@ -50,6 +50,7 @@ info:
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_REFLINK: "1"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WORKTRUNK_TEST_ZSH_INSTALLED: "0"
XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
@@ -59,4 +60,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-✓ Copied 3 files · 10 B
+✓ Copied 3 files · 10 B (reflinked, no extra disk)
diff --git a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_default_copies_all.snap b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_default_copies_all.snap
index 6f4d490e7..63f405a78 100644
--- a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_default_copies_all.snap
+++ b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_default_copies_all.snap
@@ -50,6 +50,7 @@ info:
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_REFLINK: "1"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WORKTRUNK_TEST_ZSH_INSTALLED: "0"
XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
@@ -59,4 +60,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-✓ Copied 2 files · 23 B
+✓ Copied 2 files · 23 B (reflinked, no extra disk)
diff --git a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_force_no_existing.snap b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_force_no_existing.snap
index 7e04684d7..869f62470 100644
--- a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_force_no_existing.snap
+++ b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_force_no_existing.snap
@@ -51,6 +51,7 @@ info:
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_REFLINK: "1"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WORKTRUNK_TEST_ZSH_INSTALLED: "0"
XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
@@ -60,4 +61,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-✓ Copied 1 file · 12 B
+✓ Copied 1 file · 12 B (reflinked, no extra disk)
diff --git a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_force_overwrites.snap b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_force_overwrites.snap
index 62fb9eb14..2cb70e13f 100644
--- a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_force_overwrites.snap
+++ b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_force_overwrites.snap
@@ -51,6 +51,7 @@ info:
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_REFLINK: "1"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WORKTRUNK_TEST_ZSH_INSTALLED: "0"
XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
@@ -60,4 +61,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-✓ Copied 1 file · 18 B
+✓ Copied 1 file · 18 B (reflinked, no extra disk)
diff --git a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_from_flag.snap b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_from_flag.snap
index 611497dab..1f0b759c0 100644
--- a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_from_flag.snap
+++ b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_from_flag.snap
@@ -52,6 +52,7 @@ info:
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_REFLINK: "1"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WORKTRUNK_TEST_ZSH_INSTALLED: "0"
XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
@@ -61,4 +62,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-✓ Copied 1 file · 14 B
+✓ Copied 1 file · 14 B (reflinked, no extra disk)
diff --git a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_reports_a_full_copy.snap b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_reports_a_full_copy.snap
new file mode 100644
index 000000000..0e5d77a4f
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_reports_a_full_copy.snap
@@ -0,0 +1,63 @@
+---
+source: tests/integration_tests/step_copy_ignored.rs
+info:
+ program: wt
+ args:
+ - step
+ - copy-ignored
+ 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_REFLINK: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WORKTRUNK_TEST_ZSH_INSTALLED: "0"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
+✓ Copied 1 file · 12 B (full copy)
diff --git a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_skips_nested_worktrees.snap b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_skips_nested_worktrees.snap
index 341ebe7ac..f03ade408 100644
--- a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_skips_nested_worktrees.snap
+++ b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_skips_nested_worktrees.snap
@@ -50,6 +50,7 @@ info:
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_REFLINK: "1"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WORKTRUNK_TEST_ZSH_INSTALLED: "0"
XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
@@ -59,4 +60,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-✓ Copied 1 file · 12 B
+✓ Copied 1 file · 12 B (reflinked, no extra disk)
diff --git a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_to_flag.snap b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_to_flag.snap
index 1fe80621e..465c792e0 100644
--- a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_to_flag.snap
+++ b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_to_flag.snap
@@ -52,6 +52,7 @@ info:
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_REFLINK: "1"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WORKTRUNK_TEST_ZSH_INSTALLED: "0"
XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
@@ -61,4 +62,4 @@ exit_code: 0
----- stdout -----
----- stderr -----
-✓ Copied 1 file · 9 B
+✓ Copied 1 file · 9 B (reflinked, no extra disk)
diff --git a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_verbose.snap b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_verbose.snap
index 0c238241f..5a6dc5e23 100644
--- a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_verbose.snap
+++ b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_verbose.snap
@@ -51,6 +51,7 @@ info:
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_REFLINK: "1"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WORKTRUNK_TEST_ZSH_INSTALLED: "0"
XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
@@ -62,4 +63,4 @@ exit_code: 0
----- stderr -----
○ Copying 1 entry:
  .env (file)
-✓ Copied 1 file · 12 B
+✓ Copied 1 file · 12 B (reflinked, no extra disk)
diff --git a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_verbose_directory.snap b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_verbose_directory.snap
index 05dd09b0d..bb13cdf63 100644
--- a/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_verbose_directory.snap
+++ b/tests/snapshots/integration__integration_tests__step_copy_ignored__copy_ignored_verbose_directory.snap
@@ -51,6 +51,7 @@ info:
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_REFLINK: "1"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WORKTRUNK_TEST_ZSH_INSTALLED: "0"
XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
@@ -62,4 +63,4 @@ exit_code: 0
----- stderr -----
○ Copying 1 entry:
  target (dir)
-✓ Copied 1 file · 6 B
+✓ Copied 1 file · 6 B (reflinked, no extra disk)