Commit Graph

307 Commits

Author SHA1 Message Date
Romain Geissler
efcc87c9d9 Repository: A little fix in error code. GIT_ENOTFOUND is returned when a gitfile is malformed and GIT_ENOTAREPO when the pointed dir is not a repo.
Fixed tests so that it check the right error code.
2011-06-06 10:02:07 +02:00
schu
fd21c6f67f Add test case checking we do not corrupt the repository when renaming
Signed-off-by: schu <schu-github@schulog.org>
2011-06-05 19:20:57 +02:00
Romain Geissler
76e9e3b763 Tests: Added tests for git_repository_discover.
Unfortunately, the across_fs flag can't be tested automaticly, as we can't
create a temporary new filesystem.
2011-06-05 00:23:24 +02:00
Vicent Marti
602ee38b6e repository: Export all internal paths 2011-06-04 20:45:09 +02:00
unknown
26a98ec8a2 Fileops: Added a fourth argument to the path prettifying functions to use an alternate basepath.
Fixed a Windows TO-DO in the prettifying functions.
2011-06-03 21:04:02 +02:00
Vicent Martí
dd8a2070ce Merge pull request #215 from schu/typos
Fix typos
2011-06-01 12:54:15 -07:00
Vicent Martí
46d359d1c3 Merge pull request #218 from schu/tests-fflush
test_lib.c: flush stdout after every test-run
2011-06-01 12:53:46 -07:00
Vicent Martí
9db04160a5 Merge pull request #222 from carlosmn/config-bugfix
Config bugfix
2011-06-01 12:52:50 -07:00
Vicent Martí
50b7334e51 Merge pull request #206 from nulltoken/topic/is-bare
Add git_repository_is_bare() accessor
2011-06-01 09:58:21 -07:00
Vicent Marti
f7e59c4dcf index: Change the memory management for repo indexes
The `git_repository_index` call now returns a brand new index that must
be manually free'd.
2011-06-01 18:54:47 +02:00
Carlos Martín Nieto
fc0ee5bdd3 Add test for empty config file
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-05-31 17:57:18 +02:00
Carlos Martín Nieto
30d0550da8 Add test for invalid ext header
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-05-31 17:57:17 +02:00
Carlos Martín Nieto
38d0bc1e81 Add config test for empty line
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-05-31 17:57:17 +02:00
schu
a7ed162538 test_lib.c: flush stdout after every test-run
Make sure the user immediately sees the feedback, '.' or 'F', for a
test. If it's only in the buffer, it may gets "lost" in case of error.

Signed-off-by: schu <schu-github@schulog.org>
2011-05-30 21:13:11 +02:00
schu
286349c6ec Fix tiny typo
Signed-off-by: nulltoken <emeric.fermas@gmail.com>
Signed-off-by: schu <schu-github@schulog.org>
2011-05-29 20:15:27 +02:00
nulltoken
fa9bcd81f5 Add git_repository_is_bare() accessor 2011-05-24 21:50:02 +02:00
Vicent Marti
b0b527e0ad config: Cleanup & renaming of the external API
"git_config_backend" have been renamed to "git_config_file", which
implements a generic interface to access a configuration file -- be it
either on disk, from a DB or whatever mumbojumbo.

I think this makes more sense.
2011-05-20 03:20:12 +03:00
schu
6628c2560c test_lib: add return value to git_test
Save the return value of functions not passing must_pass() and report
the returned error.

Signed-off-by: schu <schu-github@schulog.org>
2011-05-18 12:36:41 +02:00
Vicent Marti
c9662061f2 t15: Remove unused variable 2011-05-17 15:12:25 +03:00
Vicent Marti
124fbb3d74 tests: Update NAMING file 2011-05-17 15:11:43 +03:00
Vicent Martí
62845c903e Merge pull request #116 from carlosmn/test-naming
tests: update NAMING file
2011-05-17 05:11:06 -07:00
Carlos Martín Nieto
94711cad3b Merge upstream/development 2011-05-17 12:12:59 +02:00
Carlos Martín Nieto
c033500549 Move config to a backend structure
Configuration options can come from different sources. Currently,
there is only support for reading them from a flat file, but it might
make sense to read it from a database at some point.

Move the parsing code into src/config_file.c and create an include
file include/git2/config_backend.h to allow for other backends to be
developed.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-05-10 14:47:20 +02:00
Carlos Martín Nieto
ca8d2dfc0c Merge remote-tracking branch 'upstream/development' into config 2011-05-05 16:22:06 +02:00
Carlos Martín Nieto
bbd68c6768 ref test: update a forgotten repo -> repo2
Commit 34e5d87e05 left one of these unchanged we're trying
to read from a free'd repository.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-05-05 11:40:39 +02:00
Vicent Martí
cc3b82e376 Merge pull request #151 from carlosmn/root-commit.
Support root commits
2011-05-02 15:29:50 -07:00
Vicent Martí
fde97669ec Merge pull request #146 from nordsturm/fix_subtrees.
Fix tree-entry attribute convertion (fix corrupted trees)
2011-05-02 15:26:16 -07:00
Vicent Martí
d4ad0771e4 Merge pull request #145 from schu/fix-unused-warnings.
Fix -Wunused-but-set-variable warnings
2011-05-01 14:59:50 -07:00
nulltoken
34e5d87e05 Change implementation of refs tests that alter the current repository to make them run against a temporary clone of the test repository 2011-05-01 21:35:32 +02:00
Carlos Martín Nieto
79b6155736 Add root commit test
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-29 12:08:24 +02:00
Sergey Nikishin
555ce56819 Fix tree-entry attribute convertion (fix corrupted trees)
Magic constant replaced by direct to-string covertion because of:
1) with value length 6 (040000 - subtree) final tree will be corrupted;
2) for wrong values length <6 final tree will be corrupted too.
2011-04-26 15:32:11 +04:00
schu
402a47a7fa Fix -Wunused-but-set-variable warnings
As of gcc 4.6 -Wall includes -Wunused-but-set-variable. Use GIT_UNUSED
or remove actually unused variables to prevent those warnings.
2011-04-26 11:29:05 +02:00
Vicent Martí
5a74d16048 Merged pull request #135 from carlosmn/valgrind.
Fix memory leaks in the tests
2011-04-23 14:37:56 -07:00
Carlos Martín Nieto
a99264bff6 config: allow uppercase number suffixes
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-19 16:34:22 +02:00
Carlos Martín Nieto
7c1c15a7fb tests: free the test suite name
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-13 21:55:43 +02:00
Carlos Martín Nieto
2fe3692c23 tests: don't leak objects
If we don't create any leaks in the tests, we can use them to search
for leaks in the implementation.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-13 21:50:11 +02:00
Vicent Marti
def3fef197 Add git_tag_list
Lists all the tag references in a repository using a custom callback.
Includes unit tests courtesy of Emeric Fermas <3
2011-04-12 15:55:51 -07:00
Carlos Martín Nieto
53345e1f1f config: add tests for number suffix
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-11 18:01:01 +02:00
Carlos Martín Nieto
55c197cdd3 Merge upstream/development 2011-04-11 17:43:56 +02:00
Vicent Marti
fdd0cc9e89 Fix path normalization tests
They were backtracking too deep into the filesystem on Linux, where the
tests were running directly on `tmp/`.
2011-04-10 15:25:41 -07:00
Vicent Marti
a6359408a5 Use Z_BEST_SPEED for filebuf deflating
This is what Git uses by default for all deflating.
2011-04-10 12:23:55 -07:00
nulltoken
4a34b3a9ff Add two new accessors to the repository
git_repository_path() and git_repository_workdir() respectively return the path to the git repository and the working directory. Those paths are absolute and normalized.
2011-04-09 15:25:24 -07:00
Vicent Marti
b918ae40d1 Do not declare variables in the middle of a func 2011-04-08 15:35:25 -07:00
Vicent Marti
41233c40c0 Add new method git_repository_is_empty 2011-04-08 12:42:18 -07:00
Vicent Marti
cef75d7430 Remove unused variables from test files 2011-04-08 12:41:17 -07:00
Vicent Marti
d79f1da65a refs: Fix issue when packing weak tags
Weak tags (e.g. tags that point directly to a normal object instead of a
tag object) were failing to be packed.
2011-04-08 12:14:33 -07:00
Carlos Martín Nieto
7bc66a79fa tag: don't allow tags to non-existent objects
These indicate an inconsistency in the repository which we've created,
so don't allow them.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-08 03:36:53 +03:00
Shuhei Tanuma
98ac678085 fix git_treebuilder_insert probrem.
couldn't add new entry when inserting new one with `git_treebuilder_insert`.
2011-04-08 03:30:47 +03:00
Dmitry Kovega
8a64bc292c redis backend 2011-04-08 03:27:01 +03:00
Carlos Martín Nieto
8bd6c0ab83 Merge remote-tracking branch 'upstream/development' into config 2011-04-06 15:49:29 +02:00
Vicent Marti
0ad6efa110 Build & write custom trees in memory 2011-04-04 19:25:33 +03:00
Carlos Martín Nieto
511b2370d9 tests: update NAMING file
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-04 17:24:37 +02:00
Carlos Martín Nieto
8cd767ef52 config: test for a variable on its own
If a variable is on its own, truth should be assumed. Check this is
true in our code.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-04 17:07:47 +02:00
Carlos Martín Nieto
0bf8ca8820 config: add tests
These tests are basic, but they should tell us when we've broken
something.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-04 16:44:23 +02:00
nulltoken
f3564e1e29 Fix tag reference name in testrepo.git
The git test repository was holding a wrongly named tag reference ("very-simple") pointing at a tag named "e90810b".
This mistake (mine :-/ ) originates back to https://github.com/libgit2/libgit2/commit/9282e92

Whole credit goes to @tclem for having spotted this.
2011-04-04 13:12:23 +03:00
Vicent Marti
3e3e4631a0 Merge branch 'tagging' of https://github.com/nulltoken/libgit2 into development
Conflicts:
	include/git2/tag.h
	src/tag.c
2011-04-02 12:50:25 +03:00
Vicent Marti
720d5472f8 Change parse methods to const buffer
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-04-02 12:42:04 +03:00
nulltoken
9e680bcc00 Add git_tag_delete() 2011-03-30 23:26:36 +02:00
nulltoken
a50c145855 Add git_tag_create_o_f() and git_tag_create_f() which overwrite existing tag reference, if any 2011-03-30 23:16:30 +02:00
nulltoken
74e50a2d3e Fix memory leak in tag releated tests 2011-03-30 22:46:52 +02:00
nulltoken
bf4c39f929 Prevent tag_create() from creating a conflicting reference 2011-03-30 22:30:55 +02:00
nulltoken
6d3160148b Add test demonstrating that one can create a tag pointing at a non existent target 2011-03-30 22:26:53 +02:00
nulltoken
8e9a3d4217 Enforce the testing of the correct creation of a tag 2011-03-30 21:46:19 +02:00
nulltoken
673de2cf59 Fix misleading comments 2011-03-30 21:29:10 +02:00
nulltoken
2b9b99b6ed Add test ensuring one can not create an oid reference which targets at an unknown id 2011-03-29 21:29:30 +02:00
nulltoken
4d00dfd438 Replace gitfo_unlink() calls with git_reference_delete() in refs related tests 2011-03-29 21:21:47 +02:00
Carlos Martín Nieto
553fbd640f Check for looser reference names
res/dummy/a and refs/stash must pass. The other rules are already
tested by the rest of the checks.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:19 +03:00
Vicent Marti
95cde17ca4 Enforce coding conventions in refs.c
Internal methods are static and without the git prefix.
'Force' methods have a `_f` prefix to match the other 'force' methods.
2011-03-29 19:58:19 +03:00
Carlos Martín Nieto
fc1eeb9dfc Make overwrite test more comprehensive
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:19 +03:00
Carlos Martín Nieto
ec99193655 force-rename test: check for the right name
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:19 +03:00
Carlos Martín Nieto
591a9423f5 Add tests covering overwriting references
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:18 +03:00
Vicent Marti
483526ebec Update the SQLite backend 2011-03-28 22:23:44 +03:00
nulltoken
a8375f5322 Add test exercising the opening of an standard repository initialized by git 2011-03-23 00:25:05 +02:00
nulltoken
2ce44b67f3 Add test exercising the opening of an empty bare repository initialized by git 2011-03-23 00:25:04 +02:00
nulltoken
29e1797c14 Add remove_placeholders() test helper function which recursively removes marker files from a directory structure 2011-03-23 00:25:04 +02:00
Vicent Marti
3fe9c60c6a Add empty bare and normal repos to test resources
We have removed the hooks folder because it takes a lot of space
2011-03-23 00:25:04 +02:00
nulltoken
f428ae615b Slightly enforce copy_recurs() behavior
The folder creation is now decorrelated from the recursive parsing of the source tree structure.
2011-03-23 00:25:04 +02:00
nulltoken
ba1bdf86e7 Improve test coverage of new path prettifying behavior 2011-03-23 00:24:51 +02:00
nulltoken
3644e98fd9 Fix detection of attempt to escape the root directory on Windows 2011-03-23 00:17:25 +02:00
nulltoken
c90292ce4f Change gitfo_prettify_dir_path() and gitfo_prettify_file_path() behavior
Those functions now return prettified rooted path.
2011-03-23 00:17:24 +02:00
nulltoken
677a3c07f4 Add failing test for issue 84
see https://github.com/libgit2/libgit2/issues#issue/84
2011-03-23 00:17:24 +02:00
nulltoken
56d8ca266c Switch from time_t to git_time_t
git_time_t is defined as a signed 64 integer. This allows a true predictable multiplatform behavior.
2011-03-23 00:07:58 +02:00
Vicent Marti
99baacfb56 Fix MSVC warnings 2011-03-21 19:27:45 +02:00
Vicent Marti
72a3fe42fb I broke your bindings
Hey. Apologies in advance -- I broke your bindings.

This is a major commit that includes a long-overdue redesign of the
whole object-database structure. This is expected to be the last major
external API redesign of the library until the first non-alpha release.

Please get your bindings up to date with these changes. They will be
included in the next minor release. Sorry again!

Major features include:

	- Real caching and refcounting on parsed objects
	- Real caching and refcounting on objects read from the ODB
	- Streaming writes & reads from the ODB
	- Single-method writes for all object types
	- The external API is now partially thread-safe

The speed increases are significant in all aspects, specially when
reading an object several times from the ODB (revwalking) and when
writing big objects to the ODB.

Here's a full changelog for the external API:

blob.h
------

	- Remove `git_blob_new`
	- Remove `git_blob_set_rawcontent`
	- Remove `git_blob_set_rawcontent_fromfile`
	- Rename `git_blob_writefile` -> `git_blob_create_fromfile`
	- Change `git_blob_create_fromfile`:
		The `path` argument is now relative to the repository's working dir
	- Add `git_blob_create_frombuffer`

commit.h
--------

	- Remove `git_commit_new`
	- Remove `git_commit_add_parent`
	- Remove `git_commit_set_message`
	- Remove `git_commit_set_committer`
	- Remove `git_commit_set_author`
	- Remove `git_commit_set_tree`

	- Add `git_commit_create`
	- Add `git_commit_create_v`
	- Add `git_commit_create_o`
	- Add `git_commit_create_ov`

tag.h
-----

	- Remove `git_tag_new`
	- Remove `git_tag_set_target`
	- Remove `git_tag_set_name`
	- Remove `git_tag_set_tagger`
	- Remove `git_tag_set_message`

	- Add `git_tag_create`
	- Add `git_tag_create_o`

tree.h
------

	- Change `git_tree_entry_2object`:
		New signature is `(git_object **object_out, git_repository *repo, git_tree_entry *entry)`

	- Remove `git_tree_new`
	- Remove `git_tree_add_entry`
	- Remove `git_tree_remove_entry_byindex`
	- Remove `git_tree_remove_entry_byname`
	- Remove `git_tree_clearentries`
	- Remove `git_tree_entry_set_id`
	- Remove `git_tree_entry_set_name`
	- Remove `git_tree_entry_set_attributes`

object.h
------------

	- Remove `git_object_new
	- Remove `git_object_write`

	- Change `git_object_close`:
		This method is now *mandatory*. Not closing an object causes a
		memory leak.

odb.h
-----

	- Remove type `git_rawobj`
	- Remove `git_rawobj_close`
	- Rename `git_rawobj_hash` -> `git_odb_hash`
	- Change `git_odb_hash`:
		New signature is `(git_oid *id, const void *data, size_t len, git_otype type)`

	- Add type `git_odb_object`
	- Add `git_odb_object_close`

	- Change `git_odb_read`:
		New signature is `(git_odb_object **out, git_odb *db, const git_oid *id)`
	- Change `git_odb_read_header`:
		New signature is `(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id)`
	- Remove `git_odb_write`
	- Add `git_odb_open_wstream`
	- Add `git_odb_open_rstream`

odb_backend.h
-------------

	- Change type `git_odb_backend`:
		New internal signatures are as follows

			int (* read)(void **, size_t *, git_otype *, struct git_odb_backend *, const git_oid *)
			int (* read_header)(size_t *, git_otype *, struct git_odb_backend *, const git_oid *)
			int (* writestream)(struct git_odb_stream **, struct git_odb_backend *, size_t, git_otype)
			int (* readstream)( struct git_odb_stream **, struct git_odb_backend *, const git_oid *)

	- Add type `git_odb_stream`
	- Add enum `git_odb_streammode`

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-20 21:45:11 +02:00
Vicent Marti
bb3de0c472 Thread safe cache 2011-03-20 21:45:06 +02:00
Vicent Marti
b5c5f0f808 Fix headers for the new Revision Walker
The "oid.h" header is now included instead of "object.h".

The old "revwalk.h" header has been removed; it was empty.
2011-03-16 23:59:09 +02:00
Vicent Marti
36aaf1ff1a Change the Revwalk reset behavior to the old version
The `reset` call now removes the pushed commits so we can reuse
the revwalker. The API documentation has been updated with the details.
2011-03-16 01:53:25 +02:00
Vicent Marti
bbcc7ffc69 Add proper threading support to libgit2
We now depend on libpthread on all Unix platforms (should be installed
by default) and use a simple wrapper for Windows threads under Win32.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-15 21:14:07 +02:00
Vicent Marti
b5abb881a6 Do not segfault when listing unpacked references 2011-03-15 19:55:01 +02:00
Vicent Marti
7ad96e51ca Remove duplicate refs in git_reference_listall 2011-03-15 05:38:50 +02:00
Ben Noordhuis
1ee32c6dd9 Add test case for issue GH-86 2011-03-15 02:56:32 +02:00
Vicent Marti
6b2a19418c Fix the retarded object interdependency system
It's no longer retarded. All object interdependencies are stored as OIDs
instead of actual objects. This should be hundreds of times faster,
specially on big repositories. Heck, who knows, maye it doesn't even
segfault -- wouldn't that be awesome?

What has changed on the API?

	`git_commit_parent`, `git_commit_tree`, `git_tag_target` now return
	their values through a pointer-to-pointer, and have an error code.

	`git_commit_set_tree` and `git_tag_set_target` now return an error
	code and may fail.

	`git_repository_free__no_gc` has been deprecated because it's
	stupid. Since there are no longer any interdependencies between
	objects, we don't need internal reference counting, and GC
	never fails or double-free's pointers.

	`git_object_close` now does a very sane thing: marks an object
	as unused. Closed objects will be eventually free'd from the
	object cache based on LRU. Please use `git_object_close` from
	the garbage collector `destroy` method on your bindings. It's
	100% safe.

	`git_repository_gc` is a new method that forces a garbage collector
	pass through the repo, to free as many LRU objects as possible.
	This is useful if we are running out of memory.
2011-03-14 23:52:32 +02:00
Vicent Marti
0057182807 Add new method git_reference_listall
Lists all the references in a repository. Listing may be filtered by
reference type.

This should applease Lord Clem.
2011-03-14 23:52:32 +02:00
Vicent Marti
71db842fac Rewrite the Revision Walker
The new revision walker uses an internal Commit object storage system,
custom memory allocator and much improved topological and time sorting
algorithms. It's about 20x times faster than the previous implementation
when browsing big repositories.

The following external API calls have changed:

	`git_revwalk_next` returns an OID instead of a full commit object.
	The initial call to `git_revwalk_next` is no longer blocking when
	iterating through a repo with a time-sorting mode.

	Iterating with Topological or inverted modes still makes the initial
	call blocking to preprocess the commit list, but this block should be
	mostly unnoticeable on most repositories (topological preprocessing
	times at 0.3s on the git.git repo).

	`git_revwalk_push` and `git_revwalk_hide` now take an OID instead
	of a full commit object.
2011-03-14 23:52:15 +02:00
Vicent Marti
26022f0719 Add git_oid_shorten (unique OID minimzer)
Set of methods to find the minimal-length to uniquely identify every OID
in a list. Useful for GUI applications, commit logs and so on.

Includes stress test.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-14 23:36:10 +02:00
Tim Clem
45314a7e4a clean up temp repo for t12-repo tests
add actual must_pass calls back into the repo tests and remove ./ from
beginning of temp repo path
2011-03-04 23:31:28 -08:00
Vicent Marti
48c27f86bb Implement reference counting for git_objects
All `git_object` instances looked up from the repository are reference
counted. User is expected to use the new `git_object_close` when an
object is no longer needed to force freeing it.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:52 +02:00
Vicent Marti
86d7e1ca6f Fix searching in git_vector
We now store only one sorting callback that does entry comparison. This
is used when sorting the entries using a quicksort, and when looking for
a specific entry with the new search methods.

The following search methods now exist:

	git_vector_search(vector, entry)
	git_vector_search2(vector, custom_search_callback, key)

	git_vector_bsearch(vector, entry)
	git_vector_bsearch2(vector, custom_search_callback, key)

The sorting state of the vector is now stored internally.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:52 +02:00
Vicent Marti
5de079b86d Change the object creation/lookup API
The methods previously known as

	git_repository_lookup
	git_repository_newobject
	git_repository_lookup_ref

are now part of their respective namespaces:

	git_object_lookup
	git_object_new
	git_reference_lookup

This makes the API more consistent with the new references API.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:52 +02:00
Vicent Marti
3dccfed163 Cleanup the testing toolkit
Tests are now declared with detailed descriptions and a short test name:

	BEGIN_TEST(the_test0, "this is an example test that does something")
		...
	END_TEST

Modules are declared through a simple macro interface:

	BEGIN_MODULE(mod_name)
		ADD_TEST(the_test0);
		...
	END_MODULE

Error messages when tests fail have been greatly improved.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:52 +02:00