Add bindings for git_index_find_prefix#903
Conversation
| if result == 0 { | ||
| Ok(Some(at_pos)) | ||
| } else { | ||
| Ok(None) | ||
| } |
There was a problem hiding this comment.
This doesn't ever seem to return an error. Should this perhaps be:
| if result == 0 { | |
| Ok(Some(at_pos)) | |
| } else { | |
| Ok(None) | |
| } | |
| if result == 0 { | |
| Ok(Some(at_pos)) | |
| } else if result == raw::GIT_ENOTFOUND { | |
| Ok(None) | |
| } else { | |
| Err(Error::last_error(result).unwrap()) | |
| } |
I understand git_index_find_prefix currently never returns any other error, but I'm not very comfortable assuming that will be the case forever.
Also, I'm a little uncomfortable doing the ENOTFOUND check. I think it makes for a more natural Rust interface, but I don't see any other methods in the library doing that (they all just return NotFound). What were your thoughts on this?
There was a problem hiding this comment.
Indeed, I imagined that returning None in situations when the prefix hasn't been found would be more rusty, but after reviewing some other similar functions, it seems like NotFound error is never handled this way, and as there's no point in going against the design of the rest of the library I just decided to leave it inside the Error, as you suggested.
I hope it's okay now
Plus a test that checks
find_prefixandget_path