Write an empty commit (no file changes).
(
&self,
repo: &mut Repository,
parsed: &ParsedCommit,
header: ChangeHeader,
)
| 3515 | |
| 3516 | /// Write an empty commit (no file changes). |
| 3517 | fn write_empty_commit( |
| 3518 | &self, |
| 3519 | repo: &mut Repository, |
| 3520 | parsed: &ParsedCommit, |
| 3521 | header: ChangeHeader, |
| 3522 | ) -> CliResult<ImportedCommitInfo> { |
| 3523 | let commit_start = Instant::now(); |
| 3524 | let metadata = self.build_git_metadata(parsed, true, false); |
| 3525 | let write_outcome = repo |
| 3526 | .write_import_recorded( |
| 3527 | header, |
| 3528 | &[], |
| 3529 | metadata, |
| 3530 | &[], |
| 3531 | self.options.preserve_working_copy, |
| 3532 | Default::default(), |
| 3533 | ) |
| 3534 | .map_err(|e| CliError::Internal(e.into()))?; |
| 3535 | // Index git SHA → Atomic change in GIT_SHA_INDEX |
| 3536 | let _ = repo.index_git_sha(&parsed.git_sha, &write_outcome.hash); |
| 3537 | |
| 3538 | trace_git_import(format!( |
| 3539 | "write {} files=0 recorded=0 add_batch=0ms record=0ms assemble={}ms save={}ms apply={}ms direct_graph={}ms direct_crdt={}ms commit={}ms cleanup=0ms total={}ms empty_commit=true", |
| 3540 | parsed.short_sha, |
| 3541 | write_outcome.timings.assemble_ms, |
| 3542 | write_outcome.timings.save_ms, |
| 3543 | write_outcome.timings.apply_ms, |
| 3544 | write_outcome.timings.direct_graph_ms, |
| 3545 | write_outcome.timings.direct_crdt_ms, |
| 3546 | write_outcome.timings.commit_ms, |
| 3547 | commit_start.elapsed().as_millis() |
| 3548 | )); |
| 3549 | |
| 3550 | Ok(ImportedCommitInfo { |
| 3551 | git_sha: parsed.git_sha.clone(), |
| 3552 | short_sha: parsed.short_sha.clone(), |
| 3553 | atomic_hash: write_outcome.hash, |
| 3554 | is_merge: parsed.is_merge, |
| 3555 | message: parsed.full_message(), |
| 3556 | squash_insert: None, |
| 3557 | }) |
| 3558 | } |
| 3559 | |
| 3560 | /// Build git metadata for the change's unhashed field. |
| 3561 | fn build_git_metadata( |
no test coverage detected