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

Function reindex_working_copy

atomic-cli/src/commands/git/import.rs:895–925  ·  view source on GitHub ↗

Rebuild FILE_INDEX from the current working copy. During normal single-branch Git import the files on disk are already the authoritative Git checkout for the imported branch, so there is no reason to materialize the same content back out of Atomic. Indexing the tracked files makes the post-import `atomic status` baseline clean.

(repo: &Repository)

Source from the content-addressed store, hash-verified

893/// to materialize the same content back out of Atomic. Indexing the tracked
894/// files makes the post-import `atomic status` baseline clean.
895fn reindex_working_copy(repo: &Repository) {
896 use atomic_core::types::Hash;
897 use std::time::SystemTime;
898
899 let repo_root = repo.root().to_path_buf();
900 let tracked = repo.list_tracked_files().unwrap_or_default();
901 let mut entries: Vec<(String, i64, u32, u64, Hash)> = Vec::new();
902
903 for file in &tracked {
904 let abs = repo_root.join(&file.path);
905 if let Ok(metadata) = std::fs::metadata(&abs) {
906 let mtime = metadata.modified().unwrap_or(SystemTime::UNIX_EPOCH);
907 let duration = mtime
908 .duration_since(SystemTime::UNIX_EPOCH)
909 .unwrap_or_default();
910 if let Ok(bytes) = std::fs::read(&abs) {
911 entries.push((
912 file.path.to_string_lossy().replace('\\', "/"),
913 duration.as_secs() as i64,
914 duration.subsec_nanos(),
915 metadata.len(),
916 Hash::of(&bytes),
917 ));
918 }
919 }
920 }
921
922 if !entries.is_empty() {
923 let _ = repo.update_file_index(&entries);
924 }
925}
926
927/// Create .atomicignore and initialize vault AFTER git import + materialize.
928///

Callers 1

runMethod · 0.85

Calls 8

list_tracked_filesMethod · 0.80
rootMethod · 0.45
modifiedMethod · 0.45
pushMethod · 0.45
replaceMethod · 0.45
lenMethod · 0.45
is_emptyMethod · 0.45
update_file_indexMethod · 0.45

Tested by

no test coverage detected