diff --git a/src/wt/cmd/init.lua b/src/wt/cmd/init.lua index b5d9f8e8a9891e7d526b5b258d0903a8700c0d83..baa9bb86f0a5c415ed6c1641430acb04cdbe8042 100644 --- a/src/wt/cmd/init.lua +++ b/src/wt/cmd/init.lua @@ -134,7 +134,10 @@ function M.cmd_init(args) -- Check for uncommitted changes local status_out = shell.run_cmd("git status --porcelain") if status_out ~= "" then - shell.die("uncommitted changes; commit or stash before converting") + io.stderr:write("error: uncommitted changes\n") + io.stderr:write("hint: commit, or stash and restore after:\n") + io.stderr:write(" git stash -u && wt init && cd && git stash pop\n") + os.exit(exit.EXIT_USER_ERROR) end -- Detect default branch @@ -196,14 +199,22 @@ function M.cmd_init(args) io.stderr:write("warning: " .. w .. "\n") end - -- Confirm with gum (unless -y/--yes) - if not skip_confirm then - local confirm_msg = "Convert to wt bare structure? This will move .git to .bare" - if #orphaned > 0 then - confirm_msg = confirm_msg .. " and remove " .. #orphaned .. " items from root" + -- Prominent warning about file deletion + if #orphaned > 0 then + io.stderr:write("\n") + io.stderr:write("WARNING: The following " .. #orphaned .. " items will be DELETED from project root:\n") + for _, item in ipairs(orphaned) do + io.stderr:write(" - " .. item .. "\n") end + io.stderr:write("\n") + io.stderr:write("These files are preserved in the new worktree at:\n") + io.stderr:write(" " .. worktree_path .. "\n") + io.stderr:write("\n") + end - local confirm_code = os.execute("gum confirm '" .. confirm_msg .. "'") + -- Confirm with gum (unless -y/--yes) + if not skip_confirm then + local confirm_code = os.execute("gum confirm 'Convert to wt bare structure?'") if confirm_code ~= true then print("Aborted") os.exit(exit.EXIT_USER_ERROR)