{"record":{"id":"55a74494acb5df31","repo":"GitoxideLabs/gitoxide","slug":"cannot-time-travel-from-an-unborn-head","errorCode":null,"errorMessage":"cannot time-travel from an unborn HEAD","messagePattern":"cannot time-travel from an unborn HEAD","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/time_travel.rs","lineNumber":751,"sourceCode":"    clippy::too_many_arguments,\n    reason = \"time travel context plus rebased-commit reporting\"\n)]\npub(crate) fn perform_reporting_rebased(\n    repository_path: &Path,\n    bare: bool,\n    mut selected: ObjectId,\n    graph: &history::HistoryGraph,\n    review_roots: &[ObjectId],\n    revisions: &[OsString],\n    include_worktrees: bool,\n    mut report: impl FnMut(ObjectId),\n) -> Result<Perform> {\n    let mut repository =\n        open_repository(repository_path, bare, false).context(\"could not open repository for time-travel\")?;\n    repository.workdir().context(\"time-travel requires a worktree\")?;\n    let head = repository.head().context(\"could not read HEAD before time-travel\")?;\n    let Some(mut head_id) = head.id().map(gix::Id::detach) else {\n        anyhow::bail!(\"cannot time-travel from an unborn HEAD\");\n    };\n    let head_was_detached = head.is_detached();\n    drop(head);\n    if repository\n        .index_or_empty()\n        .context(\"could not inspect the index before time-travel\")?\n        .entries()\n        .iter()\n        .any(|entry| entry.stage() != gix::index::entry::Stage::Unconflicted)\n    {\n        anyhow::bail!(\"cannot time-travel with unresolved index conflicts\");\n    }\n    let source_review = review_tree(&repository, graph, review_roots, head_id)?;\n    let destination_review = review_tree(&repository, graph, review_roots, selected)?;\n    let crosses_review_boundary =\n        source_review.as_ref().map(|review| review.root) != destination_review.as_ref().map(|review| review.root);\n    let mut completed_graph = None;\n    let mut original_ids = HashMap::new();","sourceCodeStart":733,"sourceCodeEnd":769,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/time_travel.rs#L733-L769","documentation":"Time travel cannot start because HEAD is unborn: the repository has no commits (HEAD points at a branch that does not exist yet), so `head.id()` returns None. The library bails since there is no commit to travel from. Thrown at the start of `perform_reporting_rebased`.","triggerScenarios":"Calling perform (or the listed tests) on a freshly `git init`-ed repository before the first commit, or on a repo whose current branch has no commits, so `head.id()` is None and the `let ... else` bails.","commonSituations":"Running the tool right after initializing a repo; an orphan branch checkout with no commits; a repo where the initial commit failed and the branch never materialized.","solutions":["Create an initial commit before time-traveling (`git commit --allow-empty` if appropriate).","Check out a branch that has at least one commit.","Verify with `git rev-parse HEAD` (must not error) before invoking the operation."],"exampleFix":"// before (fresh repo)\n$ gix time-travel ...  # unborn HEAD\n// after\n$ git commit --allow-empty -m \"initial\"\n$ gix time-travel ...","handlingStrategy":"validation","validationCode":"let repo = gix::open(repo_path)?;\nlet head = repo.head()?;\nif head.is_unborn() || head.id().is_none() {\n    return Err(anyhow!(\"repository has no commits; create an initial commit first\"));\n}","typeGuard":"fn head_is_born(repo: &gix::Repository) -> bool {\n    repo.head().ok().and_then(|h| h.id()).is_some()\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"cannot time-travel from an unborn HEAD\") => {\n        // create an initial commit, then retry\n    }\n    other => other?,\n}","preventionTips":["Skip time-travel tooling on freshly initialized repositories.","Verify `git rev-parse HEAD` succeeds before invoking.","Avoid orphan branches with zero commits as starting points."],"tags":["git","unborn-head","empty-repository","precondition"],"backgroundTag":"resource-not-found","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}