summaryrefslogtreecommitdiff
path: root/src/errors.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix VS warning C4098: 'giterr_set_str' : void function returning a valueSven Strickroth2019-01-241-1/+1
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-16/+16
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* git_error: deprecate error valuesEdward Thomson2019-01-221-1/+1
| | | | | 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-4/+26
| | | | | | | | | 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.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* errors: tighten up git_error_state OOMs a bit moreEdward Thomson2015-08-031-30/+42
| | | | | When an error state is an OOM, make sure that we treat is specially and do not try to free it.
* Merge remote-tracking branches 'upstream/pr/3323' and 'upstream/pr/3329'Edward Thomson2015-08-031-17/+33
|\
| * error: store the error messages in a reusable buffercmn/error-bufferCarlos Martín Nieto2015-07-281-17/+33
| | | | | | | | | | | | | | Instead of allocating a brand new buffer for each error string we want to store, we can use a per-thread buffer to store the error string and re-use the underlying storage. We already use the buffer to format the string, so this mostly makes that more direct.
* | Make giterr_restore aware of g_git_oom_errorMichael Procter2015-08-031-8/+11
| | | | | | | | | | | | | | Allow restoring a previously captured oom error, by detecting when the captured message pointer points to the static oom error message. This means there is no need to strdup the message in giterr_detach.
* | Make giterr_detach no longer publicMichael Procter2015-08-031-1/+1
| |
* | Ensure static oom error message not detachedMichael Procter2015-08-031-2/+6
|/ | | | | | | | Error messages that are detached are assumed to be dynamically allocated. Passing a pointer to the static oom error message can cause an attempt to free the static buffer later. This change checks if the oom error message is about to be detached and detaches a copy instead.
* Allow NULL error message prefix when class=GITERR_OSEdward Thomson2014-08-131-7/+9
|
* Remove now-duplicated stdarg.h includeEdward Thomson2014-02-241-1/+0
|
* Improve GIT_EUSER handlingRussell Belfer2013-12-111-3/+42
| | | | | | | | | | | 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.
* error: Simplify giterr_detachVicent Marti2013-11-051-11/+6
|
* Add giterr_detach API to get and clear errorRussell Belfer2013-11-041-0/+23
| | | | | | | | There are a number of cases where it is convenient to be able to fetch and "claim" the current error string, clearing the error. This is helpful when you need to call some code that may alter the error and you want to restore it later on and/or report it via some other mechanism.
* More filemode cleanups for FAT on MacOSRussell Belfer2013-10-081-1/+0
| | | | | | | | | | | | | | | | | | | | | | This cleans up some additional issues. The main change is that on a filesystem that doesn't support mode bits, libgit2 will now create new blobs with GIT_FILEMODE_BLOB always instead of being at the mercy to the filesystem driver to report executable or not. This means that if "core.filemode" lies and claims that filemode is not supported, then we will ignore the executable bit from the filesystem. Previously we would have allowed it. This adds an option to the new git_repository_reset_filesystem to recurse through submodules if desired. There may be other types of APIs that would like a "recurse submodules" option, but this one is particularly useful. This also has a number of cleanups, etc., for related things including trying to give better error messages when problems come up from the filesystem. For example, the FAT filesystem driver on MacOS appears to return errno EINVAL if you attempt to write a filename with invalid UTF-8 in it. We try to capture that with a better error message now.
* Fix valgrind issues (and mmap fallback for diff)Russell Belfer2013-03-141-0/+1
| | | | | | | | | | This fixes a number of issues identified by valgrind - mostly missed free calls. Inside valgrind, mmap() may fail which causes some of the diff tests to fail. This adds a fallback code path to diff_output.c:get_workdir_content() where is the mmap() fails the code will now try to read the file data directly into allocated memory (which is what it would do if the data needed to be filtered anyhow).
* Portability fixes for SolarisPhilip Kelley2013-02-221-4/+5
|
* Deduplicate FormatMessage UTF-16 to UTF-8 conversion codeSven Strickroth2013-02-021-28/+5
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Improved error handlingSven Strickroth2013-02-021-2/+9
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Get utf8_size from WideCharToMultiByte instead of guessing itSven Strickroth2013-02-011-3/+3
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Win32: Make sure error messages are consistently UTF-8 encodedSven Strickroth2013-02-011-5/+14
| | | | | | | | W/o this a libgit2 error message could have a mixed encoding: e.g. a filename in UTF-8 combined with a native Windows error message encoded with the local code page. Signed-off-by: Sven Strickroth <email@cs-ware.de>
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* revparse: Deploy EINVALIDSPEC usagenulltoken2012-12-011-1/+8
|
* Move error capture to top of giterr_setRussell Belfer2012-11-021-4/+4
|
* Prefer GetLastError() for GITERR_OS on Win32Philip Kelley2012-11-021-30/+19
|
* Make giterr_set_str publicRussell Belfer2012-09-211-1/+5
| | | | | | | There has been discussion for a while about making some set of the `giterr_set` type functions part of the public API for code that is implementing new backends to libgit2. This makes the `giterr_set_str()` and `giterr_set_oom()` functions public.
* Fix valgrind warnings and spurious error messagesRussell Belfer2012-08-241-0/+5
| | | | | | Just clean up valgrind warnings about uninitialized memory and also clear out errno in some cases where it results in a false error message being generated at a later point.
* errors: Use a git_buf for building error stringsVicent Martí2012-05-031-29/+42
|
* Remove old and unused error codesVicent Martí2012-05-021-105/+1
|
* Implement git_pool paged memory allocatorRussell Belfer2012-04-251-1/+1
| | | | | | | | | | | | | | | | | | This adds a `git_pool` object that can do simple paged memory allocation with free for the entire pool at once. Using this, you can replace many small allocations with large blocks that can then cheaply be doled out in small pieces. This is best used when you plan to free the small blocks all at once - for example, if they represent the parsed state from a file or data stream that are either all kept or all discarded. There are two real patterns of usage for `git_pools`: either for "string" allocation, where the item size is a single byte and you end up just packing the allocations in together, or for "fixed size" allocation where you are allocating a large object (e.g. a `git_oid`) and you generally just allocation single objects that can be tightly packed. Of course, you can use it for other things, but those two cases are the easiest.
* Refactor git_repository_open with new optionsRussell Belfer2012-04-111-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new command `git_repository_open_ext` with extended options that control how searching for a repository will be done. The existing `git_repository_open` and `git_repository_discover` are reimplemented on top of it. We may want to change the default behavior of `git_repository_open` but this commit does not do that. Improve support for "gitdir" files where the work dir is separate from the repo and support for the "separate-git-dir" config. Also, add support for opening repos created with `git-new-workdir` script (although I have only confirmed that they can be opened, not that all functions work correctly). There are also a few minor changes that came up: - Fix `git_path_prettify` to allow in-place prettifying. - Fix `git_path_root` to support backslashes on Win32. This fix should help many repo open/discover scenarios - it is the one function called when opening before prettifying the path. - Tweak `git_config_get_string` to set the "out" pointer to NULL if the config value is not found. Allows some other cleanup. - Fix a couple places that should have been calling `git_repository_config__weakptr` and were not. - Fix `cl_git_sandbox_init` clar helper to support bare repos.
* Resolve comments from pull requestRussell Belfer2012-03-131-7/+26
| | | | | | | This converts the map validation function into a macro, tweaks the GITERR_OS system error automatic appending, and adds a tentative new error access API and some quick unit tests for both the old and new error APIs.
* Migrate ODB files to new error handlingRussell Belfer2012-03-121-4/+24
| | | | | | | | | | | | | | This migrates odb.c, odb_loose.c, odb_pack.c and pack.c to the new style of error handling. Also got the unix and win32 versions of map.c. There are some minor changes to other files but no others were completely converted. This also contains an update to filebuf so that a zeroed out filebuf will not think that the fd (== 0) is actually open (and inadvertently call close() on fd 0 if cleaned up). Lastly, this was built and tested on win32 and contains a bunch of fixes for the win32 build which was pretty broken.
* error-handling: On-disk config file backendVicent Martí2012-03-091-9/+19
| | | | | | | | | | | | | | | Includes: - Proper error reporting when encountering syntax errors in a config file (file, line number, column). - Rewritten `config_write`, now with 99% less goto-spaghetti - Error state in `git_filebuf`: filebuf write functions no longer need to be checked for error returns. If any of the writes performed on a buffer fail, the last call to `git_filebuf_commit` or `git_filebuf_hash` will fail accordingly and set the appropiate error message. Baller!
* Fix issues raised on pull requestRussell Belfer2012-03-071-1/+1
| | | | This resolves the comments on pull request #590
* Migrating diff to new error handlingRussell Belfer2012-03-061-0/+9
| | | | | | Ended up migrating a bunch of upstream functions as well including vector, attr_file, and odb in order to get this to work right.
* error-handling: ReferencesVicent Martí2012-03-061-37/+17
| | | | | Yes, this is error handling solely for `refs.c`, but some of the abstractions leak all ofer the code base.
* error-handling: Add new routinesVicent Martí2012-03-031-0/+64
| | | | | Obviously all the old throw routines are still in place, so we can gradually port over.
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* threads: Fix the shared global state with TLSVicent Marti2011-11-161-13/+19
| | | | | | | See `global.c` for a description of what we're doing. When libgit2 is built with GIT_THREADS support, the threading system must be explicitly initialized with `git_threads_init()`.
* global: Properly use `git__` memory wrappersVicent Marti2011-10-281-2/+2
| | | | | Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
* Tabify everythingVicent Marti2011-09-191-1/+1
| | | | | | There were quite a few places were spaces were being used instead of tabs. Try to catch them all. This should hopefully not break anything. Except for `git blame`. Oh well.
* Cleanup legal dataVicent Marti2011-09-191-21/+3
| | | | | | | | | | 1. The license header is technically not valid if it doesn't have a copyright signature. 2. The COPYING file has been updated with the different licenses used in the project. 3. The full GPLv2 header in each file annoys me.
* Fix false positive -Wuninitialized warningsKirill A. Shutemov2011-08-241-6/+2
| | | | | | | | GCC produces several -Wuninitialized warnings. Most of them can be fixed if we make visible for gcc that git__throw() and git__rethrow() always return first argument. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* test: Properly show error messagesVicent Marti2011-06-281-0/+7
|
* Added error for ambiguous oid prefixes. Added methods to compare the first ↵Marc Pegon2011-06-011-0/+1
| | | | nth hexadecimal characters (i.e. packets of 4 bits) of OIDs.
* Merge upstream/developmentCarlos Martín Nieto2011-05-171-0/+64
|\
| * Bring back `git_strerror`Vicent Marti2011-05-111-0/+46
| | | | | | | | | | We cannot totally deprecate this until the new error handling mechanisms are all in place.