{"record":{"id":"13e111f6a1c44bac","repo":"nikivdev/code","slug":"aborted-commit-or-stash-changes-before-continuing","errorCode":null,"errorMessage":"Aborted; commit or stash changes before continuing.","messagePattern":"Aborted; commit or stash changes before continuing\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/ext.rs","lineNumber":267,"sourceCode":"    };\n\n    let workspace = workspace_name_for_project(project_root)?;\n    if workspace.is_empty() {\n        return Ok(source.to_path_buf());\n    }\n\n    let status = git_capture_in(&repo_root, &[\"status\", \"--porcelain\"]).unwrap_or_default();\n    if !status.trim().is_empty() {\n        println!(\"Source repo has uncommitted changes:\");\n        for line in status.lines().take(20) {\n            println!(\"  {line}\");\n        }\n        let continue_anyway = prompt_yes_no(\n            &format!(\"Continue and use jj workspace \\\"{}\\\"?\", workspace),\n            false,\n        )?;\n        if !continue_anyway {\n            bail!(\"Aborted; commit or stash changes before continuing.\");\n        }\n    }\n\n    let workspaces = jj_workspace_list(&repo_root).unwrap_or_default();\n    if let Some(existing_path) = workspaces.get(&workspace) {\n        return Ok(PathBuf::from(existing_path));\n    }\n\n    let base = workspace_base(&repo_root)?;\n    fs::create_dir_all(&base).with_context(|| format!(\"failed to create {}\", base.display()))?;\n    let workspace_path = base.join(&workspace);\n    jj_run_in(\n        &repo_root,\n        &[\n            \"workspace\",\n            \"add\",\n            workspace_path\n                .to_str()","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ext.rs#L249-L285","documentation":"When the source workspace has uncommitted/dirty state, prepare_source_workspace asks the user to confirm continuing. Answering no (the default) aborts the import, telling the user to commit or stash first so the imported snapshot is consistent.","triggerScenarios":"import_external_path on a jj workspace with working-copy changes, and the user presses Enter or answers 'n' at the \"Continue and use jj workspace ...?\" prompt (default_yes=false).","commonSituations":"Importing a workspace mid-development with uncommitted edits; accidentally accepting the safe default; scripted runs where stdin yields a non-affirmative answer.","solutions":["In the source workspace run `jj commit` (or `jj new`) to describe the working copy, then retry.","Use `jj st` to review changes and `jj restore`/stash anything unwanted.","If the state is intentional, answer 'y' at the confirmation prompt."],"exampleFix":"// before (shell)\nimport-external ~/repos/dirty-ws   # answer: n\n// after (shell)\ncd ~/repos/dirty-ws && jj commit -m \"wip before import\"\nimport-external ~/repos/dirty-ws","handlingStrategy":"validation","validationCode":"let st = std::process::Command::new(\"jj\")\n    .args([\"st\"])\n    .current_dir(source)\n    .output()?;\nlet dirty = String::from_utf8_lossy(&st.stdout).contains(\"Working copy changes\");\nif dirty {\n    return Err(anyhow!(\"Commit or stash changes in {} before importing\", source));\n}\nimport_external_path(source)?;","typeGuard":"fn has_uncommitted_changes(status_output: &str) -> bool {\n    !status_output.trim().is_empty()\n}","tryCatchPattern":"match import_external_path(source) {\n    Err(e) if e.to_string().contains(\"Aborted\") => {\n        eprintln!(\"Clean the source workspace (jj commit / jj new) and retry\");\n    }\n    other => other?,\n}","preventionTips":["Adopt a habit of `jj commit -m wip` before any import/sync operation.","Check `jj st` in the source as a pre-flight step in scripts.","Run imports interactively if you intend to answer confirmation prompts."],"tags":["vcs","uncommitted-changes","user-abort"],"backgroundTag":"uncommitted-changes","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}