Commit Graph

584 Commits

Author SHA1 Message Date
Vicent Marti
d40d30cb76 Debug assertion when using an initialized hashtable 2011-03-15 19:54:45 +02:00
Vicent Marti
434bedcda0 Fix compilation warnings in ZLib (MSVC)
Yes, we are changing the Zlib code. This is dangerous and uncool.
Fortunately, these are just some implicit casts.
2011-03-15 19:46:38 +02:00
Vicent Marti
7ad96e51ca Remove duplicate refs in git_reference_listall 2011-03-15 05:38:50 +02:00
Vicent Marti
5f8078d4dc Use a more sane zconf.f when building Zlib 2011-03-15 04:22:47 +02:00
Vicent Marti
11a203e1b1 Add nodegit to the README 2011-03-15 03:31:52 +02:00
Vicent Marti
ab6a3d3de5 Add ZLib as a built-in dependency
I don't know if this is good or bad. This lets libgit2 compile cleanly
on any platforms without any external dependencies, but adds a little
bit of bloat...

Let's test this out and see what happens.
2011-03-15 03:29:20 +02:00
Ben Noordhuis
1ee32c6dd9 Add test case for issue GH-86 2011-03-15 02:56:32 +02:00
Ben Noordhuis
bd1aa741a4 git_object_lookup() should also check the type if the object comes from the cache 2011-03-15 02:56:19 +02:00
Vicent Marti
7c8a7b9143 Skip the optional header in packed-refs files 2011-03-15 02:45:49 +02:00
Vicent Marti
7064938bd5 libgit2 version 0.10.0, "very disco"
A version *so* awesome that needs 2 version bumps AND a codename.

Major features:

	- New internal garbage collection (harder)
	- Pack backend rewritten from scratch (better)
	- Revision walker rewritten from scratch (faster)
	- New object interdependency system (stronger)
	- Unique OID shortener
	- Reference listing

In honor of one heck of a music album, released ten years ago,
yesterday.
2011-03-15 00:02:29 +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
58d06cf120 Rewrite the Pack backend
The new pack backend is an adaptation of the original git.git code in
`sha1_file.c`. It's slightly faster than the previous version and
severely less memory-hungry.

The call-stack of a normal pack backend query has been properly
documented in the top of the header for future reference. And by
properly I mean with ASCII diagrams 'n shit.
2011-03-14 23:52:25 +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
Vicent Marti
b760fbf539 Update README.md with new bindings
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-07 21:19:33 +02:00
Tim Clem
74bcb63fae add objective-git to readme 2011-03-07 10:13:56 -08:00
Vicent Marti
55ffebe377 Fix creation of deeply-rooted references
Use a new `gitfo_creat_force` that will create the full path to a file
before creating it.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-05 14:34:32 +02:00
Vicent Marti
246eba80af Use memmove() in git__dirname and git__basename
We cannot make sure that the user doesn't use the same buffer as source
and destination, so write to it using memmove.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-05 13:58:47 +02:00
Vicent Marti
60cb1d10b3 Use memmove() in git__joinpath for overlapping copies
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-05 13:56:14 +02:00
Vicent Marti
545a6915eb Change interface for Tree Index attr (always unsigned)
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-05 13:46:37 +02:00
Sakari Jokinen
9de27ad0c4 Check for valid range of attributes for tree entry 2011-03-05 13:46:27 +02:00
Vicent Marti
3490188b3c Change the return type of git_blob_rawcontent
Should return `void *` for raw bytes.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-05 13:29:50 +02:00
Vicent Marti
e0011be330 Fix the opening of empty repositories
We were checking for the index file, which is not assured to exist on
clean git repositories.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-05 13:22:16 +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
f335b42c72 Fix segmentation fault when freeing a repository
Disable garbage collection of cross-references to prevent
double-freeing. Internal reference management is now done
with a separate method.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-05 02:05:26 +02:00
Vicent Marti
e06dd9b6d6 Fix 'possibly uninitialized variable' warning 2011-03-04 15:23:52 +02:00
Vicent Marti
f7fcb0dd1b Don't use non-int bit fields
They are not standard. MSVC complains about them. And that's not good.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-04 15:10:16 +02:00
Vicent Marti
c3a41e5f14 Fix compilation when using CMake in Windows
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 22:01:15 +02:00
Vicent Marti
3c41c635fb Fix compilation in MSVC
MSVC cannot substract void pointers. Go figure.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 21:58:37 +02:00
Vicent Marti
b64e11d1fe Bump the version number to 0.8.0
Yes, these are some seriously massive changes to the external API. We
are breaking stuff.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:53 +02:00
Vicent Marti
71d33382a7 Move the external includes folder from src to include
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:53 +02:00
Vicent Marti
584f49a5ce Fix several issues with refcounting
- Added several missing reference increases
- Add new destructor to the repository that does not GC the objects

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:53 +02:00
Vicent Marti
971c90befe Do not free the index if it's owned by a repository
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:52 +02: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
nulltoken
8fc050961c Add test deleteref::deleting_a_ref_which_is_both_packed_and_loose_should_remove_both_tracks_in_the_filesystem() 2011-03-03 20:23:52 +02:00
nulltoken
5ad0351db1 Fix reference removal: remove packed refs together with loose ones 2011-03-03 20:23:52 +02:00
nulltoken
d561403f08 Add test for corner case in reference renaming 2011-03-03 20:23:52 +02:00
nulltoken
8f90ced5ed Fix corner case in reference renaming
Renaming a packed reference should not pack another reference
which happens to be in both loose and pack state.
2011-03-03 20:23:52 +02:00
nulltoken
268bee3d4f Add test renameref::rename_a_loose_reference() 2011-03-03 20:23:52 +02:00
Vicent Marti
19a30a3f6e Add new move function, gitfo_mv_force
Forces a move by creating the folder for the destination file, if it
doesn't exist.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:51 +02:00
nulltoken
6b02b21516 Add test renameref::can_not_rename_a_reference_with_an_invalid_name() 2011-03-03 20:23:51 +02:00
nulltoken
129007b423 Fix refs renaming to prevent renaming with an invalid name 2011-03-03 20:23:51 +02:00
nulltoken
65cc1f44e1 Add test renameref::can_not_rename_a_reference_with_an_invalid_name() 2011-03-03 20:23:51 +02:00
nulltoken
e2d426227f Fix reference renaming to prevent duplicated names 2011-03-03 20:23:51 +02:00
nulltoken
de05ff6c78 Add test renameref::renaming_a_packed_reference_makes_it_loose() 2011-03-03 20:23:51 +02:00
nulltoken
76f7cf7075 Fix reference renaming implementation to match standard git behavior 2011-03-03 20:23:51 +02:00