{"record":{"id":"857eb25cd15bfbeb","repo":"gitbutlerapp/gitbutler","slug":"no-committed-changes-to-discard","errorCode":null,"errorMessage":"No committed changes to discard","messagePattern":"No committed changes to discard","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/but/src/command/legacy/discard.rs","lineNumber":496,"sourceCode":"                                    .collect::<Vec<but_core::ui::TreeChange>>(),\n                                );\n                            }\n\n                            builder.push_hunks_with_changes(\n                                [hunk.hunk],\n                                tree_changes\n                                    .as_ref()\n                                    .expect(\"tree changes are initialized for committed hunks\"),\n                            )\n                        }\n                    }\n                }\n                builder.into_diff_specs()\n            };\n            let paths: NonEmpty<BString> = NonEmpty::from_vec(paths.into_iter().collect())\n                .context(\"Paths must not be empty\")?;\n\n            anyhow::ensure!(!changes.is_empty(), \"No committed changes to discard\");\n            ExecutableDiscardOperation::CommittedChanges {\n                source,\n                paths,\n                changes,\n            }\n        }\n        DiscardOperation::Uncommitted(selection) => {\n            let changes = {\n                let context_lines = ctx.settings.context_lines;\n                let (repo, ..) = ctx.workspace_and_db_mut_with_perm(perm.read_permission())?;\n                let mut builder = DiffSpecBuilder::new(&repo, context_lines);\n                match selection {\n                    UncommittedSelection::All => builder.push_changes_from_uncommitted_area()?,\n                    UncommittedSelection::Changes(changes) => {\n                        for change in *changes {\n                            match change {\n                                UncommittedDiscardSource::HunkOrFile(change) => {\n                                    builder.push_changes_from_uncommitted(&change)?;","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/discard.rs#L478-L514","documentation":"`but discard` for committed changes collects the diff specs and paths for the selected commits; `NonEmpty::from_vec` for paths and `ensure!(!changes.is_empty())` guard the invariant that there is something to discard. If the computed change set is empty (or the path list is empty), the CLI raises this error rather than executing a no-op transaction.","triggerScenarios":"Selecting committed changes whose diff resolves to an empty change set — e.g. the commit is empty, the specified paths have no differences versus the source, or the requested discard range contains no actual file changes.","commonSituations":"Discarding an already-empty commit; path filters that exclude every change in the commit; re-running a discard that previously succeeded so nothing is left to discard; race where the target commit was rewritten/rebased meanwhile.","solutions":["Run `but` status / `but commit list` and confirm the targeted commit actually has file changes","Drop the empty commit directly (e.g. `but commit drop`) instead of discarding its changes","Remove or broaden path filters so at least one changed path is selected","Re-check the workspace state; if a prior discard already applied, there is nothing left to do"],"exampleFix":"// before: empty commit targeted\nbut discard <id-of-empty-commit>  // Error: No committed changes to discard\n\n// after: pick a commit with real changes, verified via status output\nbut\nbut discard <id-with-changes>","handlingStrategy":"validation","validationCode":"# ensure the chosen commit has file changes before discarding\nbut commit list   # confirm the target id shows changed files\ngit show --stat <commit>","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inspect commit contents before discard","Avoid discarding commits you already emptied","Re-check state after prior discard/absorb operations"],"tags":["cli","discard","empty-input","no-op"],"backgroundTag":"empty-required-field","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"}