A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/GitoxideLabs/gitoxide/commit/26ae766b182218151ae4c3f30306b6d41bab358a below:

submodules()` in an unborn repository. · GitoxideLabs/gitoxide@26ae766 · GitHub

File tree Expand file treeCollapse file tree 6 files changed

+33

-15

lines changed

Filter options

Expand file treeCollapse file tree 6 files changed

+33

-15

lines changed Original file line number Diff line number Diff line change

@@ -26,7 +26,7 @@ impl Repository {

26 26

)?))

27 27

}

28 28 29 -

/// Return a shared [`.gitmodules` file](crate::submodule::File) which is updated automatically if the in-memory snapshot

29 +

/// Return a shared [`.gitmodules` file](submodule::File) which is updated automatically if the in-memory snapshot

30 30

/// has become stale as the underlying file on disk has changed. The snapshot based on the file on disk is shared across all

31 31

/// clones of this repository.

32 32

///

@@ -54,12 +54,20 @@ impl Repository {

54 54

}) {

55 55

Some(id) => id,

56 56

None => match self

57 -

.head_commit()?

58 -

.tree()?

59 -

.find_entry(submodule::MODULES_FILE)

60 -

.map(|entry| entry.inner.oid)

57 +

.head()?

58 +

.try_peel_to_id_in_place()?

59 +

.map(|id| -> Result<Option<_>, submodule::modules::Error> {

60 +

Ok(id

61 +

.object()?

62 +

.peel_to_commit()?

63 +

.tree()?

64 +

.find_entry(submodule::MODULES_FILE)

65 +

.map(|entry| entry.inner.oid.to_owned()))

66 +

})

67 +

.transpose()?

68 +

.flatten()

61 69

{

62 -

Some(id) => id.to_owned(),

70 +

Some(id) => id,

63 71

None => return Ok(None),

64 72

},

65 73

};

Original file line number Diff line number Diff line change

@@ -226,13 +226,6 @@ mod submodule_status {

226 226

v

227 227

}

228 228

Ok(None) => Vec::new(),

229 -

Err(crate::submodule::modules::Error::FindHeadCommit(

230 -

crate::reference::head_commit::Error::PeelToCommit(

231 -

crate::head::peel::to_commit::Error::PeelToObject(

232 -

crate::head::peel::to_object::Error::Unborn { .. },

233 -

),

234 -

),

235 -

)) => Vec::new(),

236 229

Err(err) => return Err(err),

237 230

};

238 231

Ok(Self {

Original file line number Diff line number Diff line change

@@ -23,8 +23,12 @@ pub mod modules {

23 23

OpenIndex(#[from] crate::worktree::open_index::Error),

24 24

#[error("Could not find the .gitmodules file by id in the object database")]

25 25

FindExistingBlob(#[from] crate::object::find::existing::Error),

26 -

#[error("Did not find commit in current HEAD to access its tree")]

27 -

FindHeadCommit(#[from] crate::reference::head_commit::Error),

26 +

#[error(transparent)]

27 +

FindHeadRef(#[from] crate::reference::find::existing::Error),

28 +

#[error(transparent)]

29 +

PeelHeadRef(#[from] crate::head::peel::Error),

30 +

#[error(transparent)]

31 +

PeelObjectToCommit(#[from] crate::object::peel::to_kind::Error),

28 32

#[error(transparent)]

29 33

TreeFromCommit(#[from] crate::object::commit::Error),

30 34

}

Original file line number Diff line number Diff line change

@@ -144,3 +144,5 @@ git clone with-submodules not-a-submodule

144 144

mv modules.bak .gitmodules

145 145

git add m1 && git commit -m "no submodule in index and commit, but in configuration"

146 146

)

147 + 148 +

git init unborn

Original file line number Diff line number Diff line change

@@ -340,6 +340,17 @@ mod open {

340 340

Ok(())

341 341

}

342 342 343 +

#[test]

344 +

fn in_unborn() -> crate::Result {

345 +

let repo = repo("unborn")?;

346 +

assert_eq!(

347 +

repo.submodules()?.into_iter().flatten().count(),

348 +

0,

349 +

"there is nothing, and that is fine"

350 +

);

351 +

Ok(())

352 +

}

353 + 343 354

#[test]

344 355

#[cfg(feature = "revision")]

345 356

fn submodule_worktrees() -> crate::Result {

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4