summaryrefslogtreecommitdiff
path: root/src/object.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* I broke your bindingsVicent Marti2011-03-201-253/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hey. Apologies in advance -- I broke your bindings. This is a major commit that includes a long-overdue redesign of the whole object-database structure. This is expected to be the last major external API redesign of the library until the first non-alpha release. Please get your bindings up to date with these changes. They will be included in the next minor release. Sorry again! Major features include: - Real caching and refcounting on parsed objects - Real caching and refcounting on objects read from the ODB - Streaming writes & reads from the ODB - Single-method writes for all object types - The external API is now partially thread-safe The speed increases are significant in all aspects, specially when reading an object several times from the ODB (revwalking) and when writing big objects to the ODB. Here's a full changelog for the external API: blob.h ------ - Remove `git_blob_new` - Remove `git_blob_set_rawcontent` - Remove `git_blob_set_rawcontent_fromfile` - Rename `git_blob_writefile` -> `git_blob_create_fromfile` - Change `git_blob_create_fromfile`: The `path` argument is now relative to the repository's working dir - Add `git_blob_create_frombuffer` commit.h -------- - Remove `git_commit_new` - Remove `git_commit_add_parent` - Remove `git_commit_set_message` - Remove `git_commit_set_committer` - Remove `git_commit_set_author` - Remove `git_commit_set_tree` - Add `git_commit_create` - Add `git_commit_create_v` - Add `git_commit_create_o` - Add `git_commit_create_ov` tag.h ----- - Remove `git_tag_new` - Remove `git_tag_set_target` - Remove `git_tag_set_name` - Remove `git_tag_set_tagger` - Remove `git_tag_set_message` - Add `git_tag_create` - Add `git_tag_create_o` tree.h ------ - Change `git_tree_entry_2object`: New signature is `(git_object **object_out, git_repository *repo, git_tree_entry *entry)` - Remove `git_tree_new` - Remove `git_tree_add_entry` - Remove `git_tree_remove_entry_byindex` - Remove `git_tree_remove_entry_byname` - Remove `git_tree_clearentries` - Remove `git_tree_entry_set_id` - Remove `git_tree_entry_set_name` - Remove `git_tree_entry_set_attributes` object.h ------------ - Remove `git_object_new - Remove `git_object_write` - Change `git_object_close`: This method is now *mandatory*. Not closing an object causes a memory leak. odb.h ----- - Remove type `git_rawobj` - Remove `git_rawobj_close` - Rename `git_rawobj_hash` -> `git_odb_hash` - Change `git_odb_hash`: New signature is `(git_oid *id, const void *data, size_t len, git_otype type)` - Add type `git_odb_object` - Add `git_odb_object_close` - Change `git_odb_read`: New signature is `(git_odb_object **out, git_odb *db, const git_oid *id)` - Change `git_odb_read_header`: New signature is `(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id)` - Remove `git_odb_write` - Add `git_odb_open_wstream` - Add `git_odb_open_rstream` odb_backend.h ------------- - Change type `git_odb_backend`: New internal signatures are as follows int (* read)(void **, size_t *, git_otype *, struct git_odb_backend *, const git_oid *) int (* read_header)(size_t *, git_otype *, struct git_odb_backend *, const git_oid *) int (* writestream)(struct git_odb_stream **, struct git_odb_backend *, size_t, git_otype) int (* readstream)( struct git_odb_stream **, struct git_odb_backend *, const git_oid *) - Add type `git_odb_stream` - Add enum `git_odb_streammode` Signed-off-by: Vicent Marti <tanoku@gmail.com>
* git_object_lookup() should also check the type if the object comes from the ↵Ben Noordhuis2011-03-151-0/+3
| | | | cache
* Fix the retarded object interdependency systemVicent Marti2011-03-141-13/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's no longer retarded. All object interdependencies are stored as OIDs instead of actual objects. This should be hundreds of times faster, specially on big repositories. Heck, who knows, maye it doesn't even segfault -- wouldn't that be awesome? What has changed on the API? `git_commit_parent`, `git_commit_tree`, `git_tag_target` now return their values through a pointer-to-pointer, and have an error code. `git_commit_set_tree` and `git_tag_set_target` now return an error code and may fail. `git_repository_free__no_gc` has been deprecated because it's stupid. Since there are no longer any interdependencies between objects, we don't need internal reference counting, and GC never fails or double-free's pointers. `git_object_close` now does a very sane thing: marks an object as unused. Closed objects will be eventually free'd from the object cache based on LRU. Please use `git_object_close` from the garbage collector `destroy` method on your bindings. It's 100% safe. `git_repository_gc` is a new method that forces a garbage collector pass through the repo, to free as many LRU objects as possible. This is useful if we are running out of memory.