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

Method write_commit

atomic-cli/src/commands/git/parallel.rs:5673–5780  ·  view source on GitHub ↗
(
        &self,
        repo: &mut Repository,
        git: &GitRepository,
        ledger: &mut ClosureLedger,
        parsed: &ParsedCommit,
        _line_index: &mut ImportLineIndex,
        verif

Source from the content-addressed store, hash-verified

5671 /// classification and ReviewGate tagging.
5672 #[allow(clippy::too_many_arguments)]
5673 fn write_commit(
5674 &self,
5675 repo: &mut Repository,
5676 git: &GitRepository,
5677 ledger: &mut ClosureLedger,
5678 parsed: &ParsedCommit,
5679 _line_index: &mut ImportLineIndex,
5680 verified: &VerifiedProspectiveEquivalence,
5681 prospective: &atomic_repository::ProjectTree,
5682 boundaries: &[&'static str],
5683 touched_only: bool,
5684 ) -> CliResult<ImportedCommitInfo> {
5685 #[cfg(test)]
5686 stream::assert_ordinary_recorder_allowed();
5687 // CB-9B F1-adjacent sibling import: a Git commit already interpreted
5688 // locally (same full SHA) has exactly one Atomic change. Re-synthesizing
5689 // it in a second branch view allocates a second incarnation with new
5690 // graph inodes, and the two claimants then surface as an unresolved name
5691 // conflict for the edited paths (`git import --all` over sibling
5692 // branches sharing a base). Reference the existing change into the
5693 // target view instead: metadata-only, dependency-closed, and the exact
5694 // same interpretation every view sees.
5695 if let Some(existing) = repo
5696 .checked_git_sha(&parsed.git_sha)
5697 .map_err(|e| CliError::Internal(e.into()))?
5698 {
5699 repo.ensure_union_state(&self.options.target_view, &[existing])
5700 .map_err(|e| CliError::Internal(e.into()))?;
5701 ledger.record_introduced(&parsed.git_sha, existing, &self.options.target_view);
5702 trace_git_import(format!(
5703 "write {} reuse existing change {} (commit already interpreted locally; \
5704 referenced into view '{}')",
5705 parsed.short_sha,
5706 existing.to_base32(),
5707 self.options.target_view
5708 ));
5709 return Ok(ImportedCommitInfo {
5710 git_sha: parsed.git_sha.clone(),
5711 short_sha: parsed.short_sha.clone(),
5712 atomic_hash: existing,
5713 is_merge: parsed.is_merge,
5714 message: parsed.full_message(),
5715 squash_insert: None,
5716 });
5717 }
5718 // All-parent traversal can visit another leg between a commit and
5719 // its child. Synthesis aligns the view to that leg, so exclusions
5720 // alone cannot recover the next parent's missing membership. Restore
5721 // its canonical closure by reference before resolving file identities;
5722 // never reinterpret an already stored file as a fresh FileAdd.
5723 if !self.options.mainline_only && parsed.parent_oids.len() == 1 {
5724 let parent_sha = parsed.parent_oids[0].to_string();
5725 let closure = ledger.interpreted_closure(repo, git, &parent_sha)?;
5726 if closure.is_empty() {
5727 return Err(git_error(format!(
5728 "commit {} parent {} has no interpreted closure",
5729 parsed.git_sha, parent_sha
5730 )));

Callers 2

phase2_writeMethod · 0.80

Calls 15

trace_git_importFunction · 0.85
checked_git_shaMethod · 0.80
ensure_union_stateMethod · 0.80
record_introducedMethod · 0.80
full_messageMethod · 0.80
interpreted_closureMethod · 0.80
sortMethod · 0.80
git_errorFunction · 0.70

Tested by

no test coverage detected