summaryrefslogtreecommitdiff
path: root/src/revwalk.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Make more methods return error codesVicent Marti2011-02-051-5/+9
| | | | | | | | git_revwalk_next now returns an error code when the iteration is over. git_repository_index now returns an error code when the index file could not be opened. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Merge branch 'timezone'Vicent Marti2010-12-181-2/+2
|\
| * Rename 'git_person' to 'git_signature'Vicent Marti2010-12-181-2/+2
| | | | | | | | | | | | | | 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>
* | Fix initialization & freeing of inexistent reposVicent Marti2010-12-131-0/+12
|/ | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Commit parents now use the common 'vector' codeVicent Marti2010-12-021-4/+7
| | | | | | No more linked lists, no more O(n) access. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Improve error handlingVicent Marti2010-11-051-14/+16
| | | | | | | | 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>
* Add getter methods for object ownersVicent Marti2010-10-291-0/+6
| | | | | | | You can know access the owning repository of any existing object, or the repository on which a revision walker is working on. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add setter methods & write support for git_commitVicent Marti2010-09-201-7/+0
| | | | | | | | | | | 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>
* Redesigned the walking/object lookup interfaceVicent Marti2010-08-121-107/+337
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add external API to access detailed commit attributesVicent Marti2010-07-151-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+3
| | | | | | | | | | 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-9/+21
| | | | | | | | | | | | 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-0/+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>
* Actually free all commits when freeing a commit poolVicent Marti2010-07-101-0/+9
| | | | | | | | | Previously the objects table was being freed, but not the actuall commits. All git_commit objects are freed and hence invalidated when freeing the git_rp object they belong to. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Style: Do not use (C99) // commentsRamsay Jones2010-06-021-4/+6
| | | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Improved error handling on auxilirary functions.Vicent Marti2010-06-021-4/+6
| | | | | Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Added new error codes. Improved error handling.Vicent Marti2010-06-021-14/+26
| | | | | Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Fixed brace placement and converted spaces to tabs.Vicent Marti2010-06-021-74/+70
| | | | | Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Fixed parsing commit times (they weren't being stored at all!)Vicent Marti2010-06-021-2/+2
| | | | | Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Add external API for revision sorting.Vicent Marti2010-06-021-6/+18
| | | | | | | | | The GIT_RPSORT_XXX flags have been moved to the external API, and a new method 'gitrp_sorting(...)' has been added to safely change the sorting method of a revision pool. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Properly reset all commit properties when doing a gitrp_reset().Vicent Marti2010-06-021-0/+12
| | | | | | | Add git_revpool_table_free() method. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Add topological sorting and new insertion methods for commit lists.Vicent Marti2010-06-021-3/+10
| | | | | | | | | | | | '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>
* Add object cache to the revision pool.Vicent Marti2010-06-021-26/+16
| | | | | | | | | | | Fixed issue when generating pending commits list during iteration. The 'git_commit_lookup' function will now check the pool's cache for commits which have been previously loaded/parsed; there can only be a single 'git_commit' structure for each commit on the same pool. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Add commit caching on the commit table.Vicent Marti2010-06-021-20/+38
| | | | | | | Properly initialize the pending commits list. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Add 'git_revpool_object' and 'git_revpool_table' structures.Vicent Marti2010-06-021-1/+1
| | | | | | | | | | | | | | 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>
* Changed 'git_commit_list' from a linked list to a doubly-linked list.Vicent Marti2010-06-021-36/+24
| | | | | | | 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>
* Add arbritrary ordering revision walking.Vicent Marti2010-06-021-11/+51
| | | | | | | | 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>
* Split git_commit_lookup into separate functions.Vicent Marti2010-06-021-7/+18
| | | | | | | | | | | 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>
* Add commit parents to parsed commits and commit lists to the revpool.Vicent Marti2010-06-021-0/+54
| | | | | | | | | | | | | | | | | | 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>
* Wrap malloc and friends and report out of memory as GIT_ENOMEMShawn O. Pearce2008-12-301-1/+2
| | | | | | | | | | | | | | | | 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>
* Rename git_revpool_* functions gitrp_*Andreas Ericsson2008-11-221-8/+3
| | | | | | | | | | Otherwise their prototypes don't match their declarations. Detected by 'sparse', which is obviously good to run before each commit. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* s/git_revp/git_revpool/Andreas Ericsson2008-11-181-4/+4
| | | | | | | | | | | | | | | | | | | git_revp is something I personally can't stop pronouncing "rev pointer". I'm sure others would suffer the same problem. Also, rename the git_revp_ sub-api "gitrp_". This is the first of many such renames, primarily done to prevent extreme inflation in the "git_" namespace, which we'd like to reserve for a higher-level API. While we're at it, we remove the noise-char "c" from a lot of functions. Since revision walking is all about commits, the common case should be that we're dealing with commits. Exceptions can get a more mnemonic description as needed. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Switch the license from BSD to GPL+libgcc exceptionShawn O. Pearce2008-11-011-29/+19
| | | | Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Move include files to include/git/, drop git_ prefix from file namesShawn O. Pearce2008-11-011-0/+56
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>