-
Notifications
You must be signed in to change notification settings - Fork 429
Open
Description
git2::ReferenceNames is an iterator that lists the names of references in the repository. The documentation observes that ReferenceNames is more efficient compared to References, since ReferenceNames outputs a &str rather than a Reference.
The problem is that there might be references whose names aren't valid UTF-8 and therefore can't be represented as str. If such a reference is found, next will panic (str::from_utf8(bytes).unwrap(), at reference.rs line 498.)
For example, if I create a repository like this:
git init foo
cd foo
git branch -m $'\300'
git commit --allow-empty -m whoops
Then the following program will crash when invoked in foo:
fn main() {
let repo = git2::Repository::open_from_env().expect("open_from_env");
let mut refs = repo.references().expect("references");
for name in refs.names() {
println!("name: {name:?}");
}
}
Instead, the iterator probably ought to produce an error value in this case. I don't know what that error should be, since it's not a libgit2 error.
Metadata
Metadata
Assignees
Labels
No labels