From 3d5ed1aaad88ef057c9807d4ac28472e9fec6a53 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Sun, 26 Nov 2023 20:34:54 +0900 Subject: [PATCH] Remove do_reload With done_store now not doing anything that init_store wouldn't do, we can just use init_store directly. --- src/main.rs | 18 ++---------------- src/store.rs | 4 ++-- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index 731271ade..2157da3b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -181,20 +181,6 @@ extern "C" { fn init_cinnabar(argv0: *const c_char) -> c_int; } -pub unsafe fn do_reload(store: &mut Store, metadata: Option) { - let mut c = None; - done_store(store); - - if let Some(metadata) = metadata { - if !metadata.is_null() { - c = Some(metadata); - } - } else { - c = get_oid_committish(METADATA_REF.as_bytes()); - } - init_store(store, c); -} - static REF_UPDATES: Lazy, CommitId>>> = Lazy::new(|| Mutex::new(HashMap::new())); @@ -260,7 +246,7 @@ fn do_done_and_check(store: &mut Store, args: &[&[u8]]) -> bool { .unwrap(); transaction.commit().unwrap(); } - do_reload(store, None); + init_store(store, Some(new_metadata)); } do_check_files(store) } @@ -920,7 +906,7 @@ fn do_reclone(store: &mut Store, rebase: bool) -> Result<(), String> { let current_metadata_oid = unsafe { let current_metadata_oid = store.metadata_cid; - do_reload(store, Some(CommitId::NULL)); + init_store(store, None); store.metadata_cid = current_metadata_oid; current_metadata_oid }; diff --git a/src/store.rs b/src/store.rs index 5340ebee4..303c56218 100644 --- a/src/store.rs +++ b/src/store.rs @@ -55,7 +55,7 @@ use crate::util::{ Transpose, }; use crate::xdiff::{apply, textdiff, PatchInfo}; -use crate::{check_enabled, do_reload, Checks}; +use crate::{check_enabled, Checks}; pub const REFS_PREFIX: &str = "refs/cinnabar/"; pub const REPLACE_REFS_PREFIX: &str = "refs/cinnabar/replace/"; @@ -2333,7 +2333,7 @@ pub fn merge_metadata( } unsafe { - do_reload(store, Some(metadata_cid)); + init_store(store, Some(metadata_cid)); } true }