From b35086d4c9f50918864899aef76b310f750ebe8c Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 17 Nov 2021 10:05:25 -0800 Subject: [PATCH] repo: use local variable for `WorkingCopy` in `Repo::init()` No need to pass it into `Repo` and then get it back from there. --- lib/src/repo.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/src/repo.rs b/lib/src/repo.rs index d2d80242f..b740e0c8d 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -188,7 +188,7 @@ impl ReadonlyRepo { ) -> Arc { let repo_settings = user_settings.with_repo(&repo_path).unwrap(); - let working_copy = WorkingCopy::init( + let mut working_copy = WorkingCopy::init( store.clone(), wc_path.clone(), repo_path.join("working_copy"), @@ -222,7 +222,11 @@ impl ReadonlyRepo { let view = View::new(root_view); - let repo = ReadonlyRepo { + working_copy + .check_out(checkout_commit) + .expect("failed to check out root commit"); + + Arc::new(ReadonlyRepo { repo_path, wc_path, store, @@ -234,13 +238,7 @@ impl ReadonlyRepo { index: Mutex::new(None), working_copy: Arc::new(Mutex::new(working_copy)), view, - }; - let repo = Arc::new(repo); - - repo.working_copy_locked() - .check_out(checkout_commit) - .expect("failed to check out root commit"); - repo + }) } pub fn load(