summaryrefslogtreecommitdiff
path: root/src/object.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
* object: add missing git_odb_object_freeMichael Schubert2012-06-211-1/+3
|
* errors: Rename error codesbreaking-changesVicent Martí2012-05-181-3/+3
|
* errors: Rename the generic return codesVicent Martí2012-05-181-6/+6
|
* object: make git_object_lookup() return GIT_ENOTFOUND when searching for an ↵nulltoken2012-05-111-2/+2
| | | | | | | | | existing object by specifying an incorrect type This fix complements cb0ce16bbe8efe2098ef9cfffcf158301b036565 and cover the following additional use cases - retrieving an object which has been previously searched, found and cached - retrieving an object through an non ambiguous abbreviated id
* object: make git_object_lookup() return GIT_ENOTFOUND when searching for an ↵nulltoken2012-05-081-2/+2
| | | | existing object by specifying an incorrect type
* Fix valgrind issuesRussell Belfer2012-05-041-1/+1
| | | | | | | There are three changes here: - correctly propogate error code from failed object lookups - make zlib inflate use our allocators - add OID to notfound error in ODB lookups
* Support reading attributes from indexRussell Belfer2012-05-031-0/+39
| | | | | | | | | | | | | | Depending on the operation, we need to consider gitattributes in both the work dir and the index. This adds a parameter to all of the gitattributes related functions that allows user control of attribute reading behavior (i.e. prefer workdir, prefer index, only use index). This fix also covers allowing us to check attributes (and hence do diff and status) on bare repositories. This was a somewhat larger change that I hoped because it had to change the cache key used for gitattributes files.
* Remove old and unused error codesVicent Martí2012-05-021-2/+1
|
* error handling: move the missing parts over to the new error handlingCarlos Martín Nieto2012-04-261-15/+15
|
* Migrate ODB files to new error handlingRussell Belfer2012-03-121-1/+1
| | | | | | | | | | | | | | 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.
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* Rename all `_close` methodsVicent Marti2011-11-261-4/+4
| | | | | There's no difference between `_free` and `_close` semantics: keep everything with the same name to avoid confusions.
* repository: Change ownership semanticsVicent Marti2011-11-261-6/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ownership semantics have been changed all over the library to be consistent. There are no more "borrowed" or duplicated references. Main changes: - `git_repository_open2` and `3` have been dropped. - Added setters and getters to hotswap all the repository owned objects: `git_repository_index` `git_repository_set_index` `git_repository_odb` `git_repository_set_odb` `git_repository_config` `git_repository_set_config` `git_repository_workdir` `git_repository_set_workdir` Now working directories/index files/ODBs and so on can be hot-swapped after creating a repository and between operations. - All these objects now have proper ownership semantics with refcounting: they all require freeing after they are no longer needed (the repository always keeps its internal reference). - Repository open and initialization has been updated to keep in mind the configuration files. Bare repositories are now always detected, and a default config file is created on init. - All the tests affected by these changes have been dropped from the old test suite and ported to the new one.
* global: Properly use `git__` memory wrappersVicent Marti2011-10-281-1/+1
| | | | | Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
* Tabify everythingVicent Marti2011-09-191-7/+7
| | | | | | 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 memory leak when wrong object type is looked up from cacheLambert CLARA2011-08-021-0/+3
| | | | Update unit test accordingly : no need to close
* short-oid: CleanupVicent Marti2011-06-011-9/+8
|
* Added a GIT_OID_MINPREFIXLEN constant to define the minimum length allowed ↵Marc Pegon2011-06-011-2/+2
| | | | for oid prefixes (set to 4, like in git). Consequently updated some object lookup methods and their documentation.
* Added git.git sha1 lookup method to replace simple binary search in pack ↵Marc Pegon2011-06-011-9/+52
| | | | | | | | | | | | | | | backend. Implemented find_unique_short_oid for pack backend, based on git sha1 lookup method; finding an object given its full oid is just a particular case of searching the unique object matching an oid prefix (short oid). Added git_odb_read_unique_short_oid, which iterates over all the backends to find and read the unique object matching the given oid prefix. Added a git_object_lookup_short_oid method to find the unique object in the repository matching a given oid prefix : it generalizes git_object_lookup which now does nothing but calls git_object_lookup_short_oid.
* object: Reword errorsVicent Marti2011-05-231-3/+3
|
* object.c: Move to new error handling mechanismJakob Pfender2011-05-231-6/+6
|