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

Function restore_index_from_head

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

Discard a candidate staging by restoring the git index from HEAD's tree, leaving git byte-identical to its pre-operation state (the working copy is never touched). Best-effort.

(git_repo: &GitRepository)

Source from the content-addressed store, hash-verified

401/// leaving git byte-identical to its pre-operation state (the working copy is
402/// never touched). Best-effort.
403fn restore_index_from_head(git_repo: &GitRepository) {
404 if let Ok(tree) = git_repo
405 .head()
406 .and_then(|h| h.peel_to_commit())
407 .and_then(|c| c.tree())
408 {
409 if let Ok(mut index) = git_repo.index() {
410 let _ = index.read_tree(&tree);
411 let _ = index.write();
412 }
413 }
414}
415
416#[cfg(test)]
417mod tests {

Callers 2

sync_git_head_to_viewFunction · 0.85
stage_and_validate_treeFunction · 0.85

Calls 2

indexMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected