{"record":{"id":"6c24bd9cadfeec72","repo":"GitoxideLabs/gitoxide","slug":"update-head-requires-message","errorCode":null,"errorMessage":"`--update-head` requires `--message`","messagePattern":"`--update-head` requires `--message`","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"gitoxide-core/src/repository/merge/tree.rs","lineNumber":51,"sourceCode":"        theirs: BString,\n        Options {\n            format,\n            file_favor,\n            tree_favor,\n            in_memory,\n            debug,\n            message,\n            update_head,\n        }: Options,\n    ) -> anyhow::Result<()> {\n        if format != OutputFormat::Human {\n            bail!(\"JSON output isn't implemented yet\");\n        }\n        if update_head && in_memory {\n            bail!(\"`--update-head` cannot be used with `--in-memory` - cannot set head to nothing\");\n        }\n        if update_head && message.is_none() {\n            bail!(\"`--update-head` requires `--message`\");\n        }\n        repo.object_cache_size_if_unset(repo.compute_object_cache_size_for_tree_diffs(&**repo.index_or_empty()?));\n        if in_memory || message.is_some() {\n            repo.objects.enable_object_memory();\n        }\n        let (base_ref, base_id) = refname_and_tree(&repo, base)?;\n        let (ours_ref, ours_id) = refname_and_tree(&repo, ours)?;\n        let (theirs_ref, theirs_id) = refname_and_tree(&repo, theirs)?;\n\n        let options = repo\n            .tree_merge_options()?\n            .with_file_favor(file_favor)\n            .with_tree_favor(tree_favor);\n        let base_id_str = base_id.to_string();\n        let ours_id_str = ours_id.to_string();\n        let theirs_id_str = theirs_id.to_string();\n        let labels = gix::merge::blob::builtin_driver::text::Labels {\n            ancestor: base_ref","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gitoxide-core/src/repository/merge/tree.rs#L33-L69","documentation":"`--update-head` writes a merge commit to the current branch, and git requires commits to carry a message. The command validates up front that a `--message` was supplied whenever `--update-head` is set, and bails otherwise, since it would otherwise have to invent a commit message.","triggerScenarios":"Calling `tree()` in gitoxide-core/src/repository/merge/tree.rs with `update_head == true` while `message` is `None`.","commonSituations":"Automating merges in CI where only the flag combination was copied from a non-committing invocation; forgetting that an in-memory merge and a head-updating merge have different flag requirements.","solutions":["Add `--message \"...\"` to the command when using `--update-head`.","Drop `--update-head` if you don't intend to create a commit on the current branch.","In wrapper code, validate the flag pair before spawning the command to give users a clearer error."],"exampleFix":"// before\ngix repo merge tree --update-head <base> <ours> <theirs>\n// after\ngix repo merge tree --update-head --message \"Merge branch 'feature'\" <base> <ours> <theirs>","handlingStrategy":"validation","validationCode":"if update_head && message.is_none() {\n    return Err(anyhow::anyhow!(\"--update-head requires --message\"));\n}","typeGuard":null,"tryCatchPattern":"match run_merge_tree(opts) {\n    Err(e) if e.to_string().contains(\"requires `--message`\") => eprintln!(\"supply a commit message when using --update-head\"),\n    r => r?,\n}","preventionTips":["Always pair --update-head with --message in scripts.","Use clap's `requires_if`/`requires` attributes to enforce the dependency at arg-parse time."],"tags":["cli","merge","missing-required-flag","gitoxide"],"backgroundTag":"missing-required-flag","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}