summaryrefslogtreecommitdiff
path: root/src/object.c
Commit message (Collapse)AuthorAgeFilesLines
* Make the tests pass cleanly with MemorySanitizerlhchavez2020-06-301-1/+2
| | | | | | | | | This change: * Initializes a few variables that were being read before being initialized. * Includes https://github.com/madler/zlib/pull/393. As such, it only works reliably with `-DUSE_BUNDLED_ZLIB=ON`.
* Make type mismatch errors consistentTobias Nießen2020-01-151-1/+1
|
* object: deprecate git_object__size for removalcmn/object-size-nopublicCarlos Martín Nieto2019-07-291-10/+4
| | | | | | | | In #5118 we remove the double-underscore to make it a normally-named public function. However, this is not an interesting function outside of the library and it takes up a name for something that could be more useful. Remove the single-underscore version as we have not done any releases with it.
* configuration: cvar -> configmapPatrick Steinhardt2019-07-181-1/+1
| | | | | `cvar` is an unhelpful name. Refactor its usage to `configmap` for more clarity.
* object: rename git_object__size to git_object_sizeethomson/object_sizeEdward Thomson2019-06-161-3/+9
| | | | We don't use double-underscores in the public API.
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-12/+12
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* object_type: GIT_OBJECT_BAD is now GIT_OBJECT_INVALIDEdward Thomson2019-01-171-3/+3
| | | | | | | We use the term "invalid" to refer to bad or malformed data, eg `GIT_REF_INVALID` and `GIT_EINVALIDSPEC`. Since we're changing the names of the `git_object_t`s in this release, update it to be `GIT_OBJECT_INVALID` instead of `BAD`.
* object_type: use new enumeration namesethomson/index_fixesEdward Thomson2018-12-011-53/+53
| | | | Use the new object_type enumeration names within the codebase.
* object: properly propagate errors on parsing failuresPatrick Steinhardt2018-10-111-1/+3
| | | | | | | | | When failing to parse a raw object fromits data, we free the partially parsed object but then fail to propagate the error to the caller. This may lead callers to operate on objects with invalid memory, which will sooner or later cause the program to segfault. Fix the issue by passing up the error code returned by `parse_raw`.
* object: implement function to parse raw dataPatrick Steinhardt2018-06-221-8/+57
| | | | | | | | | Now that we have implement functions to parse all git objects from raw data, we can implement a generic function `git_object__from_raw` to create a structure of type `git_object`. This allows us to parse and interpret objects from raw data without having to touch the ODB at all, which is especially useful for object verification prior to accepting them into the repository.
* object: introduce git_object_stringn2typeEdward Thomson2017-12-201-2/+11
| | | | | | | | | Introduce an internal API to get the object type based on a length-specified (not null terminated) string representation. This can be used to compare the (space terminated) object type name in a loose object. Reimplement `git_object_string2type` based on this API.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-1/+3
| | | | | | | | | | | | | | | | | | | | | | 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.
* settings: rename `GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`Patrick Steinhardt2017-06-081-1/+0
| | | | | | | | | | | Initially, the setting has been solely used to enable the use of `fsync()` when creating objects. Since then, the use has been extended to also cover references and index files. As the option is not yet part of any release, we can still correct this by renaming the option to something more sensible, indicating not only correlation to objects. This commit renames the option to `GIT_OPT_ENABLE_FSYNC_GITDIR`. We also move the variable from the object to repository source code.
* fsync: call it "synchronous" object writingEdward Thomson2017-02-281-1/+1
| | | | | Rename `GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION` -> `GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`.
* Add `ENABLE_SYNCHRONIZED_OBJECT_CREATION` optionEdward Thomson2017-02-281-0/+1
| | | | Allow users to enable `SYNCHRONIZED_OBJECT_CREATION` with a setting.
* giterr_set: consistent error messagesEdward Thomson2016-12-291-5/+5
| | | | | | | | Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
* object: avoid call of memset with ouf of bounds pointerPatrick Steinhardt2016-03-111-6/+3
| | | | | | | | | | | | | | When computing a short OID we do this by first copying the leading parts into the new OID structure and then setting the trailing part to zero. In the case of the desired length being `GIT_OID_HEXSZ - 1` we will call `memset` with an out of bounds pointer and a length of 0. While this seems to cause no problems for common platforms the C89 standard does not explicitly state that calling `memset` with an out of bounds pointer and length of 0 is valid. Fix the potential issue by using the newly introduced `git_oid__cpy_prefix` function.
* turn on strict object validation by defaultEdward Thomson2016-02-281-1/+1
|
* git_object__is_valid: use `odb_read_header`Edward Thomson2016-02-281-0/+24
| | | | | This allows lighter weight validation in `git_object__is_valid` that does not require reading the entire object.
* git_libgit2_opts: introduce `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION`Edward Thomson2016-02-281-0/+2
|
* object: remove unused constant OBJECT_BASE_SIZEPatrick Steinhardt2015-11-301-2/+0
|
* Revert "object: correct the expected ID size in prefix lookup"Vicent Marti2015-06-261-5/+5
| | | | | | | | | | | | This reverts commit 969d4b703c910a8fd045baafbcd243b4c9825316. This was a fluke from Coverity. The length to all the APIs in the library is supposed to be passed in as nibbles, not bytes. Passing it as bytes would prevent us from parsing uneven-sized SHA1 strings. Also, the rest of the library was still using nibbles (including revparse and the odb_prefix APIs), so this change was seriously breaking things in unexpected ways. ^^
* object: correct the expected ID size in prefix lookupCarlos Martín Nieto2015-06-101-5/+5
| | | | | | | | | | | | | We take in a possibly partial ID by taking a length and working off of that to figure out whether to just look up the object or ask the backends for a prefix lookup. Unfortunately we've been checking the size against `GIT_OID_HEXSZ` which is the size of a *string* containing a full ID, whereas we need to check against the size we can have when it's a 20-byte array. Change the checks and comment to use `GIT_OID_RAWSZ` which is the correct size of a git_oid to have when full.
* peel: reject bad queries with EINVALIDSPECcmn/peeling-errorsCarlos Martín Nieto2014-11-221-6/+33
| | | | | | | | | | 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.
* object: fix a braceCarlos Martín Nieto2014-05-061-1/+1
| | | | | | The brace in the check for peel's return was surrounding the wrong thing, which made 'error' be set to 1 when there was an error instead of the error code.
* Add git_object_short_id API to get short id stringRussell Belfer2014-03-041-0/+43
| | | | | | This finds a short id string that will unambiguously select the given object, starting with the core.abbrev length (usually 7) and growing until it is no longer ambiguous.
* Remove now-duplicated stdarg.h includeEdward Thomson2014-02-241-2/+0
|
* Avoid temporary object in lookup routineBen Straub2013-10-281-8/+7
|
* Port blame from git.gitBen Straub2013-09-161-0/+36
|
* Fix broken build when MSVC SDL checks is enabledLinquize2013-05-111-1/+1
|
* Use assert for peel target type checkRussell Belfer2013-05-021-10/+5
|
* Report a couple object error conditionsRussell Belfer2013-05-011-8/+14
|
* Simplify object table parse functionsRussell Belfer2013-04-221-23/+14
| | | | | This unifies the object parse functions into one signature that takes an odb_object.
* Add callback to git_objects_tableRussell Belfer2013-04-221-93/+52
| | | | | | | | | | This adds create and free callback to the git_objects_table so that more of the creation and destruction of objects can be table driven instead of using switch statements. This also makes the semantics of certain object creation functions consistent so that we can make better use of function pointers. This also fixes a theoretical error case where an object allocation fails and we end up storing NULL into the cache.
* Duplicated type objectVicent Marti2013-04-221-9/+6
|
* What has science done.Vicent Marti2013-04-221-4/+5
|
* Random evictionVicent Marti2013-04-221-0/+1
|
* lol this worked first try wtfVicent Marti2013-04-221-21/+33
|
* object: Export git_object_dupVicent Marti2013-04-101-1/+7
|
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* object: refine git_object_peel() error reportnulltoken2012-12-011-11/+33
|
* Remove git_object_oid2typePhilip Kelley2012-11-291-15/+0
|
* Push! By schu, phkelley, and congyiwu, et alPhilip Kelley2012-11-281-0/+16
|
* object: Raise proper code on invalid object typeVicent Marti2012-11-281-2/+2
|
* More external API cleanupVicent Marti2012-11-271-3/+3
| | | | | | Conflicts: src/branch.c tests-clar/refs/branches/create.c
* repo: Make git_repository_head_tree() return error codesnulltoken2012-11-221-40/+0
|
* Reorg internal odb read header and object lookupRussell Belfer2012-09-101-44/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | Often `git_odb_read_header` will "fail" and have to read the entire object into memory instead of just the header. When this happens, the object is loaded and then disposed of immediately, which makes it difficult to efficiently use the header information to decide if the object should be loaded (since attempting to do so will often result in loading the object twice). This commit takes the existing code and reorganizes it to have two new functions: - `git_odb__read_header_or_object` which acts just like the old read header function except that it returns the object, too, if it was forced to load the whole thing. It then becomes the callers responsibility to free the `git_odb_object`. - `git_object__from_odb_object` which was extracted from the old `git_object_lookup` and creates a subclass of `git_object` from an existing `git_odb_object` (separating the ODB lookup from the `git_object` creation). This allows you to use the first header reading function efficiently without instantiating the `git_odb_object` twice. There is no net change to the behavior of any of the existing functions, but this allows internal code to tap into the ODB lookup and object creation to be more efficient.
* Make git_object_peel a bit smarterRussell Belfer2012-08-271-25/+26
| | | | | | | | | | | This expands the types of peeling that `git_object_peel` knows how to do to include TAG -> BLOB peeling, and makes the errors slightly more consistent depending on the situation. It also adds a new special behavior where peeling to ANY will peel until the object type changes (e.g. chases TAGs to a non-TAG). Using this expanded peeling, this replaces peeling code that was embedded in `git_tag_peel` and `git_reset`.
* portability: Improve x86/amd64 compatibilitynulltoken2012-07-241-1/+1
|
* object: introduce git_object_peel()nulltoken2012-07-171-0/+69
| | | | Partially fix #530