{"record":{"id":"fb09344e266a3d65","repo":"gitbutlerapp/gitbutler","slug":"cannot-use-both-fix-formatting-and-message-flags-together","errorCode":null,"errorMessage":"Cannot use both --fix-formatting and --message flags together","messagePattern":"Cannot use both --fix-formatting and --message flags together","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/reword.rs","lineNumber":279,"sourceCode":"}\n\nfn edit_commit_message_by_id_and_reword_commit(\n    ctx: &mut Context,\n    commit_oid: gix::ObjectId,\n    out: &mut OutputChannel,\n    message: Option<&str>,\n    format: bool,\n    show_diff_in_editor: ShowDiffInEditor,\n    perm: &mut RepoExclusive,\n) -> Result<()> {\n    // Get commit details directly - no need to iterate through stacks\n    let commit_details = but_api::diff::commit_details(ctx, commit_oid, ComputeLineStats::No)?;\n    let current_message = commit_details.commit.inner.message.to_string();\n\n    // Get new message from provided argument, format flag, or editor\n    let new_message = if format {\n        if message.is_some() {\n            bail!(\"Cannot use both --fix-formatting and --message flags together\");\n        }\n        // Format the current message without opening an editor\n        Some(but_action::commit_format::format_commit_message(\n            &current_message,\n        ))\n    } else if let Some(message) = message {\n        Some(normalize_commit_message(message).to_owned())\n    } else {\n        get_commit_message_from_editor(\n            &*ctx.repo.get()?,\n            ctx.settings.context_lines,\n            commit_details,\n            current_message.clone(),\n            &current_message,\n            show_diff_in_editor,\n        )?\n    }\n    .filter(|new_message| should_update_commit_message(&current_message, new_message));","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/reword.rs#L261-L297","documentation":"`edit_commit_message_by_id_and_reword_commit` treats --fix-formatting and --message as mutually exclusive sources for the new commit message: --fix-formatting reformats the existing message while --message supplies a replacement. Supplying both is ambiguous and is rejected.","triggerScenarios":"Running `but reword --fix-formatting --message \"text\"` (reword_target path) with both flags set on the same invocation.","commonSituations":"Script/template that always passes --message but also gained --fix-formatting; user wanting formatting plus tweaks in one call.","solutions":["Drop --message to only reformat the existing message","Drop --fix-formatting to set the message verbatim","Run twice if both are needed: first reword --message, then reword --fix-formatting"],"exampleFix":"// before\nbut reword <commit> --fix-formatting --message \"msg\"\n// after\nbut reword <commit> --fix-formatting","handlingStrategy":"validation","validationCode":"if (args.fixFormatting && args.message)\n  throw new Error('Use either --fix-formatting or --message, not both');","typeGuard":"const flagsAreExclusive = (a, b) => !(a != null && b != null);","tryCatchPattern":null,"preventionTips":["Make flag sets mutually exclusive in CLI argument parsing before execution","In generated commands, pick one message source explicitly","If formatting plus customization is needed, chain two invocations"],"tags":["cli","flags","mutually-exclusive"],"backgroundTag":"mutually-exclusive-flags","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"}