gitbutlerapp/gitbutler · error
Cannot use both --fix-formatting and --message flags…
Error message
Cannot use both --fix-formatting and --message flags together
What it means
`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.
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
Example fix
// before but reword <commit> --fix-formatting --message "msg" // after but reword <commit> --fix-formatting
Defensive patterns
Strategy: validation
Validate before calling
if (args.fixFormatting && args.message)
throw new Error('Use either --fix-formatting or --message, not both'); Type guard
const flagsAreExclusive = (a, b) => !(a != null && b != null);
Prevention
- 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
When it happens
Trigger: Running `but reword --fix-formatting --message "text"` (reword_target path) with both flags set on the same invocation.
Common situations: Script/template that always passes --message but also gained --fix-formatting; user wanting formatting plus tweaks in one call.
Understand the failure class
Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.
Related errors
- Cannot pass both --local and --global
- --ai cannot be combined with a resolve subcommand. For one…
- Cannot use both --detect and --path options together
- Conflicted uncommitted files can only be marked as…
- Gerrit push flags (--wip, --ready, --hashtag/--tag…
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/fb09344e266a3d65.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/reword.rs:279
}
fn edit_commit_message_by_id_and_reword_commit(
ctx: &mut Context,
commit_oid: gix::ObjectId,
out: &mut OutputChannel,
message: Option<&str>,
format: bool,
show_diff_in_editor: ShowDiffInEditor,
perm: &mut RepoExclusive,
) -> Result<()> {
// Get commit details directly - no need to iterate through stacks
let commit_details = but_api::diff::commit_details(ctx, commit_oid, ComputeLineStats::No)?;
let current_message = commit_details.commit.inner.message.to_string();
// Get new message from provided argument, format flag, or editor
let new_message = if format {
if message.is_some() {
bail!("Cannot use both --fix-formatting and --message flags together");
}
// Format the current message without opening an editor
Some(but_action::commit_format::format_commit_message(
¤t_message,
))
} else if let Some(message) = message {
Some(normalize_commit_message(message).to_owned())
} else {
get_commit_message_from_editor(
&*ctx.repo.get()?,
ctx.settings.context_lines,
commit_details,
current_message.clone(),
¤t_message,
show_diff_in_editor,
)?
}
.filter(|new_message| should_update_commit_message(¤t_message, new_message));View on GitHub (pinned to 58e5313667)