{"record":{"id":"47aeca1e9b45aa28","repo":"gitbutlerapp/gitbutler","slug":"path-has-total-hunks-conflicts-content-applies-to-one-at-a","errorCode":null,"errorMessage":"\"{path}\" has {total_hunks} conflicts; content applies to one at a time, use \"{path}:<N>\".","messagePattern":"\"(.+?)\" has (.+?) conflicts; content applies to one at a time, use \"(.+?):<N>\"\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/resolve.rs","lineNumber":963,"sourceCode":"                .find(|file| but_api::resolve::normalize_path(&file.path) == lookup)\n            {\n                bail!(\n                    \"\\\"{path}\\\" cannot be resolved this way: {} Resolve this commit in edit mode instead.\",\n                    manual.reason\n                );\n            }\n            let total_hunks = conflicts\n                .files\n                .iter()\n                .find(|conflicted| but_api::resolve::normalize_path(&conflicted.path) == lookup)\n                .map(|conflicted| conflicted.hunks.len())\n                .with_context(|| format!(\"\\\"{path}\\\" is not a conflicted file of this commit\"))?;\n            match &resolution {\n                HunkResolution::Ours | HunkResolution::Theirs | HunkResolution::Ai => {\n                    (1..=total_hunks).collect()\n                }\n                HunkResolution::Content(_) if total_hunks == 1 => vec![1],\n                HunkResolution::Content(_) => bail!(\n                    \"\\\"{path}\\\" has {total_hunks} conflicts; content applies to one at a time, use \\\"{path}:<N>\\\".\"\n                ),\n            }\n        }\n    };\n    let specs = hunks\n        .into_iter()\n        .map(|hunk| ResolutionSpec {\n            path: path.to_owned(),\n            hunk,\n            resolution: resolution.clone(),\n        })\n        .collect();\n\n    let result = but_api::resolve::resolve_commit_conflict_hunks(ctx, commit_oid, specs)?;\n\n    if let Some(human_out) = out.for_human() {\n        let repo = ctx.repo.get()?;","sourceCodeStart":945,"sourceCodeEnd":981,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/resolve.rs#L945-L981","documentation":"When applying a content-based resolution (`<path>:<content>`) to a conflicted file that has more than one conflict hunk, the command refuses: whole-file content only applies unambiguously when there is exactly one hunk. It directs the user to target a specific hunk with `<path>:<N>`. Ours/theirs/Ai resolutions are exempt because they can be applied to every hunk.","triggerScenarios":"`but resolve <commit> <path>:<content>` (or via the API HunkResolution::Content) where conflicts.files lookup shows total_hunks > 1.","commonSituations":"Pasting resolved file content for a file with several conflict markers; script that assumes a single conflict block per file.","solutions":["Target a single hunk: `but resolve <commit> \"<path>:2\":<content>`","Repeat per hunk, or resolve each hunk with ours/theirs","Resolve in edit mode if per-hunk CLI targeting is impractical"],"exampleFix":"// before\nbut resolve <commit-id> \"src/main.rs\":'resolved full file content'\n// error: \"src/main.rs\" has 3 conflicts; content applies to one at a time, use \"src/main.rs\":<N>\n// after\nbut resolve <commit-id> \"src/main.rs:1\":'content for hunk 1'\nbut resolve <commit-id> \"src/main.rs:2\":'content for hunk 2'","handlingStrategy":"validation","validationCode":"const file = conflicts.files.find(f => normalizePath(f.path) === lookupPath);\nconst hunkCount = file ? file.hunks.length : 0;\nif (resolution.kind === 'content' && hunkCount > 1)\n  throw new Error(`Use \"${path}:<N>\" per hunk (${hunkCount} hunks)`);","typeGuard":"const canApplyWholeContent = (path, conflicts) => {\n  const f = conflicts.files.find(f => normalize(f.path) === normalize(path));\n  return f != null && f.hunks.length === 1;\n};","tryCatchPattern":null,"preventionTips":["Query hunk count per conflicted file before choosing resolution kind","For multi-hunk files, always emit per-hunk targets `<path>:<N>` in scripts","Prefer ours/theirs for blanket resolutions across all hunks"],"tags":["cli","conflict-resolution","hunks"],"backgroundTag":"invalid-argument-value","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"}