{"record":{"id":"09fad30bf77648b5","repo":"GitoxideLabs/gitoxide","slug":"update-head-cannot-be-used-with-in-memory","errorCode":null,"errorMessage":"`--update-head` cannot be used with `--in-memory` - cannot set head to nothing","messagePattern":"`--update-head` cannot be used with `--in-memory` - cannot set head to nothing","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"gitoxide-core/src/repository/merge/tree.rs","lineNumber":48,"sourceCode":"        err: &mut dyn std::io::Write,\n        base: BString,\n        ours: BString,\n        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();","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gitoxide-core/src/repository/merge/tree.rs#L30-L66","documentation":"The `gix repo merge tree` CLI command refuses the combination of `--update-head` and `--in-memory`. `--update-head` moves the current branch ref to the merge result commit, but an in-memory merge produces no persisted commit, so there would be no head to update. The command fails fast with this message before doing any work.","triggerScenarios":"Running `gix repo merge tree` (gitoxide-core repository::merge::tree `tree()`) with both `update_head == true` and `in_memory == true` set in Options.","commonSituations":"Scripting a merge whose result should land on the current branch while also passing `--in-memory` (e.g. copied flags from an earlier dry-run invocation); wrapping the CLI in automation that always enables in-memory mode for speed.","solutions":["Drop `--in-memory` so the merge writes a commit that `--update-head` can point the branch at.","Drop `--update-head` if you only want the computed tree/merge result without moving the branch.","If you need in-memory computation plus a head update, write the commit yourself from the resulting tree id, then update the ref with `gix ref` APIs."],"exampleFix":"// before\ngix repo merge tree --update-head --in-memory <base> <ours> <theirs>\n// after\n# either drop --in-memory\ngix repo merge tree --update-head --message \"merge\" <base> <ours> <theirs>\n# or drop --update-head\ngix repo merge tree --in-memory <base> <ours> <theirs>","handlingStrategy":"validation","validationCode":"if update_head && in_memory {\n    return Err(anyhow::anyhow!(\"--update-head and --in-memory are mutually exclusive\"));\n}","typeGuard":null,"tryCatchPattern":"match run_merge_tree(opts) {\n    Err(e) if e.to_string().contains(\"--update-head`\") => eprintln!(\"pick either --update-head or --in-memory\"),\n    r => r?,\n}","preventionTips":["Validate flag combinations in your CLI wrapper before invoking.","Remember: --update-head requires a persisted commit, --in-memory skips persistence."],"tags":["cli","merge","mutually-exclusive-flags","gitoxide"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}