History

Ignore all cycles and be happy if we have found at least one actual odb

I think this will make the implementation more user friendly, while seeding out cycles that lead to nothing usable.

Sebastian Thiel committed 6 years ago

Commit 1effdfd1 parent 08f9ec41 file · +8 −4Browse files

Unified · Split

git-odb/src/alternate.rs+8−4
@@ -19,12 +19,12 @@ pub fn resolve(objects_directory: impl Into<PathBuf>) -> Result<Vec<compound::Db · 18 unmodified lines
1919 let mut out = Vec::new();
2020 let mut seen = Vec::new();
2121 while let Some((depth, dir)) = dirs.pop() {
22− if seen.contains(&dir) {
23− return Err(Error::Cycle(seen));
24− }
25− seen.push(dir.clone());
2622 match fs::read(dir.join("info").join("alternates")) {
2723 Ok(content) => {
24+ if seen.contains(&dir) {
25+ continue;
26+ }
27+ seen.push(dir.clone());
2828 dirs.push((
2929 depth + 1,
3030 content
@@ -44,5 +44,9 @@ pub fn resolve(objects_directory: impl Into<PathBuf>) -> Result<Vec<compound::Db · 13 unmodified lines
4444 Err(err) => return Err(err.into()),
4545 };
4646 }
47+
48+ if out.is_empty() && !seen.is_empty() {
49+ return Err(Error::Cycle(seen));
50+ }
4751 Ok(out)
4852 }