{"record":{"id":"c18454ffe11e5775","repo":"gitbutlerapp/gitbutler","slug":"diff-and-no-diff-flags-can-only-be-used-with-c","errorCode":null,"errorMessage":"--diff and --no-diff flags can only be used with commits, not branches","messagePattern":"--diff and --no-diff flags can only be used with commits, not branches","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/reword.rs","lineNumber":55,"sourceCode":"\n    let mut guard = ctx.exclusive_worktree_access();\n    let id_map = IdMap::new_from_context(ctx, guard.read_permission())?;\n\n    let target = {\n        let repo = ctx.repo.get()?;\n        target.resolve_in_workspace(&repo, &id_map, Purpose::Target, None)?\n    };\n\n    match target.into_branch_or_commit()? {\n        BranchOrCommit::Branch(BranchArg(name)) => {\n            if format {\n                return Err(anyhow::anyhow!(\n                    \"--fix-formatting flag can only be used with commits, not branches\"\n                )\n                .into());\n            }\n            if !matches!(show_diff_in_editor, ShowDiffInEditor::Unspecified) {\n                return Err(anyhow::anyhow!(\n                    \"--diff and --no-diff flags can only be used with commits, not branches\"\n                )\n                .into());\n            }\n            edit_branch_name(ctx, &name, out, message, guard.write_permission())?;\n        }\n        BranchOrCommit::Commit(commit) => {\n            // Rewording a landed commit is lost work: the rewritten commit is\n            // dropped again on the next `but pull`.\n            MergedUpstream::from_ctx(ctx, allow_merged)?\n                .ensure_commit_not_merged(commit.commit_id)?;\n            edit_commit_message_by_id_and_reword_commit(\n                ctx,\n                commit.commit_id,\n                out,\n                message,\n                format,\n                show_diff_in_editor,","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/reword.rs#L37-L73","documentation":"Same branch/commit split in `but reword`: `--diff`/`--no-diff` control whether the editor shows the commit diff while rewording, which only applies to commits. Any explicit `ShowDiffInEditor` value other than Unspecified is rejected on the branch arm.","triggerScenarios":"Running `but reword --diff <branch>` or `but reword --no-diff <branch>`; the branch arm checks the diff preference and bails.","commonSituations":"Aliases that always pass --no-diff; scripts shared between commit and branch rewords without branching on target kind.","solutions":["Drop the flag when rewording a branch","Or reword a commit: `but reword --diff <sha>`","Adjust aliases so diff flags are added only for commit targets"],"exampleFix":"# before\nbut reword --diff my-branch\n# error: --diff and --no-diff flags can only be used with commits, not branches\n\n# after\nbut reword my-branch        # no diff flags on branches\nbut reword --diff 4a2f9c1   # diff display applies to commits","handlingStrategy":"validation","validationCode":"# Only add diff flags for commit-looking targets\ncase \"$target\" in\n  *[0-9a-f][0-9a-f][0-9a-f]*) but reword --diff \"$target\" ;;  # commit sha\n  *)                            but reword \"$target\" ;;        # branch\nesac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Leave --diff/--no-diff out of branch rename invocations","Scope always-on diff aliases to commit rewords only","When a reword fails on flag/target mismatch, re-check the target kind first"],"tags":["reword","flag-combination","usage","commit-vs-branch"],"backgroundTag":"invalid-flag-combination","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}