summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix MSVC warnings and errorsVicent Marti2010-11-241-1/+1
| | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix memory leak in t0401Vicent Marti2010-11-161-0/+4
| | | | | | | Commit object must be internally free'd after each parse attempt, even it fails. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add support for 'index add'Vicent Marti2010-11-163-8/+8
| | | | | | | | 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>
* Fix parsing of commits that have no newlines in the message.Colin Timmermans2010-11-071-2/+20
|
* Update commit_time along with committer.Dave Borowitz2010-11-051-0/+1
|
* Test that commit attributes are set correctly.Dave Borowitz2010-11-051-4/+21
|
* Add string descriptions for all error codesVicent Marti2010-11-051-1/+0
| | | | | | | Old descriptions have been updated and new ones have been added for the 'git_strerror' function. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Improve error handlingVicent Marti2010-11-0511-69/+36
| | | | | | | | 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-0245-102/+42
| | | | | | | | | | | | 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 unit tests for git_odb_read_headerVicent Marti2010-10-291-0/+210
| | | | | | | Test the new method by loading all the objects in the sample ODB with a full-read and a header-only read, and comparing the types and sizes. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix internal memory management on the libraryVicent Marti2010-10-284-13/+29
| | | | | | | | | | | | | | | | | | | | 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>
* msvc: Fix an "conversion, possible loss of data" warningRamsay Jones2010-10-271-1/+1
| | | | | | | | | | | | | | In particular, msvc complains thus: t0603-sort.c(23) : warning C4244: 'function' : conversion from \ 'time_t' to 'unsigned int', possible loss of data Note that msvc, by default, defines time_t as a 64-bit type, whereas srand() is expecting an (32-bit) unsigned int. In order to suppress the warning, we simply cast the return value of the time() function call to 'unsigned int'. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
* Fix issue 3 (memory corruption resize_tree_array)Vicent Marti2010-10-081-0/+33
| | | | | | | | | 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 unit tests for object write-backVicent Marti2010-10-075-0/+272
| | | | | | | | | | Basic write-back & in-memory editing for objects is now tested in t0403 (commits), t0802 (tags) and t0902 (trees). Add new helper functions in test_helpers.c to remove the loose objects created when doing write-back tests. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix possible segfaults in src/tree.c (issue 1)Vicent Marti2010-10-071-2/+28
| | | | | | | | | git_tree_entry_byname was dereferencing a NULL pointer when the searched file couldn't be found on the tree. New test cases have been added to check for entry access methods. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add write-back support for git_treeVicent Marti2010-09-211-1/+2
| | | | | | | | | | | 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 setter methods & write support for git_commitVicent Marti2010-09-201-14/+12
| | | | | | | | | | | 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-197-40/+40
| | | | | | | | | | 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>
* Finish the tree object APIVicent Marti2010-08-121-0/+42
| | | | | | | | | | 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 unit tests for index manipulationVicent Marti2010-08-123-0/+229
| | | | | | | | | | | | | | | | | | | Three new unit tests, t06XX files have been added. t0601-read: tests for loading index files from disk, for creating in-memory indexes and for accessing index entries. t0602-write: tests for writing index files back to disk t0603-sort: tests for properly sorting the entries array of an index Two test indexes have been added in 'tests/resources/': test/resources/index: a sample index from a libgit2 repository test/resources/gitgit.index: a sample index from a git.git repository (includes TREE extension data) Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Move test resources to a common directoryVicent Marti2010-08-1225-2/+2
| | | | | | | All the external resources used by the tests are now placed inside the common 'tests/resources' directory. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Redesigned the walking/object lookup interfaceVicent Marti2010-08-128-182/+292
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-123-0/+50
| | | | | | | | 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-7/+7
| | | | | | | | | | 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 packfile readingVicent Marti2010-08-066-0/+156
| | | | | | | | | | | Packed objects inside packfiles are now properly unpacked when calling the git_odb__read_packed() method; delta'ed objects are also properly generated when needed. A new unit test 0204-readpack tries to read a couple hundred packed objects from a standard packed repository. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Changed test files to use tabs instead of spacesVicent Marti2010-07-153-98/+98
| | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add external API to access detailed commit attributesVicent Marti2010-07-152-79/+225
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 new tests: t0502-table, t0503-tableitVicent Marti2010-07-152-0/+170
| | | | | | | | | | | | | "t0502-table" tests for basic functionality of the objects table: table_create (creating a new object table) table_populate (fill & lookup on the object table) table_resize (dynamically resize the table) "t0503-tableit" tests the iterator for object tables: table_iterator (make sure the iterator reaches all objects) Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fixed memory leaks in test suiteVicent Marti2010-07-101-0/+4
| | | | | | | | | | 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>
* msvc: Disable a level 4 warning and change -W3 to -W4Ramsay Jones2010-06-071-1/+1
| | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
* Makefile(s): Add -Wextra to CFLAGSRamsay Jones2010-06-071-1/+1
| | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
* Fix a bug in the git_oid_to_string() functionRamsay Jones2010-06-071-0/+25
| | | | | | | | | When git_oid_to_string() was passed a buffer size larger than GIT_OID_HEXSZ+1, the function placed the c-string NUL char at the wrong position. Fix the code to place the NUL at the end of the (possibly truncated) oid string. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
* Style: Do not use (C99) // commentsRamsay Jones2010-06-023-23/+25
| | | | | 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-022-10/+6
| | | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
* msvc: tests/t0403-lists.c: Fix a compiler warningRamsay Jones2010-06-021-1/+1
| | | | | | | | | For more recent versions of msvc, the time_t type, as returned by the time() function, is a 64-bit type. The srand() function, however, expects an 'unsigned int' input parameter, leading to the warning. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Added t0501-walk (simple test for all revision pool walking modes)Vicent Marti2010-06-0222-0/+92
| | | | | Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Changed commit time sorting to be descending (from newest to oldest).Vicent Marti2010-06-021-2/+2
| | | | | 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-6/+6
| | | | | | | | | | | | '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>
* Updated t0401 (commit parsing) to reflect the new API changes.Vicent Marti2010-06-021-4/+9
| | | | | Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Add unit tests for list sorting.Vicent Marti2010-06-021-0/+60
| | | | | Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
* Add unit tests for Commit parsingVicent Marti2010-06-022-0/+165
| | | | | | | | | | | | | | 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>
* Add support to enable the library to use OpenSSL SHA1 functionsRamsay Jones2010-05-041-0/+4
| | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
* Makefile(s): Don't include the OpenSSL crypto library in the linkRamsay Jones2010-04-281-4/+0
| | | | | | Also, fully purge the NO_OPENSSL build variable. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
* win32: Remove wsock32 from the list of libraries to linkRamsay Jones2010-04-281-2/+2
| | | | | | | | | | | | | | | | Commit 5dddf7c (Add block-sha1 in favour of the mozilla routines 2010-04-14) introduced the "bswap.h" header file which, for x86 or x86-64 machines, provides a "sane" implementation of ntohl() and htonl(). The wsock32 library, on the msvc and MinGW build, is only included in the link to supply the ntohl()/htonl() routines. Since we now have a built-in implementation, we can remove the wsock32 library from the link. [This will break a Windows build on a non-intel machine] Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
* Makefile: Add support for custom build options in config.mak fileRamsay Jones2010-02-281-0/+2
| | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
* Fix some coding style issuesRamsay Jones2010-02-288-121/+119
| | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
* Makefile: Add support for building with MSVCRamsay Jones2010-02-011-5/+24
| | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
* msvc: Fix some "unreferenced formal parameter" warningsRamsay Jones2010-01-201-0/+2
| | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
* msvc: Fix some -W4 warningsRamsay Jones2010-01-201-3/+3
| | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
* Fix some "unused parameter" warnings with -WextraRamsay Jones2010-01-201-1/+1
| | | | Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>