Skip to content

Commit

Permalink
Remove do_reload
Browse files Browse the repository at this point in the history
With done_store now not doing anything that init_store wouldn't do, we can
just use init_store directly.
  • Loading branch information
glandium committed Nov 26, 2023
1 parent 5ca0e7c commit 3d5ed1a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
18 changes: 2 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CommitId>) {
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<Mutex<HashMap<Box<BStr>, CommitId>>> =
Lazy::new(|| Mutex::new(HashMap::new()));

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
};
Expand Down
4 changes: 2 additions & 2 deletions src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand Down Expand Up @@ -2333,7 +2333,7 @@ pub fn merge_metadata(
}

unsafe {
do_reload(store, Some(metadata_cid));
init_store(store, Some(metadata_cid));
}
true
}
Expand Down

0 comments on commit 3d5ed1a

Please sign in to comment.