summaryrefslogtreecommitdiff
path: root/include/git2/errors.h
Commit message (Collapse)AuthorAgeFilesLines
* streams: sockets are non-blocking and can timeoutEdward Thomson2023-05-131-1/+2
| | | | | | | | | | | | | | | Make socket I/O non-blocking and add optional timeouts. Users may now set `GIT_OPT_SET_SERVER_CONNECT_TIMEOUT` to set a shorter connection timeout. (The connect timeout cannot be longer than the operating system default.) Users may also now configure the socket read and write timeouts with `GIT_OPT_SET_SERVER_TIMEOUT`. By default, connects still timeout based on the operating system defaults (typically 75 seconds) and socket read and writes block. Add a test against our custom testing git server that ensures that we can timeout reads against a slow server.
* Merge branch 'pr/pks-t/5254' into shallow-clone-localyuangli2022-07-261-1/+2
|\
| * Merge branch 'main' into pr/pks-t/5254Yuang Li2022-06-241-6/+6
| |\
| * | grafts: move parsing into grafts modulePatrick Steinhardt2020-06-271-1/+2
| | | | | | | | | | | | | | | | | | Parsing of grafts files is currently contained in the repository code. To make grafts-related logic more self-contained, move it into "grafts.c" instead.
* | | repo: ensure that repo dir is owned by current userEdward Thomson2022-04-111-1/+2
| | | | | | | | | | | | | | | | | | Ensure that the repository directory is owned by the current user; this prevents us from opening configuration files that may have been created by an attacker.
* | | sha: GIT_ERROR_SHA1 is deprecated in favor of GIT_ERROR_SHAEdward Thomson2022-03-231-1/+1
| | | | | | | | | | | | The more generic GIT_ERROR_SHA allows for SHA256 errors as well as SHA1.
* | | errors: expose `git_error_set`Edward Thomson2022-02-221-2/+16
| | | | | | | | | | | | | | | The `git_error_set` function is useful for callers who implement backends and advanced callbacks. Expose it.
* | | Make enum in includes C90 compliant by removing trailing comma.Peter Pettersson2021-11-151-1/+1
| |/ |/|
* | Merge branch 'main' into http-use-eauthEdward Thomson2021-08-291-1/+2
|\ \ | |/
| * Introduce GIT_ASSERT macrosEdward Thomson2020-05-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Provide macros to replace usages of `assert`. A true `assert` is punishing as a library. Instead we should do our best to not crash. GIT_ASSERT_ARG(x) will now assert that the given argument complies to some format and sets an error message and returns `-1` if it does not. GIT_ASSERT(x) is for internal usage, and available as an internal consistency check. It will set an error message and return `-1` in the event of failure.
* | use consistent whitespace before commentsJosh Bleecher Snyder2020-02-071-6/+6
|/
* error functions: return an intEdward Thomson2020-01-241-1/+2
| | | | | Stop returning a void for functions, future-proofing them to allow them to fail.
* http: introduce GIT_ERROR_HTTPethomson/gssapiEdward Thomson2020-01-241-1/+2
| | | | | Disambiguate between general network problems and HTTP problems in error codes.
* deprecation: move deprecated bits to deprecated.hEdward Thomson2019-01-251-88/+0
|
* git_error: deprecate error valuesEdward Thomson2019-01-221-34/+34
| | | | | Replace the `GITERR` values with a `const int` to deprecate error values.
* git_error: use full class name in public error APIEdward Thomson2019-01-221-43/+131
| | | | | | | | | Move to the `git_error` name in error-related functions, deprecating the `giterr` functions. This means, for example, that `giterr_last` is now `git_error_last`. The old names are retained for compatibility. This only updates the public API; internal API and function usage remains unchanged.
* transport: allow cred/cert callbacks to return GIT_PASSTHROUGHethomson/defer_cert_cred_cbEdward Thomson2018-11-211-1/+1
| | | | | | | | | | | | Allow credential and certificate checking callbacks to return GIT_PASSTHROUGH, indicating that they do not want to act. Introduce this to support in both the http and ssh callbacks. Additionally, enable the same mechanism for certificate validation. This is most useful to disambiguate any meaning in the publicly exposed credential and certificate functions (`git_transport_smart_credentials` and `git_transport_smart_certificate_check`) but it may be more generally useful for callers to be able to defer back to libgit2.
* apply: return a specific exit code on failureEdward Thomson2018-11-041-0/+1
| | | | | | Return `GIT_EAPPLYFAIL` on patch application failure so that users can determine that patch application failed due to a malformed/conflicting patch by looking at the error code.
* Merge pull request #4788 from tiennou/doc-fixesPatrick Steinhardt2018-08-301-1/+2
|\ | | | | Documentation fixes
| * doc: fix comment on GIT_EUSEREtienne Samson2018-08-291-1/+2
| |
* | Add two words to clarifyJohan Abildskov2018-08-271-1/+1
| |
* | Update giterr_last API documentation to reflect real behaviourJohan Abildskov2018-08-201-1/+6
|/
* index: return a unique error code on dirty indexEdward Thomson2018-06-291-0/+1
| | | | | When the index is dirty, return GIT_EINDEXDIRTY so that consumers can identify the exact problem programatically.
* odb: verify object hashesPatrick Steinhardt2017-04-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The upstream git.git project verifies objects when looking them up from disk. This avoids scenarios where objects have somehow become corrupt on disk, e.g. due to hardware failures or bit flips. While our mantra is usually to follow upstream behavior, we do not do so in this case, as we never check hashes of objects we have just read from disk. To fix this, we create a new error class `GIT_EMISMATCH` which denotes that we have looked up an object with a hashsum mismatch. `odb_read_1` will then, after having read the object from its backend, hash the object and compare the resulting hash to the expected hash. If hashes do not match, it will return an error. This obviously introduces another computation of checksums and could potentially impact performance. Note though that we usually perform I/O operations directly before doing this computation, and as such the actual overhead should be drowned out by I/O. Running our test suite seems to confirm this guess. On a Linux system with best-of-five timings, we had 21.592s with the check enabled and 21.590s with the ckeck disabled. Note though that our test suite mostly contains very small blobs only. It is expected that repositories with bigger blobs may notice an increased hit by this check. In addition to a new test, we also had to change the odb::backend::nonrefreshing test suite, which now triggers a hashsum mismatch when looking up the commit "deadbeef...". This is expected, as the fake backend allocated inside of the test will return an empty object for the OID "deadbeef...", which will obviously not hash back to "deadbeef..." again. We can simply adjust the hash to equal the hash of the empty object here to fix this test.
* win32: introduce `do_with_retries` macroEdward Thomson2017-04-011-0/+1
| | | | | | Provide a macro that will allow us to run a function with posix-like return values multiple times in a retry loop, with an optional cleanup function called between invocations.
* hash: include sha1collisiondetectionEdward Thomson2017-03-031-1/+2
| | | | | Include the SHA1 collision attack detection library from https://github.com/cr-marcstevens/sha1collisiondetection
* worktree: implement `git_worktree_validate`Patrick Steinhardt2017-02-131-0/+1
| | | | | | Add a new function that checks wether a given `struct git_worktree` is valid. The validation includes checking if the gitdir, parent directory and common directory are present.
* Introduce git_apply_patchEdward Thomson2016-05-261-1/+2
| | | | | The beginnings of patch application from an existing (diff-created) git_patch object: applies the hunks of a git_patch to a buffer.
* giterr_set_str: remove `GITERR_OS` documentationEdward Thomson2016-02-231-5/+0
| | | | | The `giterr_set_str` does not actually honor `GITERR_OS`. Remove the documentation that claims that we do.
* merge: add GIT_MERGE_TREE_FAIL_ON_CONFLICTEdward Thomson2015-10-221-0/+1
| | | | | | Provide a new merge option, GIT_MERGE_TREE_FAIL_ON_CONFLICT, which will stop on the first conflict and fail the merge operation with GIT_EMERGECONFLICT.
* Make giterr_detach no longer publicMichael Procter2015-08-031-12/+0
|
* errors: add EDIRECTORYCarlos Martín Nieto2015-07-121-0/+1
| | | | | This is to be returned when the operation which the user asked for is not possible to do on a directory.
* stash: don't allow apply with staged changesEdward Thomson2015-06-251-0/+1
|
* errors: introduce EINVALIDCarlos Martín Nieto2015-06-241-0/+1
| | | | | We've been using EINVALIDSPEC for a while to mean this, but that name is too specific. Introduce this to be more explicit.
* Rename GIT_EMERGECONFLICT to GIT_ECONFLICTEdward Thomson2015-05-291-1/+1
| | | | | | | | | | We do not error on "merge conflicts"; on the contrary, merge conflicts are a normal part of merging. We only error on "checkout conflicts", where a change exists in the index or the working directory that would otherwise be overwritten by performing the checkout. This *may* happen during merge (after the production of the new index that we're going to checkout) but it could happen during any checkout.
* errors: add GIT_EEOF to indicate early EOFcmn/server-errorsCarlos Martín Nieto2015-05-201-0/+1
| | | | | | This can be used by tools to show mesages about failing to communicate with the server. The error message in this case will often contain the server's error message, as far as it managed to send anything.
* mkdir: walk up tree to mkdirEdward Thomson2015-01-201-0/+1
| | | | | | Walk up the tree to mkdir, which is less immediately efficient, but allows us to look at intermediate directories that may need attention.
* peel: reject bad queries with EINVALIDSPECcmn/peeling-errorsCarlos Martín Nieto2014-11-221-0/+1
| | | | | | | | | | There are some combination of objects and target types which we know cannot be fulfilled. Return EINVALIDSPEC for those to signify that there is a mismatch in the user-provided data and what the object model is capable of satisfying. If we start at a tag and in the course of peeling find out that we cannot reach a particular type, we return EPEEL.
* git_rebase_commit: drop already-picked commitsEdward Thomson2014-10-261-0/+1
| | | | | | Already cherry-picked commits should not be re-included. If all changes included in a commit exist in the upstream, then we should error with GIT_EAPPLIED.
* Introduce git_rebase to set up a rebase sessionEdward Thomson2014-10-261-0/+1
| | | | | | Introduce `git_rebase` to set up a rebase session that can then be continued. Immediately, only merge-type rebase is supported.
* Merge remote-tracking branch 'upstream/master' into cmn/describeCarlos Martín Nieto2014-09-301-16/+18
|\
| * Provide a callback for certificate validationCarlos Martín Nieto2014-09-161-0/+1
| | | | | | | | | | | | | | | | | | If the certificate validation fails (or always in the case of ssh), let the user decide whether to allow the connection. The data structure passed to the user is the native certificate information from the underlying implementation, namely OpenSSL or WinHTTP.
| * Introduce GIT_EAUTHCarlos Martín Nieto2014-06-261-0/+1
| | | | | | | | Introduce this error code to signal an authentication failure.
| * Fixed miscellaneous documentation errors.Michael Anderson2014-05-231-16/+16
| |
* | object: introduce git_describe_object()nulltoken2014-04-301-0/+1
|/
* Added cherry-pick supportJacques Germishuys2014-04-141-0/+1
|
* refs: return GIT_EMODIFIED if the ref target movedCarlos Martín Nieto2014-02-051-0/+1
| | | | | In case we loose the race to update the reference, return GIT_EMODIFIED to let the user distinguish it from other types of errors.
* Update docs for new callback return value behaviorRussell Belfer2013-12-111-16/+29
|
* Remove converting user error to GIT_EUSERRussell Belfer2013-12-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes the behavior of callbacks so that the callback error code is not converted into GIT_EUSER and instead we propagate the return value through to the caller. Instead of using the giterr_capture and giterr_restore functions, we now rely on all functions to pass back the return value from a callback. To avoid having a return value with no error message, the user can call the public giterr_set_str or some such function to set an error message. There is a new helper 'giterr_set_callback' that functions can invoke after making a callback which ensures that some error message was set in case the callback did not set one. In places where the sign of the callback return value is meaningful (e.g. positive to skip, negative to abort), only the negative values are returned back to the caller, obviously, since the other values allow for continuing the loop. The hardest parts of this were in the checkout code where positive return values were overloaded as meaningful values for checkout. I fixed this by adding an output parameter to many of the internal checkout functions and removing the overload. This added some code, but it is probably a better implementation. There is some funkiness in the network code where user provided callbacks could be returning a positive or a negative value and we want to rely on that to cancel the loop. There are still a couple places where an user error might get turned into GIT_EUSER there, I think, though none exercised by the tests.
* Improve GIT_EUSER handlingRussell Belfer2013-12-111-2/+1
| | | | | | | | | | | This adds giterr_user_cancel to return GIT_EUSER and clear any error message that is sitting around. As a result of using that in places, we need to be more thorough with capturing errors that happen inside a callback when used internally. To help with that, this also adds giterr_capture and giterr_restore so that when we internally use a foreach-type function that clears errors and converts them to GIT_EUSER, it is easier to restore not just the return value, but the actual error message text.