Skip to content

Commit

Permalink
mention that failing path when a ref-file couldn't be read (#298)
Browse files Browse the repository at this point in the history
This should help debugging a GNU toolchain problem on windows.
  • Loading branch information
Byron committed Apr 6, 2022
1 parent f041c00 commit ecb539a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
12 changes: 8 additions & 4 deletions git-ref/src/store/file/find.rs
Expand Up @@ -124,7 +124,12 @@ impl file::Store {
};
let relative_path = base.join(inbetween).join(relative_path);

let contents = match self.ref_contents(&relative_path)? {
let contents = match self
.ref_contents(&relative_path)
.map_err(|err| Error::ReadFileContents {
err,
path: relative_path.to_owned(),
})? {
None => {
if is_definitely_absolute {
if let Some(packed) = packed {
Expand Down Expand Up @@ -302,9 +307,8 @@ mod error {
from()
source(err)
}
ReadFileContents(err: io::Error) {
display("The ref file could not be read in full")
from()
ReadFileContents{err: io::Error, path: PathBuf} {
display("The ref file '{}' could not be read in full", path.display())
source(err)
}
ReferenceCreation{ err: file::loose::reference::decode::Error, relative_path: PathBuf } {
Expand Down
9 changes: 6 additions & 3 deletions git-ref/src/store/file/loose/iter.rs
Expand Up @@ -128,7 +128,10 @@ impl Iterator for Loose {
self.buf.clear();
f.read_to_end(&mut self.buf)
})
.map_err(loose::Error::ReadFileContents)
.map_err(|err| loose::Error::ReadFileContents {
err,
path: validated_path.to_owned(),
})
.and_then(|_| {
let relative_path = validated_path
.strip_prefix(&self.ref_paths.base)
Expand Down Expand Up @@ -234,8 +237,8 @@ pub mod loose {
display("The file system could not be traversed")
source(err)
}
ReadFileContents(err: io::Error) {
display("The ref file could not be read in full")
ReadFileContents{err: io::Error, path: PathBuf} {
display("The ref file '{}' could not be read in full", path.display())
source(err)
}
ReferenceCreation{ err: file::loose::reference::decode::Error, relative_path: PathBuf } {
Expand Down
9 changes: 6 additions & 3 deletions git-ref/src/store/file/overlay_iter.rs
Expand Up @@ -64,7 +64,10 @@ impl<'p, 's> LooseThenPacked<'p, 's> {
self.buf.clear();
f.read_to_end(&mut self.buf)
})
.map_err(Error::ReadFileContents)?;
.map_err(|err| Error::ReadFileContents {
err,
path: refpath.to_owned(),
})?;
loose::Reference::try_from_path(name, &self.buf)
.map_err(|err| Error::ReferenceCreation {
err,
Expand Down Expand Up @@ -245,8 +248,8 @@ mod error {
display("The file system could not be traversed")
source(err)
}
ReadFileContents(err: io::Error) {
display("The ref file could not be read in full")
ReadFileContents{err: io::Error, path: PathBuf} {
display("The ref file '{}' could not be read in full", path.display())
source(err)
}
ReferenceCreation{ err: file::loose::reference::decode::Error, relative_path: PathBuf } {
Expand Down

0 comments on commit ecb539a

Please sign in to comment.