tests


Log

Author Commit Date CI Message
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>
Vicent Marti 41109a7e 2010-12-02T04:42:33 Merge branch 'commitparents' of https://github.com/JustinLove/libgit2 into JustinLove-commitparents
Vicent Marti c4034e63 2010-12-02T04:31:54 Refactor all 'vector' functions into common code All the operations on the 'git_index_entry' array and the 'git_tree_entry' array have been refactored into common code in the src/vector.c file. The new vector methods support: - insertion: O(1) (avg) - deletion: O(n) - searching: O(logn) - sorting: O(logn) - r. access: O(1) Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti 1e35f929 2010-12-02T04:19:14 Add stack trace to the tests when building with GCC 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
Vicent Marti 277e45f4 2010-11-23T22:36:31 Remove the Makefile from the tests/ folder too Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti 6b1eab39 2010-11-23T14:36:31 Fix MSVC warnings and errors Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti d7c7cab8 2010-11-16T03:25:26 Fix memory leak in t0401 Commit object must be internally free'd after each parse attempt, even it fails. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti c3a20d5c 2010-11-14T22:11:46 Add support for 'index add' 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>
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.
Dave Borowitz f24fa088 2010-11-04T15:06:56 Test that commit attributes are set correctly.
Vicent Marti a8bfce69 2010-11-05T03:50:24 Add string descriptions for all error codes Old descriptions have been updated and new ones have been added for the 'git_strerror' function. Signed-off-by: Vicent Marti <tanoku@gmail.com>
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 6fd195d7 2010-11-02T18:42:42 Change git_repository initialization to use a path 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>
Vicent Marti aaf68dc4 2010-10-29T00:47:53 Add unit tests for git_odb_read_header 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>
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>
Ramsay Jones 2d16373c 2010-10-12T19:12:50 msvc: Fix an "conversion, possible loss of data" warning 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>
Vicent Marti e4def81a 2010-10-08T13:52:17 Fix issue 3 (memory corruption resize_tree_array) 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>
Vicent Marti 0ba7a031 2010-10-07T00:42:55 Add unit tests for object write-back 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>
Vicent Marti c4b5bedc 2010-10-07T00:07:32 Fix possible segfaults in src/tree.c (issue 1) 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>
Vicent Marti 2a884588 2010-09-21T17:17:10 Add write-back support for git_tree 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>
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 003c2690 2010-08-12T18:45:31 Finish the tree object API 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>
Vicent Marti ff17642d 2010-07-19T15:35:52 Add unit tests for index manipulation 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>
Vicent Marti 1baa25ee 2010-07-20T23:56:18 Move test resources to a common directory 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>
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 f8758044 2010-08-07T01:02:20 Add loading and parsing of tag objects 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>
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 7e4f56a5 2010-08-06T18:37:59 Add packfile reading 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>
Vicent Marti 3e590fb2 2010-07-07T19:24:08 Changed test files to use tabs instead of spaces 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 b231ef3a 2010-06-12T03:08:52 Add new tests: t0502-table, t0503-tableit "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>
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 ca3939e6 2010-06-03T22:28:30 msvc: Disable a level 4 warning and change -W3 to -W4 Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones 0aaf8708 2010-06-07T19:33:36 Makefile(s): Add -Wextra to CFLAGS Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones 552e23ba 2010-06-02T19:16:28 Fix a bug in the git_oid_to_string() function 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>
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 468b12ad 2010-06-01T19:31:26 msvc: tests/t0403-lists.c: Fix a compiler warning 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>
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 d047b47a 2010-05-23T04:41:07 Updated t0401 (commit parsing) to reflect the new API changes. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 089c2d93 2010-05-23T04:39:33 Add unit tests for list sorting. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Vicent Marti 0cf02ff9 2010-05-26T21:23:01 Added t0501-walk (simple test for all revision pool walking modes) 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 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>
Ramsay Jones 38c513b9 2010-04-28T19:07:14 Add support to enable the library to use OpenSSL SHA1 functions Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones 19d13c65 2010-04-27T17:00:30 Makefile(s): Don't include the OpenSSL crypto library in the link Also, fully purge the NO_OPENSSL build variable. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones 70aab459 2010-04-26T22:04:10 win32: Remove wsock32 from the list of libraries to link 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>
Ramsay Jones 56931d1a 2010-02-19T20:07:03 Makefile: Add support for custom build options in config.mak file Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones 1e5dd572 2010-02-12T16:50:33 Fix some coding style issues Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones 74eff33f 2010-02-01T10:39:10 Makefile: Add support for building with MSVC Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones 73dcf287 2010-01-12T16:39:25 msvc: Fix some "unreferenced formal parameter" warnings Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones e8a95256 2010-01-04T18:57:13 msvc: Fix some -W4 warnings Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones 1a7bae4d 2010-01-11T22:51:42 Fix some "unused parameter" warnings with -Wextra Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones 1cfb0ff4 2009-12-30T19:12:35 Makefile: Add some missing $(GIT_LIB) dependencies Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones a1c0728d 2009-12-21T15:54:50 Add support for the MinGW platform Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones cfe3a027 2010-01-15T22:07:44 Use a 64 bit off_t throughout the library and tests on POSIX Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones 960ca1d7 2009-08-28T21:22:46 Add the git_oid_to_string() utility function Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones e4553584 2009-08-19T17:06:39 Add test-suite coverage testing using gcov Add a new "coverage" Makefile target that re-builds the library and tests using the gcc compiler/linker flags required by gcov, runs the test suite to capture the runtime data, then compiles a coverage report. The report, which is saved in a file named "untested", consists of a list of untested files, followed by a list of untested functions. More detailed execution statistics are given in the gcov log files which are saved in the top-level directory (named like src#hash.c.gcov). Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones d2ef83fc 2009-08-28T20:22:03 t0101-oid.c: Fix a memory leak reported by valgrind Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones cac5d927 2009-08-27T16:11:07 Add support for running the tests via valgrind Add some makefile targets, which use valgrind's memcheck tool to run the tests, in order to help diagnose memory problems in the library. In addition, we enable the '--leak-check' option to report on any memory leaks. However, unlike the other memory problems reported by memcheck, memory leak reports do not result in an error exit from valgrind. (So memory leaks are reported on stderr, but don't halt the test run.) A suppressions file (tests.supp) is included since libz triggers some false positives. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Julio Espinoza-Sokal 73c4dd92 2009-06-15T21:26:02 Add noreturn declaration compatible with the MSVC compiler. MSVC provides a compiler declaration to declare that a function never returns. This declaration is required in front of the function definition rather than at the end, but fortunately gcc is compatible with this location as well. Explicit returns are no longer required after calls to test_die. Signed-off-by: Julio Espinoza-Sokal <julioes@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Ramsay Jones cf33ac7a 2009-06-04T17:10:17 Makefile: Add CFLAGS to the "test_main.c" compile target Also, add the <string.h> include to test_main.c, in order to suppress the resulting "implicit declaration of strcmp()" warning. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
Ramsay Jones c8d42b9b 2009-06-04T17:12:00 t0020-dirent.c: Add explicit returns to the callback functions In particular, the one_entry() and dont_call_me() callback functions require explicit returns, in order to suppress some "control path" compiler warnings (from MS Visual C/C++). Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
Ramsay Jones aee8b26e 2009-06-04T17:11:06 Makefile: move test related targets to a new tests/Makefile Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
Ramsay Jones e17a3f56 2009-06-04T16:47:59 Implement git_odb_write() Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
Ramsay Jones fd0ec033 2009-03-23T18:52:00 Fix comments in renamed t020?-readloose tests Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Ramsay Jones 498bc090 2009-03-23T18:47:18 t0020-dirent.c: allow test to be run standalone This test assumed that it was invoked in an empty directory, which is true when run from the Makefile, and so would fail if run standalone. In order to allow the test to work when run from any directory, create a sub directory "dir-walk" and chdir() into this directory while running the tests. Also, add some additional tests. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Julio Espinoza-Sokal 0f39781c 2009-03-12T22:10:32 Add a test to check existence of loose objects. Signed-off-by: Julio Espinoza-Sokal <julioes@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Julio Espinoza-Sokal 491442f9 2009-03-12T22:10:22 Factor out test helper methods for creating/deleting loose objects Signed-off-by: Julio Espinoza-Sokal <julioes@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Ramsay Jones 04c9c16e 2009-02-03T18:16:11 Correct some comments in readloose tests Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Ramsay Jones 4730b722 2009-01-12T19:51:17 Tidy up the readloose tests Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Ramsay Jones ced645ea 2009-01-12T19:42:13 Add git__dirname and git__basename utility routines These routines are intended to extract the directory and base name from a path string. Note that these routines do not interact with any filesystem and work only on the text of the path. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce 5690f02e 2008-12-31T15:35:36 Rewrite git_foreach_dirent into gitfo_dirent Our fileops API is currently private. We aren't planning on supplying a cross-platform file API to applications that link to us. If we did, we'd probably whole-sale publish fileops, not just the dirent code. By moving it to be private we can also change the call signature to permit the buffer to be passed down through the call chain. This is very helpful when we are doing a recursive scan as we can reuse just one buffer in all stack frames, reducing the impact the recursion has on the stack frames in the data cache. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce 9eb79764 2008-12-31T14:35:39 Add string utility functions for prefix and suffix compares Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce 028ef0de 2008-12-31T13:20:21 Add a mutex and atomic counter abstraction and implementations These abstractions can be used to implement an efficient resource reference counter and simple mutual exclusion. On pthreads we use pthread_mutex_t, except when we are also on glibc and can directly use its asm/atomic.h definitions. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce 4260699b 2008-12-31T11:16:41 Rename the test cases to run in specific orders This way we can be fairly certain we run tests of lower-level parts of the library before we run tests of higher-level more complex parts. If there is any problem in a lower-level part of the library, the earlier test will identify it and stop, making it easire to troubleshoot the failure. A rough naming guide has been added for the test suite to explain the current category structure. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce a1d34bc0 2008-12-30T21:49:38 Support building on Mac OS X by using pthread_getspecific for TLS The Mach-O format does not permit gcc to implement the __thread TLS specification, so we must instead emulate it using a single int cell allocated from memory and stored inside of the thread specific data associated with the current pthread. What makes this tricky is git_errno must be a valid lvalue, so we really need to return a pointer to the caller and deference it as part of the git_errno macro. The GCC-specific __attribute__((constructor)) extension is used to ensure the pthread_key_t is allocated before any Git functions are executed in the library, as this is necessary to access our thread specific storage. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Ramsay Jones c960d6a3 2008-12-27T18:59:43 Add a routine to determine a git_oid given an git_obj Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Ramsay Jones 007e0753 2008-12-27T18:58:25 Add some routines for SHA1 hash computation [sp: Changed signature for output to use git_oid, and added a test case to verify an allocated git_hash_ctx can be reinitialized and reused.] Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Ramsay Jones 3d3552e8 2008-12-18T22:58:10 Implement git_odb__read_loose() Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Ramsay Jones 7b6e8067 2008-12-10T18:31:28 Add some git_otype string conversion and testing routines Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce af795e49 2008-12-02T09:56:23 Add routines to convert git_oid to hex strings [sp: Credit for some of this implementation goes to Pieter, I started off a patch he proposed for libgit2 but reworked enough of it that I don't want to blame him for any bugs.] Suggested-by: Pieter de Bie <pdebie@ai.rug.nl> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce 367ab010 2008-11-03T18:19:02 Add an extra oid test to verify control characters aren't read We only want hex digits to be read, any other character in the 8-bit character set is invalid within an id string. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce b7c891c6 2008-11-03T17:31:16 Add git_oid_cpy, git_oid_cmp as inline functions These are easily built off the standard C library functions memcpy and memcmp. By marking these inline we stand a good chance of the C compiler replacing the entire thing with tight machine code, because many compilers will actually inline a memcmp or memcpy when the 3rd argument (the size) is a constant value. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce b81dd80e 2008-11-03T18:38:12 Change test_main to run a single test case out of the suite By passing the name of the test function on the command line we execute exactly that one test, and then exit successfully if the test did not fail. This permits multiple functions in the same .c file, so they could be called from a shell script or debugged independently externally. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce b923f2f9 2008-11-03T17:00:54 Fix Makefile to correctly handle 'make -j4 test' If we have more than one test build running we cannot use the same file for each test case; instead we need to use a per-test path so there aren't any collisions. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce fbbfdf9f 2008-11-03T16:29:56 Move GIT_NORETURN into test_lib.h only We should never have a noreturn style function in the library itself, as such a function would prevent the calling application from handling error conditions the way it wants. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce 15bffce9 2008-11-01T18:14:22 Create a basic test suite for the library and test oid functions This is a horribly simple test suite that makes it fairly easy to put together some basic function level unit tests on the library. Its patterned somewhat after the test suite in git.git, but also after the "Check" test library. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>