src/commit.c


Log

Author Commit Date CI Message
Vicent Marti 6b2a1941 2011-03-12T23:09:16 Fix the retarded object interdependency system 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.
Vicent Marti f335b42c 2011-03-05T01:17:59 Fix segmentation fault when freeing a repository 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>
Vicent Marti 584f49a5 2011-03-01T01:37:28 Fix several issues with refcounting - 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>
Vicent Marti 86d7e1ca 2011-02-28T12:46:13 Fix searching in git_vector 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>
Vicent Marti 5de079b8 2011-02-28T12:12:26 Change the object creation/lookup API 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>
Vicent Marti 48c27f86 2011-02-28T16:51:17 Implement reference counting for git_objects 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>
John Wiegley 9217bbda 2011-02-01T05:00:52 Fixed a bug with the way commits are written
Robert G. Jakabosky 4b64c37f 2011-01-08T02:22:22 Fixed memory leak in git_commit__free().
Vicent Marti 638c2ca4 2010-12-18T02:10:25 Rename 'git_person' to 'git_signature' 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>
nulltoken 13710f1e 2010-12-10T16:30:06 Added timezone offset parsing and outputting.
Vicent Marti 4eec2c0d 2010-12-07T03:55:46 Set short message when changing a commit's message Yes, finally. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti 44908fe7 2010-12-06T23:03:16 Change the library include file 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>
Vicent Marti d12299fe 2010-12-03T22:22:10 Change include structure for the project 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>
nulltoken 6f02c3ba 2010-12-05T20:18:56 Small source code readability improvements. Replaced magic number "0" with GIT_SUCCESS constant wherever it made sense.
Vicent Marti eec95235 2010-12-02T04:58:22 Commit parents now use the common 'vector' code No more linked lists, no more O(n) access. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Justin Love eb095435 2010-11-30T21:28:39 add git_commit_parent to retrieve a parent by index
Justin Love 12114415 2010-11-30T21:01:47 add git_commit_parentcount
Colin Timmermans 69f0295c 2010-11-06T00:14:18 Fix compiler warning in commit.c
Colin Timmermans 1081d909 2010-11-05T18:04:46 Fix parsing of commits that have no newlines in the message.
Dave Borowitz 88d035bd 2010-11-04T15:08:01 Update commit_time along with committer.
Vicent Marti 1795f879 2010-11-05T03:20:17 Improve error handling 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>
Vicent Marti d80e9d55 2010-10-31T06:01:46 Fix in-memory commit getters trying to parse 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>
Vicent Marti 57450775 2010-10-29T02:44:32 Do a full parse on commits before modifying them 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>
Vicent Marti 58519018 2010-10-28T02:07:18 Fix internal memory management on the library 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>
Vicent Marti d45b4a9a 2010-09-20T21:39:11 Add support for in-memory objects 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>
Vicent Marti 0c3596f1 2010-09-20T01:57:53 Add setter methods & write support for git_commit 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>
Vicent Marti f49a2e49 2010-09-19T03:21:06 Give object structures more descriptive names 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>
Vicent Marti a7a7ddbe 2010-09-18T19:16:04 Add generic methods for object writeback 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>
Vicent Marti f2408cc2 2010-08-12T19:59:32 Fix object handling in git_repository All loaded objects through git_repository_lookup are properly parsed & free'd on failure. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti 3315782c 2010-08-08T14:12:17 Redesigned the walking/object lookup interface 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>
Vicent Marti 364788e1 2010-08-07T00:59:58 Refactor parsing methods 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>
Vicent Marti d8603ed9 2010-07-10T16:51:15 Add parsing of tree file contents. 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>
Vicent Marti 52f2390b 2010-07-07T14:56:05 Add external API to access detailed commit attributes 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>
Vicent Marti 225fe215 2010-06-18T13:06:34 Add support for tree objects in revision pools 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>
Vicent Marti 40721f6b 2010-07-10T11:50:16 Changed revpool's object table to support arbitrary objects 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>
Vicent Marti 088a731f 2010-06-09T14:54:22 Fixed memory leaks in test suite 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>
Ramsay Jones f2924934 2010-06-01T19:41:55 Style: Do not use (C99) // comments Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
Ramsay Jones b2bc567f 2010-06-01T19:40:58 Style: Fix brace placement and spacing Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
Ramsay Jones 28f98329 2010-06-01T19:37:10 Fix inconsistent definition of off_t on Linux 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>
Ramsay Jones 331578fb 2010-06-01T19:25:28 msvc: Fix a "declaration after statement" compilation error Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
Ramsay Jones ee1765e5 2010-06-01T19:32:41 Fix sparse warnings: "Using plain integer as NULL pointer" 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>
Vicent Marti de141d4b 2010-05-28T02:02:02 Improved error handling on auxilirary functions. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 6bb7aa13 2010-05-28T01:48:59 Added new error codes. Improved error handling. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 9b3577ed 2010-05-28T00:23:43 Fixed brace placement and converted spaces to tabs. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 1d1be8ee 2010-05-26T01:42:18 Fixed topological commit sorting (no longerd reversed) and commit time sorting ('prev' pointers in the linked list are no longer lost). Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 1f798df2 2010-05-25T22:59:50 Fixed topological sorting stuck in infinite loop. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 69dca959 2010-05-25T22:30:09 Fixed parsing commit times (they weren't being stored at all!) Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 655d381a 2010-05-23T16:51:31 Add topological sorting and new insertion methods for commit lists. 'git_commit_list_toposort()' and 'git_commit_list_timesort()' now sort a commit list by topological and time order respectively. Both sorts are stable and in place. 'git_commit_list_append' has been replaced by 'git_commit_list_push_back' and 'git_commit_list_push_front'. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 47c31f58 2010-05-23T16:28:32 Fixed linked list tail being lost when sorting. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 82b1db3b 2010-05-25T22:00:55 Changed commit time sorting to be descending (from newest to oldest). Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti b60488e1 2010-05-23T04:37:39 Added sort method for commit lists. Fixed bug when parsing time headers from commits. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 5e15176d 2010-05-23T02:39:57 Add commit caching on the commit table. Properly initialize the pending commits list. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti c5696427 2010-05-22T23:21:10 Add 'git_revpool_object' and 'git_revpool_table' structures. All the objects which will will be eventually transversable from a revision pool (commits, trees, etc) now inherit from the 'git_revpool_object' structure which identifies them with their own OID. Furthermore, the 'git_revpool_table' and related functions have been added, which allow for constant time lookup (hash table) of the loaded revpool objects based on their OID. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 36b7cdb6 2010-05-22T18:15:42 Changed 'git_commit_list' from a linked list to a doubly-linked list. Changed 'git_commit' to use bit fields instead of flags. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 1a895dd7 2010-05-22T14:32:59 Add arbritrary ordering revision walking. The 'gitrp_next()' method now correctly does a revision walking of all the pushed revisions in arbritary ordering. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 8add0153 2010-05-21T02:35:40 Split git_commit_lookup into separate functions. git_commit_lookup() now creates commit references without loading them from the ODB. git_commit_parse() creates a commit reference, loads it and parses it from the ODB. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 08d5d000 2010-05-18T20:55:19 Add commit parents to parsed commits and commit lists to the revpool. Basic support for iterating the revpool. The following functions of the revwalk API have been partially implemented: void gitrp_reset(git_revpool *pool); void gitrp_push(git_revpool *pool, git_commit *commit); void gitrp_prepare_walk(git_revpool *pool); git_commit *gitrp_next(git_revpool *pool); Parsed commits' parents are now also parsed and stored in a "git_commit_list" structure (linked list). Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 4caa8962 2010-05-14T18:57:50 Fixed indentation issues in commit.c Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 417f0abc 2010-05-14T18:44:49 Add basic functionality for commit lookup/parsing The external API function "git_commit_parse" has been renamed to "git_commit_lookup" and has been partially implemented with support for loading commits straight from the ODB. It still lacks the functionality to lookup cached commits in the revpool and to resolve tags to commits. The following internal functions have been partially implemented: int git_commit__parse_buffer(...); int git_commit__parse_time(...); int git_commit__parse_oid(...); Commits are now fully parsed but the generated parent and tree references are not handled yet. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 42281e00 2010-05-16T01:52:31 Add unit tests for Commit parsing A few initial tests for commit parsing: "parse_buffer_test" tests git_commit__parse_buffer() with several malformed commit messages and a few corner cases which should pass. "parse_oid_test" tests git_commit__parse_oid() with several malformed commit lines containing broken SHA1 OIDs. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Shawn O. Pearce 64a47c01 2008-12-30T23:21:36 Wrap malloc and friends and report out of memory as GIT_ENOMEM We now forbid direct use of malloc, strdup or calloc within the library and instead use wrapper functions git__malloc, etc. to invoke the underlying library malloc and set git_errno to a no memory error code if the allocation fails. In the future once we have pack objects in memory we are likely to enhance these routines with garbage collection logic to purge cached pack data when allocations fail. Because the size of the function will grow somewhat large, we don't want to mark them for inline as gcc tends to aggressively inline, creating larger than expected executables. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Andreas Ericsson 4f0adcd0 2008-11-18T21:28:55 Get rid of GIT__PRIVATE macro Using it in the first place means something's wrong. This patch replaces it with an internal header which carries the previously "protected" code instead. Internal source-files simply include "commit.h" and they're done. The internal header includes the public one to make sure we always use the proper prototype. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce 50298f44 2008-11-01T15:55:01 Switch the license from BSD to GPL+libgcc exception Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce d1ea30c3 2008-11-01T15:42:23 Move include files to include/git/, drop git_ prefix from file names Signed-off-by: Shawn O. Pearce <spearce@spearce.org>