{"record":{"id":"10fa60ad00f8beac","repo":"gitbutlerapp/gitbutler","slug":"tearing-off-a-branch-requires-a-workspace-common-b","errorCode":null,"errorMessage":"Tearing off a branch requires a workspace common base","messagePattern":"Tearing off a branch requires a workspace common base","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/branch/move_branch.rs","lineNumber":111,"sourceCode":"                ws_meta,\n                new_tip: None,\n                branch_stack_order: None,\n            });\n        }\n\n        let Some(workspace_head) = workspace.tip_commit().map(|commit| commit.id) else {\n            bail!(\"Couldn't find workspace head.\")\n        };\n        let head_selector = editor\n            .select_commit(workspace_head)\n            .context(\"Failed to find the workspace head in the graph.\")?;\n\n        let Some(lower_bound_ref) = workspace\n            .lower_bound_segment_id\n            .map(|segment_id| &workspace.graph[segment_id])\n            .and_then(|segment| segment.ref_name())\n        else {\n            bail!(\"Tearing off a branch requires a workspace common base\");\n        };\n\n        let target_selector = editor\n            .select_reference(lower_bound_ref)\n            .context(\"Failed to find target reference in graph.\")?;\n\n        let DisconnectParameters {\n            delimiter: subject_delimiter,\n            children_to_disconnect,\n            parents_to_disconnect,\n        } = get_disconnect_parameters(\n            &editor,\n            source_stack,\n            subject_segment,\n            Some(workspace_head),\n        )?;\n\n        editor.disconnect_segment_from(","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-workspace/src/branch/move_branch.rs#L93-L129","documentation":"Tearing off a branch requires the workspace graph to have a common base - a lower-bound segment whose ref the workspace was cut from. The lower_bound_segment_id is missing or the segment has no ref name, so tear_off_branch() cannot determine where the workspace diverged and refuses to proceed.","triggerScenarios":"Calling tear_off_branch() on a workspace whose lower_bound_segment_id is None, or whose lower-bound graph segment is anonymous (no ref_name), so no common-base reference can be selected in the graph.","commonSituations":"Workspaces created without a base reference; stacked-branch workspaces whose lower bound segment lost its ref after deletes/rewrites; graphs built from repos where the workspace has no upstream/base ref.","solutions":["Ensure the workspace was created from a base ref so it has a lower-bound segment","Check the workspace graph for an anonymous lower bound and rebase/recreate the workspace on a named base ref","Use a different operation (e.g. rebase or move) if the workspace lacks a common base"],"exampleFix":"// before\nlet outcome = tear_off_branch(editor, ref_name);\n// after\nif workspace.lower_bound_segment_id.is_none() {\n    anyhow::bail!(\"workspace has no common base; cannot tear off\");\n}\nlet outcome = tear_off_branch(editor, ref_name);","handlingStrategy":"validation","validationCode":"if workspace.lower_bound_segment_id\n    .map(|id| workspace.graph[id].ref_name().is_none())\n    .unwrap_or(true)\n{\n    // workspace lacks a named common base\n}","typeGuard":null,"tryCatchPattern":"match tear_off_branch(editor, ref_name) {\n    Err(e) if e.to_string().contains(\"workspace common base\") => recreate_workspace_on_named_base(),\n    other => other?,\n}","preventionTips":["Always create workspaces from a named base ref","Avoid deleting the lower-bound/base ref of a workspace","Inspect the graph's lower-bound segment before tear-off operations"],"tags":["git","workspace","graph"],"backgroundTag":"missing-required-argument","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}