summaryrefslogtreecommitdiff
path: root/src/git
Commit message (Collapse)AuthorAgeFilesLines
* Change the library include fileVicent Marti2010-12-0616-1694/+0
| | | | | | | | | | | | 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-0615-180/+227
| | | | | | | | | | | 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>
* Decouple storage from ODB logicVicent Marti2010-12-061-57/+72
| | | | | | Comes with two default backends: loose object and packfiles. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add 'git_repository_open2' to customize repo foldersVicent Marti2010-12-021-1/+34
| | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Commit parents now use the common 'vector' codeVicent Marti2010-12-021-1/+2
| | | | | | 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/+8
|
* add git_commit_parentcountJustin Love2010-11-301-0/+8
|
* Make the bitmasks for Index Entry flags publicVicent Marti2010-11-291-0/+6
| | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Do proper symbol exports on MSVCVicent Marti2010-11-241-0/+2
| | | | | | | | | Yes, if you are wondering why the shared library was failing to build under MSVC, it's because it was empty. Oh wow. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Do not use STDINT types in public headersVicent Marti2010-11-241-11/+10
| | | | | | Old versions of MSVC don't have such types available. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Change blob API to return temp refs to the contentVicent Marti2010-11-201-8/+7
| | | | | | | If the user wants permanent references, he can duplicate the temporary one manually. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add support for 'index add'Vicent Marti2010-11-162-14/+28
| | | | | | | | Actually add files to the index by creating their corresponding blob and storing it on the repository, then getting the hash and updating the index file. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add support for blob filesVicent Marti2010-11-161-0/+100
| | | | | | | Blob files can now be loaded from the repository like all the other base Git types. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* accessor for index entry countScott Chacon2010-11-111-0/+8
|
* Make the Index API publicVicent Marti2010-11-071-2/+20
| | | | | | | | | | | Several private methods of the Index API are now public, including the methods to remove, get and add index entries. All the methods only take an integer value for the position of the entry to get/remove. To get or remove entries based on their path names, look them up first using the git_index_find method. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Improve error handlingVicent Marti2010-11-057-26/+56
| | | | | | | | 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>
* Change git_repository initialization to use a pathVicent Marti2010-11-022-7/+76
| | | | | | | | | | | | The constructor to git_repository is now called 'git_repository_open(path)' and takes a path to a git repository instead of an existing ODB object. Unit tests have been updated accordingly and the two test repositories have been merged into one. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add getter methods for object ownersVicent Marti2010-10-292-3/+20
| | | | | | | 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 git_odb_read_header method to the ODBVicent Marti2010-10-291-0/+19
| | | | | | | | | | | As requested, git_odb_read_header looks up an object on the ODB, but loads only the header information (type & size) without loading any of the actual file contents in memory. It is significantly faster than doing a git_odb_read if you only need an object's information and not its contents. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix internal memory management on the libraryVicent Marti2010-10-283-11/+19
| | | | | | | | | | | | | | | | | | | | 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>
* Change /* to /** at the start of comment blocks in public api so doxygenBenjamin C Meyer2010-10-255-11/+11
| | | | | | will generate documenation and not hide them. Signed-off-by: Benjamin C Meyer <ben@meyerhome.net>
* Fix spelling mistakes in the documentation.Benjamin C Meyer2010-10-256-8/+8
| | | | Signed-off-by: Benjamin C Meyer <ben@meyerhome.net>
* Remove whitespace from the end of the line in documentation.Benjamin C Meyer2010-10-254-13/+13
| | | | Signed-off-by: Benjamin C Meyer <ben@meyerhome.net>
* Fix issue 3 (memory corruption resize_tree_array)Vicent Marti2010-10-081-1/+2
| | | | | | | | | The tree array wasn't being initialized when instantiating a tree object in memory instead of loading it from disk. New unit tests added to check for the problem. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add write-back support for Tag filesVicent Marti2010-10-071-0/+28
| | | | | | | | Tag files can now be created and modified in-memory (all the setter methods have been implemented), and written back to disk using the generic git_object_write() method. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add write-back support for git_treeVicent Marti2010-09-211-6/+78
| | | | | | | | | | | All the setter methods for git_tree have been added, including the setters for attributes on each git_tree_entry and methods to add/remove entries of the tree. Modified trees and trees created in-memory from scratch can be written back to the repository using git_object_write(). Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add support for in-memory objectsVicent Marti2010-09-204-0/+80
| | | | | | | | | | | 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-0/+35
| | | | | | | | | | | 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-195-16/+16
| | | | | | | | | | 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 methods to access internal attributes in git_repoVicent Marti2010-09-121-0/+23
| | | | | | | | | | Added several methods to access: - The ODB behind a repo - The SHA1 id behind a generic repo object - The type of a generic repo object Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix: do not export custom types in the extern APIVicent Marti2010-09-091-1/+1
| | | | | | | Some compilers give linking problems when exporting 'uint32_t' as a return type in the external API. Use generic types instead. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add support for manually freeing repo objectsVicent Marti2010-08-121-0/+15
| | | | | | | | A new method 'git_repository_object_free' allows to manually force the freeing of a repository object, even though they are still automatically managed by the repository and don't need to be freed by the user. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Finish the tree object APIVicent Marti2010-08-121-0/+56
| | | | | | | | | | The interface for loading and parsing tree objects from a repository has been completed with all the required accesor methods for attributes, support for manipulating individual tree entries and a new unit test t0901-readtree which tries to load and parse a tree object from a repository. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add support for git index filesVicent Marti2010-08-121-0/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new 'git_index' structure is an in-memory representation of a git index on disk; the 'git_index_entry' structures represent each one of the file entries on the index. The following calls for index instantiation have been added: git_index_alloc(): instantiate a new index structure git_index_free(): free an existing index git_index_clear(): clear all the entires in an existing file The following calls for index reading and writing have been added: git_index_read(): update the contents of the index structure from its file on disk. Internally implemented through: git_index__parse() Index files are stored on disk in network byte order; all integer fields inside them are properly converted to the machine's byte order when loading them in memory. The parsing engine also distinguishes between normal index entries and extended entries with 2 extra bytes of flags. The 'TREE' extension for index entries is also loaded into memory: Tree caches stored in Index files are loaded into the 'git_index_tree' structure pointed by the 'tree' pointer inside 'git_index'. 'index->tree' points to the root node of the tree cache; the full tree can be traversed through each of the node's 'tree->children'. Index files can be written back to disk through: git_index_write(): atomic writing of existing index objects backed by internal method git_index__write() The following calls for entry manipulation have been added: git_index_add(): insert an empty entry to the index git_index_find(): search an entry by its path name git_index__append(): appends a new index entry to the end of the list, resizing the entries array if required New index entries are always inserted at the end of the array; since the index entries must be sorted for it to be internally consistent, the index object is only sorted once, and if required, before accessing the whole entriea array (e.g. before writing to disk, before traversing, etc). git_index__remove_pos(): remove an index entry in a specific position git_index__sort(): sort the entries in the array by path name The entries array is sorted stably and in place using an insertion sort, which ought to be the most efficient approach since the entries array is always mostly-sorted. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Redesigned the walking/object lookup interfaceVicent Marti2010-08-127-88/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 loading and parsing of tag objectsVicent Marti2010-08-121-0/+89
| | | | | | | | Tag objects are now properly loaded from the revision pool. New test t0801 checks for loading a parsing a series of tags, including the tag of a tag. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Refactor parsing methodsVicent Marti2010-08-072-9/+9
| | | | | | | | | | 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/+12
| | | | | | | 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-1/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+39
| | | | | | | | | | 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>
* Fixed memory leaks in test suiteVicent Marti2010-07-101-0/+6
| | | | | | | | | | 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>
* Fix a doxygen warningRamsay Jones2010-06-021-0/+1
| | | | | | | | | | | | In particular, doxygen issues the following warning: .../src/git/revwalk.h:86: Warning: The following parameters of \ gitrp_sorting(git_revpool *pool, unsigned int sort_mode) are \ not documented: parameter 'pool' Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Added new error codes. Improved error handling.Vicent Marti2010-06-022-2/+8
| | | | | 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-0/+36
| | | | | | | | | 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>
* Removed 'git_commit_uninteresting' from the public API.Vicent Marti2010-06-021-8/+0
| | | | | 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-0/+8
| | | | | | | | 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-2/+12
| | | | | | | | | | | 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 basic functionality for commit lookup/parsingVicent Marti2010-06-021-2/+2
| | | | | | | | | | | | | | | | | | | | 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>
* Fixed typos in the revwalk API documentationVicent Marti2010-06-021-2/+2
| | | | | Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Fix some coding style issuesRamsay Jones2010-02-284-11/+10
| | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>