[CString panic reduction] Reduce panics without changing return types - #1308
Open
DanielEScherzer wants to merge 28 commits into
Open
[CString panic reduction] Reduce panics without changing return types#1308DanielEScherzer wants to merge 28 commits into
DanielEScherzer wants to merge 28 commits into
Conversation
…str()` Add a `#[should_panic]` regression test for `ObjectType::from_str()` with an invalid string.
Instead of panicking, treat failure to create a `CString` as indicating that the provided string does not correspond to valid object type.
…hes()` Add a `#[should_panic]` regression test for `Refspec::dst_matches()` with an invalid string.
Instead of panicking, treat failure to create a `CString` as indicating that the provided string is not matched by the refspec.
…hes()` Add a `#[should_panic]` regression test for `Refspec::src_matches()` with an invalid string.
Instead of panicking, treat failure to create a `CString` as indicating that the provided string is not matched by the refspec.
…m()` Add a `#[should_panic]` regression test for `Refspec::transform()` with an invalid string.
Instead of panicking, convert the `alloc::ffi::NulError` error from the failure to create a `CString` into a git2 `Error` object and return an error variant.
…rm()` Add a `#[should_panic]` regression test for `Refspec::rtransform()` with an invalid string.
Instead of panicking, convert the `alloc::ffi::NulError` error from the failure to create a `CString` into a git2 `Error` object and return an error variant.
…_ref()` Add a `#[should_panic]` regression test for `Transaction::lock_ref()` with an invalid string.
Instead of panicking, convert the `alloc::ffi::NulError` error from the failure to create a `CString` into a git2 `Error` object and return an error variant.
…target()` Add a `#[should_panic]` regression test for `Transaction::set_target()` with an invalid string for the `refname` parameter.
For the `refname` parameter, instead of panicking, convert the `alloc::ffi::NulError` error from the failure to create a `CString` into a git2 `Error` object and return an error variant.
…:set_target()` Add a `#[should_panic]` regression test for `Transaction::set_target()` with an invalid string for the `reflog_message` parameter.
…get()` For the `reflog_message` parameter, instead of panicking, convert the `alloc::ffi::NulError` error from the failure to create a `CString` into a git2 `Error` object and return an error variant.
…symbolic_target()` Add a `#[should_panic]` regression test for `Transaction::set_symbolic_target()` with an invalid string for the `refname` parameter.
…_target()` For the `refname` parameter, instead of panicking, convert the `alloc::ffi::NulError` error from the failure to create a `CString` into a git2 `Error` object and return an error variant.
…:set_symbolic_target()` Add a `#[should_panic]` regression test for `Transaction::set_symbolic_target()` with an invalid string for the `target` parameter.
…bolic_target()` For the `target` parameter, instead of panicking, convert the `alloc::ffi::NulError` error from the failure to create a `CString` into a git2 `Error` object and return an error variant.
…:set_symbolic_target()` Add a `#[should_panic]` regression test for `Transaction::set_symbolic_target()` with an invalid string for the `reflog_message` parameter.
…bolic_target()` For the `reflog_message` parameter, instead of panicking, convert the `alloc::ffi::NulError` error from the failure to create a `CString` into a git2 `Error` object and return an error variant.
…reflog()` Add a `#[should_panic]` regression test for `Transaction::set_reflog()` with an invalid string.
Instead of panicking, convert the `alloc::ffi::NulError` error from the failure to create a `CString` into a git2 `Error` object and return an error variant.
…ve()` Add a `#[should_panic]` regression test for `Transaction::remove()` with an invalid string.
Instead of panicking, convert the `alloc::ffi::NulError` error from the failure to create a `CString` into a git2 `Error` object and return an error variant.
…tes()` Add a `#[should_panic]` regression test for `Tree::get_name_bytes()` with an invalid string.
Instead of panicking, convert the `alloc::ffi::NulError` error from the failure to create a `CString` into a git2 `Error` object and return an error variant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For functions where the failure can be effectively community via the existing return type, instead of panicking when a CString cannot be created, return
falseorNoneor an error variant.Part of #1297