GitoxideLabs/gitoxide · error · anyhow::Error
`--update-head` cannot be used with `--in-memory` - cannot…
Error message
`--update-head` cannot be used with `--in-memory` - cannot set head to nothing
What it means
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.
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.
Example fix
// before gix repo merge tree --update-head --in-memory <base> <ours> <theirs> // after # either drop --in-memory gix repo merge tree --update-head --message "merge" <base> <ours> <theirs> # or drop --update-head gix repo merge tree --in-memory <base> <ours> <theirs>
Defensive patterns
Strategy: validation
Validate before calling
if update_head && in_memory {
return Err(anyhow::anyhow!("--update-head and --in-memory are mutually exclusive"));
} Try / catch
match run_merge_tree(opts) {
Err(e) if e.to_string().contains("--update-head`") => eprintln!("pick either --update-head or --in-memory"),
r => r?,
} Prevention
- Validate flag combinations in your CLI wrapper before invoking.
- Remember: --update-head requires a persisted commit, --in-memory skips persistence.
When it happens
Trigger: Running `gix repo merge tree` (gitoxide-core repository::merge::tree `tree()`) with both `update_head == true` and `in_memory == true` set in Options.
Common situations: 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.
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
- `--update-head` requires `--message`
- Tree conflicted, refusing to write commit
- Tree conflicted
- Only 'human' format is currently supported
- extra-header-lookup is only meaningful in threaded mode
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/09fad30bf77648b5.
Report an issue: GitHub.
Appendix: source
Thrown at gitoxide-core/src/repository/merge/tree.rs:48
err: &mut dyn std::io::Write,
base: BString,
ours: BString,
theirs: BString,
Options {
format,
file_favor,
tree_favor,
in_memory,
debug,
message,
update_head,
}: Options,
) -> anyhow::Result<()> {
if format != OutputFormat::Human {
bail!("JSON output isn't implemented yet");
}
if update_head && in_memory {
bail!("`--update-head` cannot be used with `--in-memory` - cannot set head to nothing");
}
if update_head && message.is_none() {
bail!("`--update-head` requires `--message`");
}
repo.object_cache_size_if_unset(repo.compute_object_cache_size_for_tree_diffs(&**repo.index_or_empty()?));
if in_memory || message.is_some() {
repo.objects.enable_object_memory();
}
let (base_ref, base_id) = refname_and_tree(&repo, base)?;
let (ours_ref, ours_id) = refname_and_tree(&repo, ours)?;
let (theirs_ref, theirs_id) = refname_and_tree(&repo, theirs)?;
let options = repo
.tree_merge_options()?
.with_file_favor(file_favor)
.with_tree_favor(tree_favor);
let base_id_str = base_id.to_string();
let ours_id_str = ours_id.to_string();View on GitHub (pinned to e73179060b)