From 7c46b28aabb4858226fb08287b8e9ee74bbe6458 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Fri, 20 Feb 2026 08:27:34 -0800 Subject: [PATCH] Add dirty worktree check before merge to prevent unsaved changes from being lost --- src/cli.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cli.ts b/src/cli.ts index 37909d0..5fc02a0 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -413,6 +413,12 @@ program .description("Merge a branch into main and close the session") .action(async (branch: string) => { const root = await git.repoRoot() + const session = await state.getSession(root, branch) + + if (session && await git.isDirty(session.worktree)) { + console.error(`✖ Branch "${branch}" has unsaved changes. Run "sandlot save ${branch}" first.`) + process.exit(1) + } const conflicts = await git.merge(branch, root)