Commit Graph

9 Commits

Author SHA1 Message Date
Vicent Marti
2cd6d6866e Tests now run with the resources folder as a hardcoded path
Each tests expects a "TEST_RESOURCES" define with the full path to the
resources folder.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-12-10 05:53:39 +02:00
Vicent Marti
44908fe763 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>
2010-12-06 23:03:16 +02:00
Vicent Marti
654cd5ff7b Fix segfault in t0603 (unitialized pointer)
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-12-02 21:50:28 +02:00
Vicent Marti
c4034e63f3 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>
2010-12-02 04:31:54 +02:00
Vicent Marti
c3a20d5cab 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>
2010-11-16 02:59:28 +02:00
Vicent Marti
1795f87952 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>
2010-11-05 03:20:17 +02:00
Vicent Marti
6fd195d76c 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>
2010-11-02 18:42:42 +02:00
Ramsay Jones
2d16373cb8 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>
2010-10-27 00:59:09 +03:00
Vicent Marti
ff17642dc2 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>
2010-08-12 18:49:04 +02:00