MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / refuse_conflict_markers

Function refuse_conflict_markers

atomic-cli/src/commands/git/shadow.rs:2208–2268  ·  view source on GitHub ↗

`baseline_ref` names the ref the projection commits onto; its tip is the Git state a marker must be new against (HEAD when the ref is absent).

(
    repo: &Repository,
    git_repo: &GitRepository,
    baseline_ref: Option<&str>,
    repo_root: &Path,
    view: &str,
)

Source from the content-addressed store, hash-verified

2206/// `baseline_ref` names the ref the projection commits onto; its tip is the
2207/// Git state a marker must be new against (HEAD when the ref is absent).
2208fn refuse_conflict_markers(
2209 repo: &Repository,
2210 git_repo: &GitRepository,
2211 baseline_ref: Option<&str>,
2212 repo_root: &Path,
2213 view: &str,
2214) -> CliResult<()> {
2215 let working_copy = repo
2216 .require_working_copy_id()
2217 .map_err(CliError::Repository)?;
2218 let marker = repo
2219 .first_working_copy_conflict_marker(working_copy)
2220 .map_err(CliError::Repository)?;
2221 // Review ::26 R5: the status-filtered scan above cannot see a file whose
2222 // RECORDED state carries markers (a record made with
2223 // --allow-conflict-markers leaves the status clean while the view's
2224 // canonical content still holds the markers). The switch/shadow boundary
2225 // therefore ALSO scans the materialized view content: unresolved markers
2226 // must never become Git evidence, whatever their worktree status.
2227 //
2228 // Markers the baseline commit already holds byte-for-byte are not this
2229 // commit's doing (llmlang: a dependabot merge committed `Cargo.lock`
2230 // with its markers; every later `atomic record` of an unrelated file was
2231 // refused here AFTER the record had landed, leaving Git behind Atomic
2232 // for good). Only a file whose projected bytes the baseline does not
2233 // hold can introduce or keep an unresolved marker.
2234 let baseline = baseline_tree(git_repo, baseline_ref);
2235 let marker = marker.or_else(|| {
2236 repo.first_view_conflict_marker_where(working_copy, &|path, content| {
2237 !baseline
2238 .as_ref()
2239 .is_some_and(|tree| tree_holds_bytes(git_repo, tree, path, content))
2240 })
2241 .map_err(CliError::Repository)
2242 .ok()
2243 .flatten()
2244 });
2245 let Some((path, line)) = marker else {
2246 return Ok(());
2247 };
2248 if !std::io::stderr().is_terminal() {
2249 append_shadow_validate_log(
2250 repo_root,
2251 "V1",
2252 view,
2253 &format!("file={} line={}", path, line),
2254 );
2255 }
2256 print_warning(&format!(
2257 "Refusing to commit '{}': unresolved conflict marker at line {}.",
2258 path, line
2259 ));
2260 Err(CliError::GitError {
2261 message: format!(
2262 "'{}' still contains conflict markers at line {} — resolve the conflict \
2263 (remove the >>>>>>> / ======= / <<<<<<< lines), or pass \
2264 --allow-conflict-markers to override. No commit was created.",
2265 path, line

Calls 10

baseline_treeFunction · 0.85
tree_holds_bytesFunction · 0.85
stderrFunction · 0.85
print_warningFunction · 0.85
as_refMethod · 0.80
okMethod · 0.45

Tested by

no test coverage detected