Skip to content

Commit

Permalink
Respect core.multiPackIndex option (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Dec 20, 2021
1 parent b22e146 commit 1495efc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
8 changes: 7 additions & 1 deletion experiments/object-access/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,13 @@ where

let store = match store {
Some(store) => store,
None => OwnShared::new(odb::Store::at_opts(objects_dir, slots)?),
None => OwnShared::new(odb::Store::at_opts(
objects_dir,
git_repository::odb::store::init::Options {
slots,
..Default::default()
},
)?),
};
let handle = Cache::from(store.to_handle()).with_pack_cache(move || Box::new(new_cache()));

Expand Down
4 changes: 2 additions & 2 deletions git-odb/src/store_impls/dynamic/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use crate::store::types::{MutableIndexAndPack, SlotMapIndex};
#[derive(Copy, Clone, Debug)]
pub struct Options {
/// How to obtain a size for the slot map.
slots: Slots,
pub slots: Slots,
/// If true, we are allowed to use multi-pack indices.
use_multi_pack_index: bool,
pub use_multi_pack_index: bool,
}

impl Default for Options {
Expand Down
11 changes: 10 additions & 1 deletion git-repository/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ pub mod open {
worktree_dir = Some(git_dir.parent().expect("parent is always available").to_owned());
}
}
let use_multi_pack_index = config
.value::<Boolean<'_>>("core", None, "multiPackIndex")
.map_or(true, |b| matches!(b, Boolean::True(_)));
let hash_kind = if config
.value::<Integer>("core", None, "repositoryFormatVersion")
.map_or(0, |v| v.value)
Expand All @@ -132,7 +135,13 @@ pub mod open {
};

Ok(crate::Repository {
objects: OwnShared::new(git_odb::Store::at_opts(git_dir.join("objects"), object_store_slots)?),
objects: OwnShared::new(git_odb::Store::at_opts(
git_dir.join("objects"),
git_odb::store::init::Options {
slots: object_store_slots,
use_multi_pack_index,
},
)?),
refs: crate::RefStore::at(
git_dir,
if worktree_dir.is_none() {
Expand Down

0 comments on commit 1495efc

Please sign in to comment.