Skip to content

Commit b16d5e9

Browse files
committed
Implement object replacement (#364)
1 parent b052a9a commit b16d5e9

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

git-odb/src/store_impls/dynamic/find.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ where
168168
}
169169
}
170170

171-
fn try_find_cached_inner<'a>(
172-
&self,
173-
id: &git_hash::oid,
171+
fn try_find_cached_inner<'a, 'b>(
172+
&'b self,
173+
mut id: &'b git_hash::oid,
174174
buffer: &'a mut Vec<u8>,
175175
pack_cache: &mut impl DecodeEntry,
176176
snapshot: &mut load_index::Snapshot,
@@ -183,7 +183,16 @@ where
183183
id: r.original_id.to_owned(),
184184
});
185185
}
186+
} else if !self.ignore_replacements {
187+
if let Ok(pos) = self
188+
.store
189+
.replacements
190+
.binary_search_by(|(map_this, _)| map_this.as_ref().cmp(id))
191+
{
192+
id = self.store.replacements[pos].1.as_ref();
193+
}
186194
}
195+
187196
'outer: loop {
188197
{
189198
let marker = snapshot.marker;

git-odb/tests/odb/store/dynamic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ fn write() -> crate::Result {
206206
}
207207

208208
#[test]
209-
#[ignore]
210209
fn object_replacement() {
211210
let dir = git_testtools::scripted_fixture_repo_read_only("make_replaced_history.sh").unwrap();
212211
let handle = git_odb::at(dir.join(".git/objects")).unwrap();

0 commit comments

Comments
 (0)