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
19 let mut out = Vec::new();19 let mut out = Vec::new();
20 let mut seen = Vec::new();20 let mut seen = Vec::new();
21 while let Some((depth, dir)) = dirs.pop() {21 while let Some((depth, dir)) = dirs.pop() {
22 if seen.contains(&dir) {
23 return Err(Error::Cycle(seen));
24 }
25 seen.push(dir.clone());
26 match fs::read(dir.join("info").join("alternates")) {22 match fs::read(dir.join("info").join("alternates")) {
27 Ok(content) => {23 Ok(content) => {
24 if seen.contains(&dir) {
25 continue;
26 }
27 seen.push(dir.clone());
28 dirs.push((28 dirs.push((
29 depth + 1,29 depth + 1,
30 content30 content
@@ -44,5 +44,9 @@ pub fn resolve(objects_directory: impl Into<PathBuf>) -> Result<Vec<compound::Db · 13 unmodified lines
44 Err(err) => return Err(err.into()),44 Err(err) => return Err(err.into()),
45 };45 };
46 }46 }
47
48 if out.is_empty() && !seen.is_empty() {
49 return Err(Error::Cycle(seen));
50 }
47 Ok(out)51 Ok(out)
48}52}