Change IndexMatchedPath callback to take an Option #1268
Conversation
This comment has been minimized.
This comment has been minimized.
The matched pathspec can sometimes be None (if there was no match). This was crashing because the code was panicking in the C callback without being within the panic wrapper. The fix here is to properly handle the case where the matched_pathspec is NULL. Fixes rust-lang#585
1a7e6fb to
44eea16
Compare
Is there a reason to not just use an empty slice for the missing pathspec, instead of converting to an option? |
|
Hm, that's an interesting question. libgit2 treats an empty set of pathspecs ( git has forbidden empty pathspecs since 2.16 (from 2018), but it looks like libgit2 hasn't followed that change. One could argue that getting an empty pathspec isn't quite the same as an empty set of pathspecs, but since they are treated the same (and you can't distinguish between them), it seems reasonable to me. The main risk is if libgit2 ever decides that the empty string is no longer allowed, but an empty set is. I'm not sure if that would ever happen. |
The matched pathspec can sometimes be None (if there was no match). This was crashing because the code was panicking in the C callback without being within the panic wrapper. The fix here is to properly handle the case where the matched_pathspec is NULL.
Fixes #585
Opening as a draft since this is a semver-breaking change. We'll need to decide when to slot this in.