Commit Graph

1171 Commits

Author SHA1 Message Date
Vicent Marti
ccef1c9dc2 Move the path comparison method to fileops.c
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:50 +02:00
Vicent Marti
da7c3c71c0 Fix warnings in vector.c
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:49 +02:00
nulltoken
9b3985fa2f Slightly enhanced the readability of some reference related tests. 2011-03-03 20:23:49 +02:00
nulltoken
b0a8314340 Removed duplicate tests. 2011-03-03 20:23:49 +02:00
Vicent Marti
86194b2433 Split packed from unpacked references
These two reference types are now stored separately to eventually allow
the removal/renaming of loose references and rewriting of the refs
packfile.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:49 +02:00
Vicent Marti
32054c24a2 Brush up the refs API
Changed some more API details and updated documentation.

Sketched API for addition/removal of entries.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:49 +02:00
nulltoken
2de3b35cd4 Added test covering creation of nested symbolic references. 2011-03-03 20:23:49 +02:00
nulltoken
1d8cc73123 Refactored the reference creation API. 2011-03-03 20:23:49 +02:00
nulltoken
e1be102816 Added some more tests to ensure the correct behavior of git_reference__normalize_name(). 2011-03-03 20:23:48 +02:00
nulltoken
77600378db Fixed line endings (CRLF->LF). 2011-03-03 20:23:48 +02:00
nulltoken
6a0895adea Added GIT_EINVALIDREFSTATE error. 2011-03-03 20:23:48 +02:00
nulltoken
aa2120e9da Added git_reference__normalize_name() along with tests. 2011-03-03 20:23:48 +02:00
antong
83403e99ba Fix check for bad --sha1 option argument 2011-03-02 11:02:22 -08:00
Vicent Marti
5cfd9ce462 Add missing include to odb_backends.h
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-01 22:15:20 +02:00
Sakari Jokinen
fc70832a4f include "oid.h" in headers that use git_oid
This makes generating bindings to hlibgit2 easier
2011-02-25 00:00:36 +02:00
Vicent Marti
7360122ba9 Fix file renaming in MinGW
We now use MoveFileEx, which is not assured to be atomic but works for
always (both if the destination exists, or if it doesn't) and is
available in MinGW.

Since this is a Win32 API call, complaint about lost or overwritten files
should be forwarded at Steve Ballmer.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-24 23:53:40 +02:00
Vicent Marti
3eb47c9f67 Fix renaming of files in Win32
The `rename` call doesn't quite work on Win32: expects the destination
file to not exist. We're using a native Win32 call in those cases --
that should do the trick.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-24 21:43:08 +02:00
Vicent Marti
c3be146840 Fix double-freeing file descriptors
Was crashing the Windows build.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-24 19:31:12 +02:00
Vicent Marti
fc658755bf Rewrite git_hashtable internals
The old hash table with chained buckets has been replaced by a new one
using Cuckoo hashing, which offers guaranteed constant lookup times.
This should improve speeds on most use cases, since hash tables in
libgit2 are usually used as caches where the objects are stored once and
queried several times.

The Cuckoo hash implementation is based off the one in the Basekit
library [1] for the IO language, but rewritten to support an arbritrary
number of hashes. We currently use 3 to maximize the usage of the nodes pool.

[1]: https://github.com/stevedekorte/basekit/blob/master/source/CHash.c

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-22 21:59:36 +02:00
Vicent Marti
4378e8d470 Add unit test for writing a big index file
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-22 15:19:35 +02:00
Vicent Marti
5591ea15a5 Add printf method to the File Buffer
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-22 15:19:23 +02:00
Olivier Ramonat
af774b012c Add --without-sqlite option to waf configure
Disable sqlite support when ./waf configure is run with --without-sqlite
2011-02-21 21:57:27 +02:00
Vicent Marti
817c28201e Rewrite all file IO for more performance
The new `git_filebuf` structure provides atomic high-performance writes
to disk by using a write cache, and optionally a double-buffered scheme
through a worker thread (not enabled yet).

Writes can be done 3-layered, like in git.git (user code -> write cache
-> disk), or 2-layered, by writing directly on the cache. This makes
index writing considerably faster.

The `git_filebuf` structure contains all the old functionality of
`git_filelock` for atomic file writes and reads. The `git_filelock`
structure has been removed.

Additionally, the `git_filebuf` API allows to automatically hash (SHA1)
all the data as it is written to disk (hashing is done smartly on big
chunks to improve performance).

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-21 18:13:43 +02:00
Vicent Marti
874c3b6f37 Fix repository initialization
Fixed several issues with path joining and bare repos.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-18 14:11:53 +02:00
Vicent Marti
cb77ad0d4e Fix segfault when iterating a revlist backwards
The `prev` and `next` pointers were not being updated after popping one
of the list elements.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-18 12:23:53 +02:00
Vicent Marti
e822508a05 Disable threaded index writing by default
The interlocking on the write threads was not being done properly (index
entries were sometimes written out of order). With proper interlocking,
the threaded write is only marginally faster on big index files, and
slower on the smaller ones because of the overhead when creating
threads.

The threaded index writing has been temporarily disabled; after more
accurate benchmarks, if might be possible to enable it again only when
writing very large index files (> 1000 entries).

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-18 10:29:55 +02:00
Vicent Marti
3ecc8b5ed9 Fix refcounting initialization
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-18 00:08:34 +02:00
Vicent Marti
084c193562 Fix type truncation in index entries
64-bit types stored in memory have to be truncated into 32 bits when
writing to disk. Was causing warnings in MSVC.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-17 23:32:22 +02:00
Vicent Marti
348c7335dd Improve the performance when writing Index files
In response to issue #60 (git_index_write really slow), the write_index
function has been rewritten to improve its performance -- it should now
be in par with the performance of git.git.

On top of that, if Posix Threads are available when compiling libgit2, a
new threaded writing system will be used (3 separate threads take care
of solving byte-endianness, hashing the contents of the index and
writing to disk, respectively). For very long Index files, this method
is up to 3x times faster than git.git.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-17 23:20:47 +02:00
Tim Clem
81d0ff1ca5 fix cast in tag.h
git_tag_lookup() and git_tag_new() changed to cast GIT_OBJ_TAG to
git_otype in order to compile lib in xcode
2011-02-14 13:22:44 -08:00
Vicent Marti
d4b5a4e23a Internal changes on the backend system
The priority value for different backends has been removed from the
public `git_odb_backend` struct. We handle that internally. The priority
value is specified on the `git_odb_add_alternate`.

This is convenient because it allows us to poll a backend twice with
different priorities without having to instantiate it twice.

We also differentiate between main backends and alternates; alternates have
lower priority and cannot be written to.

These changes come with some unit tests to make sure that the backend
sorting is consistent.

The libgit2 version has been bumped to 0.4.0.

This commit changes the external API:

CHANGED:
	struct git_odb_backend
		No longer has a `priority` attribute; priority for the backend
		in managed internally by the library.

	git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority)
		Now takes an additional priority parameter, the priority that
		will be given to the backend.

ADDED:
	git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority)
		Add a backend as an alternate. Alternate backends have always
		lower priority than main backends, and writing is disabled on
		them.

Signed-off-by: Vicent Marti <tanoku@gmail.com>

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-09 19:49:38 +02:00
Vicent Marti
5a800efc42 Honor alternate entries in the ODB
The alternates file is now parsed, and the alternate ODB folders are
added as separate backends. This allows the library to efficiently query
the alternate folders.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-09 12:46:54 +02:00
Vicent Marti
995f9c34a5 Use the new git__joinpath to build paths in methods
The `git__joinpath` function has been changed to use a statically
allocated buffer; we assume the buffer to be 4096 bytes, because fuck
you.

The new method also supports an arbritrary number of paths to join,
which may come in handy in the future.

Some methods which were manually joining paths with `strcpy` now use the
new function, namely those in `index.c` and `refs.c`.

Based on Emeric Fermas' original patch, which was using the old
`git__joinpath` because I'm stupid. Thanks!

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-09 12:43:19 +02:00
Vicent Marti
772c7e7623 Merge branch 'git-reference-creation-tests' of https://github.com/nulltoken/libgit2 2011-02-08 19:28:12 +02:00
Przemyslaw Pawelczyk
20e83aa4ef Further improve SQLite support for CMake users.
Unfortunately previous commit was only a partial fix, because it broke
SQLite support on platforms w/o pkg-config, e.g. Windows. To be honest
I just forgot about messy Windows.

Now if there is no pkg-config, then user must provide two variables:
SQLITE3_INCLUDE_DIRS and SQLITE3_LIBRARIES if (s)he wants to use SQLite
backend. These variables are added to cmake-gui for her/his convenience
unless they are set by FindPkgConfig module.

pkg-config should work also now in Cygwin.
2011-02-08 13:14:19 +01:00
Przemyslaw Pawelczyk
911fd45792 Fix SQLite support for CMake users.
FindPkgConfig obviously uses pkg-config's output for setting convenient
variables such as <PREFIX>_LIBRARIES or <PREFIX>_INCLUDE_DIRS. It also
sets <PREFIX>_FOUND to 1 if <PREFIX> module exists.

So why checking for SQLITE3_FOUND is better than (SQLITE3_LIBRARIES AND
SQLITE3_INCLUDE_DIRS)? Apart from obvious readability factor, latter
condition has strong assumption that both variables are filled with
appropriate paths, which is unjustifiable unless you add another
assumptions...

pkg-config by default strips -I/usr/include from Cflags and -L/usr/lib
from Libs if some environment variables are not set,
PKG_CONFIG_ALLOW_SYSTEM_CFLAGS and PKG_CONFIG_ALLOW_SYSTEM_LIBS
respectively. This behavior is sane, because it prevents polluting the
compilation and linking commands with superfluous entries.

In debian SQLITE3_INCLUDE_DIRS is empty for instance.

Remark for developers:
Always check commands invoked by CMake after changing CMakeLists.txt.

    VERBOSE=1 cmake --build .
2011-02-08 00:30:08 +01:00
nulltoken
1b7124f849 Added tests exercising git_reference_write() to create a new symbolic reference and a new object id reference. 2011-02-07 21:24:52 +01:00
Vicent Marti
122c340583 Git trees are now always lazily sorted
Removed `git_tree_add_entry_unsorted`. Now the `git_tree_add_entry`
method doesn't sort the entries array by default; entries are only
sorted lazily when required. This is done automatically by the library
(the `git_tree_sort_entries` call has been removed).

This should improve performance. No point on sorting entries all the time, anyway.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-07 18:25:42 +02:00
Vicent Marti
8212e2d7d0 Fix detection of working dir on repositories
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-07 18:25:23 +02:00
Vicent Marti
9d1dcca229 Add proper version management
We now have proper sonames in Mac OS X and Linux, proper versioning on
the pkg-config file and proper DLL naming in Windows.

The version of the library is defined exclusively in 'src/git2.h'; the build scripts
read it from there automatically.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-07 10:35:58 +02:00
Vicent Marti
7a689719bd Merge branch 'master' of https://github.com/saschpe/libgit2 into saschpe-master
Conflicts:
	CMakeLists.txt
2011-02-07 09:14:45 +02:00
Vicent Marti
f443a8793f Compile the SQLite backend with CMake too
Use pkg-config to find the library in Unix systems. In Win32, just set
manually the path to your libraries.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-07 08:47:50 +02:00
Vicent Marti
becff0428e Fix compilation in MSVC
The git_odb_backend_* symbols were being redefined as external.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-07 08:09:11 +02:00
Vicent Marti
2e75e15690 Merge branch 'refs-handling-tests' of https://github.com/nulltoken/libgit2 2011-02-07 08:04:32 +02:00
Vicent Marti
e85c705f5a Merge branch 'join-path-tests' of https://github.com/nulltoken/libgit2 2011-02-07 08:04:04 +02:00
Vicent Marti
13317a5e0f Merge branch 'chobie_git_dir_fix' of https://github.com/chobie/libgit2 2011-02-07 08:03:06 +02:00
John Wiegley
e769e0255e Git does not like zero padded file attributes (git fsck) 2011-02-07 00:11:17 -05:00
John Wiegley
5bf4291637 Further correction to tree entry sorting (for git fsck) 2011-02-07 00:11:00 -05:00
Shuhei Tanuma
56ab8c5437 fix can't detect repository index issues. 2011-02-06 15:48:52 +09:00
nulltoken
fc8afc87d7 Fix a memory leak in git__joinpath() tests. 2011-02-06 07:48:17 +01:00