From b7297048addc62120a384152eacf81835f409d86 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 22 Oct 2026 04:54:47 +0300 Subject: [PATCH] Remove cloned observations a worktree's start revision doesn't track Content: the tree of `development` at a8e59892a7, unchanged. --- scripts/lean-tree | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/lean-tree b/scripts/lean-tree index bf6f37c7b..ce3410b1f 100755 --- a/scripts/lean-tree +++ b/scripts/lean-tree @@ -8,7 +8,8 @@ # worktree adds a git worktree on a new branch, with every tracked file. The observations are # copy-on-write clones of the main worktree's (cp -c on APFS, --reflink=auto elsewhere), which write # nothing until a file in them changes. git then hashes the clones against START_REV and rewrites -# only the files that differ, so the tree is exactly START_REV's whatever the main worktree holds. +# only the files that differ; files START_REV doesn't track are removed from the clone, so the tree +# is exactly START_REV's whatever the main worktree holds. # When the main worktree has no observations to clone, git checks them out as usual. # # snapshot extracts `git archive REV` into DEST_DIR with `tar -xm`, so every file carries the @@ -51,10 +52,11 @@ worktree) mkdir -p "$path/$(dirname "$observations")" clone "$main/$observations" "$path/$observations" # The index from START_REV with the working tree untouched; hashing the clones records the ones - # that match, and the checkout writes everything else. + # that match, the checkout writes everything else, and clean removes what START_REV doesn't track. git -C "$path" reset -q git -C "$path" update-index -q --refresh || true git -C "$path" checkout -q -- . + git -C "$path" clean -q -f -d -x -- "$observations" ;; snapshot) [ $# -ge 3 ] || die "usage: lean-tree snapshot REV DEST_DIR [--with-observations]"