Commit Graph

948 Commits

Author SHA1 Message Date
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
7341bf87b1 Refs are now always in-sync on disk 2011-03-16 23:28:27 +02:00
Vicent Marti
9f81a37aa4 Define NO_GZIP in zconf.h instead of at compile time 2011-03-16 23:02:31 +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
8613d4a930 Fix signature in git_repository_gc
The method returns an int with the amount of objects free'd
2011-03-16 01:10:40 +02:00
Vicent Marti
54a1b36c25 Export git_repository_gc properly
One of my brainfarts made me export it as `git_repository_close` instead
of GC. Duh.
2011-03-16 01:07:06 +02:00
Vicent Marti
955f9ae9bd Export git_strarray_free instead of inlining
That way non-C bindings can use it.
2011-03-16 01:06:15 +02:00
Vicent Marti
36b3132966 Properly free commit a commit list in revwalk
The commit list was not being properly free'd when a walk was stopped
halfway through.
2011-03-16 01:04:17 +02:00
Vicent Marti
f73b09cd9a Revert changes in wscript file 2011-03-15 21:19:53 +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
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
a3002d5694 First version - WIP
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-06 00:21:48 +02:00
Vicent Marti
86627121c8 Fix type-conversion warning in MSVC
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-06 00:03:31 +02:00
Vicent Marti
d6b5f5cca9 Add git_oid_shorten
Set of methods to find the minimal-length to uniquely identify every OID
in a list.

Includes stress test.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-05 23:54:49 +02: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