| From 5897ddaf158b588983cd49ed3e71dedaedfccb7b Mon Sep 17 00:00:00 2001 |
| From: Matthew Maurer <mmaurer@google.com> |
| Date: Wed, 23 Sep 2020 17:58:47 -0700 |
| Subject: [PATCH] Gracefully fall back when workdir not present. |
| |
| Bug: 169246218 |
| Change-Id: Id67e207f131613d14fd583a9c4d33c596596c481 |
| --- |
| src/tools/cargo/src/cargo/sources/path.rs | 12 ++++++------ |
| 1 file changed, 6 insertions(+), 6 deletions(-) |
| |
| diff --git a/src/tools/cargo/src/cargo/sources/path.rs b/src/tools/cargo/src/cargo/sources/path.rs |
| index cf406e8ddb..bdefd6b70b 100644 |
| --- a/src/tools/cargo/src/cargo/sources/path.rs |
| +++ b/src/tools/cargo/src/cargo/sources/path.rs |
| @@ -191,12 +191,12 @@ impl<'cfg> PathSource<'cfg> { |
| let index = repo |
| .index() |
| .chain_err(|| format!("failed to open git index at {}", repo.path().display()))?; |
| - let repo_root = repo.workdir().ok_or_else(|| { |
| - anyhow::format_err!( |
| - "did not expect repo at {} to be bare", |
| - repo.path().display() |
| - ) |
| - })?; |
| + |
| + let repo_root = match repo.workdir() { |
| + Some(workdir) => workdir, |
| + _ => return Ok(None) |
| + }; |
| + |
| let repo_relative_path = match paths::strip_prefix_canonical(root, repo_root) { |
| Ok(p) => p, |
| Err(e) => { |
| -- |
| 2.28.0.681.g6f77f65b4e-goog |
| |