summaryrefslogtreecommitdiff
path: root/src/commit.c
Commit message (Collapse)AuthorAgeFilesLines
...
* commit: Reword errorsVicent Marti2011-05-231-9/+4
|
* commit.c: Move to new error handling mechanismJakob Pfender2011-05-231-7/+18
|
* Fix two warnings from ClangCarlos Martín Nieto2011-05-061-1/+1
| | | | | | Both are about not reading the value stored in a variable. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* commit: support a root commitsCarlos Martín Nieto2011-04-291-2/+11
| | | | | | | | | | | | A root commit is a commit whose branch (usually what HEAD points to) doesn't exist (yet). This situation can happen when the commit is the first after 1) a repository is initialized or 2) a orphan checkout has been performed. Take this opportunity to remove the symbolic link check, as git_reference_resolve works on OID refs as well. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* Added git_commit_tree_oid and git_commit_parent_oid.Sam2011-04-081-0/+6
|
* Change `parse` methods to const bufferVicent Marti2011-04-021-2/+2
| | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Switch from time_t to git_time_tnulltoken2011-03-231-1/+1
| | | | git_time_t is defined as a signed 64 integer. This allows a true predictable multiplatform behavior.
* Fix MSVC warningsVicent Marti2011-03-211-3/+3
|
* I broke your bindingsVicent Marti2011-03-201-113/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix headers for the new Revision WalkerVicent Marti2011-03-161-1/+0
| | | | | | The "oid.h" header is now included instead of "object.h". The old "revwalk.h" header has been removed; it was empty.
* Fix the retarded object interdependency systemVicent Marti2011-03-141-130/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix segmentation fault when freeing a repositoryVicent Marti2011-03-051-8/+8
| | | | | | | | Disable garbage collection of cross-references to prevent double-freeing. Internal reference management is now done with a separate method. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix several issues with refcountingVicent Marti2011-03-031-8/+19
| | | | | | | - Added several missing reference increases - Add new destructor to the repository that does not GC the objects Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Implement reference counting for git_objectsVicent Marti2011-03-031-1/+21
| | | | | | | | All `git_object` instances looked up from the repository are reference counted. User is expected to use the new `git_object_close` when an object is no longer needed to force freeing it. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix searching in git_vectorVicent Marti2011-03-031-1/+1
| | | | | | | | | | | | | | | | | | We now store only one sorting callback that does entry comparison. This is used when sorting the entries using a quicksort, and when looking for a specific entry with the new search methods. The following search methods now exist: git_vector_search(vector, entry) git_vector_search2(vector, custom_search_callback, key) git_vector_bsearch(vector, entry) git_vector_bsearch2(vector, custom_search_callback, key) The sorting state of the vector is now stored internally. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Change the object creation/lookup APIVicent Marti2011-03-031-2/+2
| | | | | | | | | | | | | | | | | | The methods previously known as git_repository_lookup git_repository_newobject git_repository_lookup_ref are now part of their respective namespaces: git_object_lookup git_object_new git_reference_lookup This makes the API more consistent with the new references API. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fixed a bug with the way commits are writtenJohn Wiegley2011-02-011-2/+4
|
* Fixed memory leak in git_commit__free().Robert G. Jakabosky2011-01-081-0/+1
|
* Rename 'git_person' to 'git_signature'Vicent Marti2010-12-181-44/+27
| | | | | | | The new signature struct is public, and contains information about the timezone offset. Must be free'd manually by the user. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Added timezone offset parsing and outputting.nulltoken2010-12-101-4/+18
|
* Set short message when changing a commit's messagev0.2.0Vicent Marti2010-12-071-3/+13
| | | | | | Yes, finally. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Change the library include fileVicent Marti2010-12-061-3/+3
| | | | | | | | | | | | Libgit2 is now officially include as #include "<git2.h>" or indidividual files may be included as #include <git2/index.h> Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Change include structure for the projectVicent Marti2010-12-061-1/+1
| | | | | | | | | | | The maze with include dependencies has been fixed. There is now a global include: #include <git.h> The git_odb_backend API has been exposed. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Small source code readability improvements.nulltoken2010-12-051-9/+9
| | | | Replaced magic number "0" with GIT_SUCCESS constant wherever it made sense.
* Commit parents now use the common 'vector' codeVicent Marti2010-12-021-53/+20
| | | | | | No more linked lists, no more O(n) access. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* add git_commit_parent to retrieve a parent by indexJustin Love2010-11-301-0/+14
|
* add git_commit_parentcountJustin Love2010-11-301-0/+15
|
* Fix compiler warning in commit.cColin Timmermans2010-11-071-1/+1
|
* Fix parsing of commits that have no newlines in the message.Colin Timmermans2010-11-071-3/+4
|
* Update commit_time along with committer.Dave Borowitz2010-11-051-2/+1
|
* Improve error handlingVicent Marti2010-11-051-26/+17
| | | | | | | | All initialization functions now return error codes instead of pointers. Error codes are now properly propagated on most functions. Several new and more specific error codes have been added in common.h Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix in-memory commit getters trying to parseVicent Marti2010-10-311-2/+5
| | | | | | | | | | Issue 9 on the tracker. The commit object getters for in-memory objects were trying to parse an inexistant on-disk object when one of the commit attributes which were still not set was queried. We now return a NULL value when this happens. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Do a full parse on commits before modifying themVicent Marti2010-10-291-0/+12
| | | | | | | Before changing the attributes of a commit, make sure that the internal status is consistent with the one in the repository. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix internal memory management on the libraryVicent Marti2010-10-281-164/+68
| | | | | | | | | | | | | | | | | | | | String mememory is now managed in a much more sane manner. Fixes include: - git_person email and name is no longer limited to 64 characters - git_tree_entry filename is no longer limited to 255 characters - raw objects are properly opened & closed the minimum amount of times required for parsing - unit tests no longer leak - removed 5 other misc memory leaks as reported by Valgrind - tree writeback no longer segfaults on rare ocassions The git_person struct is no longer public. It is now managed by the library, and getter methods are in place to access its internal attributes. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add support for in-memory objectsVicent Marti2010-09-201-1/+6
| | | | | | | | | | | All repository objects can now be created from scratch in memory using either the git_object_new() method, or the corresponding git_XXX_new() for each object. So far, only git_commits can be written back to disk once created in memory. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add setter methods & write support for git_commitVicent Marti2010-09-201-69/+139
| | | | | | | | | | | All the required git_commit_set_XXX methods have been implemented; all the attributes of a commit object can now be modified in-memory. The new method git_object_write() automatically writes back the in-memory changes of any object to the repository. So far it only supports git_commit objects. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Give object structures more descriptive namesVicent Marti2010-09-191-3/+3
| | | | | | | | | | The 'git_obj' structure is now called 'git_rawobj', since it represents a raw object read from the ODB. The 'git_repository_object' structure is now called 'git_object', since it's the base object class for all objects. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add generic methods for object writebackVicent Marti2010-09-181-2/+2
| | | | | | | | | | | | | | | | git_repository_object has now several internal methods to write back the object information in the repository. - git_repository__dbo_prepare_write() Prepares the DBO object to be modified - git_repository__dbo_write() Writes new bytes to the DBO object - git_repository__dbo_writeback() Writes back the changes to the repository Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix object handling in git_repositoryVicent Marti2010-08-121-20/+5
| | | | | | | All loaded objects through git_repository_lookup are properly parsed & free'd on failure. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Redesigned the walking/object lookup interfaceVicent Marti2010-08-121-267/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old 'git_revpool' object has been removed and split into two distinct objects with separate functionality, in order to have separate methods for object management and object walking. * A new object 'git_repository' does the high-level management of a repository's objects (commits, trees, tags, etc) on top of a 'git_odb'. Eventually, it will also manage other repository attributes (e.g. tag resolution, references, etc). See: src/git/repository.h * A new external method 'git_repository_lookup(repo, oid, type)' has been added to the 'git_repository' API. All object lookups (git_XXX_lookup()) are now wrappers to this method, and duplicated code has been removed. The method does automatic type checking and returns a generic 'git_revpool_object' that can be cast to any specific object. See: src/git/repository.h * The external methods for object parsing of repository objects (git_XXX_parse()) have been removed. Loading objects from the repository is now managed through the 'lookup' functions. These objects are loaded with minimal information, and the relevant parsing is done automatically when the user requests any of the parsed attributes through accessor methods. An attribute has been added to 'git_repository' in order to force the parsing of all the repository objects immediately after lookup. See: src/git/commit.h See: src/git/tag.h See: src/git/tree.h * The previous walking functionality of the revpool is now found in 'git_revwalk', which does the actual revision walking on a repository; the attributes when walking through commits in a database have been decoupled from the actual commit objects. This increases performance when accessing commits during the walk and allows to have several 'git_revwalk' instances working at the same time on top of the same repository, without having to load commits in memory several times. See: src/git/revwalk.h * The old 'git_revpool_table' has been renamed to 'git_hashtable' and now works as a generic hashtable with support for any kind of object and custom hash functions. See: src/hashtable.h * All the relevant unit tests have been updated, renamed and grouped accordingly. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Refactor parsing methodsVicent Marti2010-08-071-13/+13
| | | | | | | | | | The 'parse_oid' and 'parse_person' methods which were used by the commit parser are now global so they can be used when parsing other objects. The 'git_commit_person' struct has been changed to a generic 'git_person'. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add parsing of tree file contents.Vicent Marti2010-07-151-0/+1
| | | | | | | The basic information (pointed trees and blobs) of each tree object in a revision pool can now be parsed and queried. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add external API to access detailed commit attributesVicent Marti2010-07-151-37/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following new external methods have been added: GIT_EXTERN(const char *) git_commit_message_short(git_commit *commit); GIT_EXTERN(const char *) git_commit_message(git_commit *commit); GIT_EXTERN(time_t) git_commit_time(git_commit *commit); GIT_EXTERN(const git_commit_person *) git_commit_committer(git_commit *commit); GIT_EXTERN(const git_commit_person *) git_commit_author(git_commit *commit); GIT_EXTERN(const git_tree *) git_commit_tree(git_commit *commit); A new structure, git_commit_person has been added to represent a commit's author or committer. The parsing of a commit has been split in two phases. When adding a commit to the revision pool: - the commit's ODB object is opened - its raw contents are parsed for commit TIME, PARENTS and TREE (the minimal amount of data required to traverse the pool) - the commit's ODB object is closed When querying for extended information on a commit: - the commit's ODB object is reopened - its raw contents are parsed for the requested information - the commit's ODB object remains open to handle additional queries New unit tests have been added for the new functionality: In t0401-parse: parse_person_test In t0402-details: query_details_test Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add support for tree objects in revision poolsVicent Marti2010-07-151-1/+2
| | | | | | | | | | Commits now store pointers to their tree objects. Tree objects now work as separate git_revpool_object entities. Tree objects can be loaded and parsed inedependently from commits. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Changed revpool's object table to support arbitrary objectsVicent Marti2010-07-151-2/+9
| | | | | | | | | | | | git_revpool_object now has a type identifier for each object type in a revpool (commits, trees, blobs, etc). Trees can now be stored in the revision pool. git_revpool_tableit now supports filtering objects by their type when iterating through the object table. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fixed memory leaks in test suiteVicent Marti2010-07-101-1/+1
| | | | | | | | | | Created commit objects in t0401-parse weren't being freed properly. Updated the API documentation to note that commit objects are owned by the revision pool and should not be freed manually. The parents list of each commit was being freed twice after each test. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Style: Do not use (C99) // commentsRamsay Jones2010-06-021-2/+2
| | | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Style: Fix brace placement and spacingRamsay Jones2010-06-021-2/+1
| | | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Fix inconsistent definition of off_t on LinuxRamsay Jones2010-06-021-2/+0
| | | | | | | | | | | | | | | | | | | | | | | In order to avoid inconsistent definitions of type off_t, all compilation units should include the "common.h" header file before certain system headers (those which directly or indirectly lead to the definition of off_t). The "common.h" header contains the definition of _FILE_OFFSET_BITS to select 64-bit file offsets. The symptom of this inconsistency, while compiling with -Wextra, is the following warning: In file included from src/common.h:50, from src/commit.c:28: src/util.h: In function git__is_sizet: src/util.h:41: warning: comparison between signed and unsigned In order to fix the problem, we simply remove the #include <time.h> statement at the head of src/commit.c. Note that src/commit.h also includes <time.h>. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Fix sparse warnings: "Using plain integer as NULL pointer"Ramsay Jones2010-06-021-3/+3
| | | | | | | | | In order to suppress this warning, we could simply replace the constant 0 with NULL. However, in this case, replacing the comparison with 0 by !buffer is more idiomatic. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>