{"record":{"id":"6ac219e311c4dddc","repo":"gitbutlerapp/gitbutler","slug":"bug-this-must-have-been-deactivated","errorCode":null,"errorMessage":"BUG: this must have been deactivated","messagePattern":"BUG: this must have been deactivated","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-core/src/snapshot/create_tree.rs","lineNumber":239,"sourceCode":"                    ..\n                }\n                | Change::Modification {\n                    location,\n                    entry_mode,\n                    id,\n                    ..\n                } => {\n                    base_tree_edit.upsert(\n                        location.as_bstr(),\n                        entry_mode\n                            .to_tree_entry_mode()\n                            .with_context(|| format!(\"Could not convert the index entry {entry_mode:?} at '{location}' into a tree entry kind\"))?\n                            .kind(),\n                        id.into_owned(),\n                    )?;\n                }\n                Change::Rewrite { .. } => {\n                    unreachable!(\"BUG: this must have been deactivated\")\n                }\n            }\n        }\n\n        let index = base_tree_edit.write()?;\n        let index = (index != base_tree.id).then_some(index.detach());\n        if let Some(index) = index {\n            snapshot_tree.upsert(\"index\", EntryKind::Tree, index)?;\n        }\n\n        let index_conflicts = if conflicts.is_empty() {\n            None\n        } else {\n            let mut root = snapshot_tree.cursor_at(\"index-conflicts\")?;\n            for (rela_path, conflict_entries) in conflicts {\n                for (stage, entry) in conflict_entries\n                    .into_iter()\n                    .enumerate()","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-core/src/snapshot/create_tree.rs#L221-L257","documentation":"When `create_tree` snapshots the index into the snapshot tree (but-core/src/snapshot/create_tree.rs), `Change::Rewrite` from the tree↔index diff is `unreachable!` because that diff is created with rewrite detection deactivated, so the index diff only emits plain modifications/additions/deletions. The panic indicates the diff producing these changes was built with rename/copy rewrites enabled, breaking the snapshot builder's assumption.","triggerScenarios":"Constructing the tree↔index diff with `gix::diff::Rewrites` enabled and passing its changes into the snapshot tree builder; option plumbing changes that share a rewrite-enabled platform with snapshot creation; gix version default changes.","commonSituations":"Reusing one diff platform configured for rename-aware UI across snapshot code; refactors that centralize diff options; dependency upgrades.","solutions":["Create the diff for snapshot tree building with rewrite detection `None`.","Keep rename-aware diffs in a separate platform instance consumed only by display code.","Regression-test snapshot creation after any change to shared diff options."],"exampleFix":"// before\nlet changes = repo.diff_tree_to_index(base_tree, None, gix::diff::tree::Options {\n    rewrites: Some(gix::diff::Rewrites::default()),\n    ..Default::default()\n})?; // Rewrite changes reach create_tree\n\n// after\nlet changes = repo.diff_tree_to_index(base_tree, None, gix::diff::tree::Options {\n    rewrites: None, // snapshot path expects no Rewrite variants\n    ..Default::default()\n})?;","handlingStrategy":"validation","validationCode":"// snapshot tree building requires a rewrite-free tree-to-index diff\nlet changes = repo.diff_tree_to_index(\n    base_tree,\n    None,\n    gix::diff::tree::Options { rewrites: None, ..Default::default() },\n)?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set rewrites to None on every diff whose changes flow into snapshot tree creation.","Keep rename-aware diffs confined to display/UI pipelines.","Re-run snapshot tests whenever diff options are centralized or gix is upgraded."],"tags":["rust","but-core","snapshot","gix","rewrite-detection","internal-invariant"],"backgroundTag":"git-rewrite-detection-enabled","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}