Skip to content

Commit c96f26b

Browse files
committed
make sure that submodule hashes aren't attached as the parent repo is the wrong one here.
1 parent e0d9b09 commit c96f26b

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

gix/src/submodule/mod.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::{
1010
use gix_odb::FindExt;
1111
pub use gix_submodule::*;
1212

13-
use crate::{bstr::BStr, ext::ObjectIdExt, repository::IndexPersistedOrInMemory, Id, Repository, Submodule};
13+
use crate::{bstr::BStr, repository::IndexPersistedOrInMemory, Repository, Submodule};
1414

1515
pub(crate) type ModulesFileStorage = gix_features::threading::OwnShared<gix_fs::SharedFileSnapshotMut<File>>;
1616
/// A lazily loaded and auto-updated worktree index.
@@ -164,29 +164,25 @@ impl<'repo> Submodule<'repo> {
164164
/// If `None`, but `Some()` when calling [`Self::head_id()`], then the submodule was just deleted but the change
165165
/// wasn't yet committed.
166166
/// If `Some()`, but `None` when calling [`Self::head_id()`], then the submodule was just added without having committed the change.
167-
pub fn index_id(&self) -> Result<Option<Id<'repo>>, index_id::Error> {
167+
pub fn index_id(&self) -> Result<Option<gix_hash::ObjectId>, index_id::Error> {
168168
let path = self.path()?;
169-
Ok(self
170-
.state
171-
.index()?
172-
.entry_by_path(&path)
173-
.map(|entry| entry.id.attach(self.state.repo)))
169+
Ok(self.state.index()?.entry_by_path(&path).map(|entry| entry.id))
174170
}
175171

176172
/// Return the object id of the submodule as stored in `HEAD^{tree}` of the superproject, or `None` if it wasn't yet committed.
177173
///
178174
/// If `Some()`, but `None` when calling [`Self::index_id()`], then the submodule was just deleted but the change
179175
/// wasn't yet committed.
180176
/// If `None`, but `Some()` when calling [`Self::index_id()`], then the submodule was just added without having committed the change.
181-
pub fn head_id(&self) -> Result<Option<Id<'repo>>, head_id::Error> {
177+
pub fn head_id(&self) -> Result<Option<gix_hash::ObjectId>, head_id::Error> {
182178
let path = self.path()?;
183179
Ok(self
184180
.state
185181
.repo
186182
.head_commit()?
187183
.tree()?
188184
.peel_to_entry_by_path(gix_path::from_bstr(path.as_ref()))?
189-
.map(|entry| entry.id()))
185+
.map(|entry| entry.inner.oid))
190186
}
191187

192188
/// Return the path at which the repository of the submodule should be located.

gix/tests/repository/submodule.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ mod modules_file {
5858
}
5959

6060
mod submodules {
61-
use gix::{bstr::BString, Id};
61+
use gix::bstr::BString;
6262

6363
use crate::{submodule::repo, util::hex_to_id};
6464

@@ -72,8 +72,8 @@ mod submodules {
7272
.map(|sm| (
7373
sm.name().to_owned(),
7474
sm.path().expect("valid path").into_owned(),
75-
sm.head_id().expect("valid").map(Id::detach),
76-
sm.index_id().expect("valid").map(Id::detach),
75+
sm.head_id().expect("valid"),
76+
sm.index_id().expect("valid"),
7777
sm.is_active().expect("no config error")
7878
))
7979
.collect::<Vec<_>>(),

0 commit comments

Comments
 (0)