summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* Brush up the refs APIVicent Marti2011-03-033-93/+70
| | | | | | | | Changed some more API details and updated documentation. Sketched API for addition/removal of entries. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Refactored the reference creation API.nulltoken2011-03-032-97/+177
|
* Added some more tests to ensure the correct behavior of ↵nulltoken2011-03-031-7/+2
| | | | git_reference__normalize_name().
* Added GIT_EINVALIDREFSTATE error.nulltoken2011-03-032-1/+5
|
* Added git_reference__normalize_name() along with tests.nulltoken2011-03-034-4/+104
|
* Add missing include to odb_backends.hVicent Marti2011-03-011-0/+1
| | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* include "oid.h" in headers that use git_oidSakari Jokinen2011-02-252-0/+2
| | | | This makes generating bindings to hlibgit2 easier
* Fix file renaming in MinGWVicent Marti2011-02-241-4/+2
| | | | | | | | | | | 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>
* Fix renaming of files in Win32Vicent Marti2011-02-241-0/+12
| | | | | | | | 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>
* Fix double-freeing file descriptorsVicent Marti2011-02-241-2/+5
| | | | | | Was crashing the Windows build. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Rewrite git_hashtable internalsVicent Marti2011-02-225-227/+199
| | | | | | | | | | | | | | | | 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>
* Add printf method to the File BufferVicent Marti2011-02-222-0/+26
| | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Rewrite all file IO for more performanceVicent Marti2011-02-217-409/+337
| | | | | | | | | | | | | | | | | | | | 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>
* Fix repository initializationVicent Marti2011-02-181-13/+11
| | | | | | Fixed several issues with path joining and bare repos. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix segfault when iterating a revlist backwardsVicent Marti2011-02-181-0/+4
| | | | | | | The `prev` and `next` pointers were not being updated after popping one of the list elements. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Disable threaded index writing by defaultVicent Marti2011-02-181-12/+34
| | | | | | | | | | | | | | 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>
* Fix refcounting initializationVicent Marti2011-02-181-4/+4
| | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix type truncation in index entriesVicent Marti2011-02-171-3/+3
| | | | | | | 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>
* Improve the performance when writing Index filesVicent Marti2011-02-173-187/+402
| | | | | | | | | | | | | | 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>
* fix cast in tag.hTim Clem2011-02-141-2/+2
| | | | | git_tag_lookup() and git_tag_new() changed to cast GIT_OBJ_TAG to git_otype in order to compile lib in xcode
* Internal changes on the backend systemVicent Marti2011-02-097-29/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Honor alternate entries in the ODBVicent Marti2011-02-091-16/+63
| | | | | | | | 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>
* Use the new git__joinpath to build paths in methodsVicent Marti2011-02-094-40/+30
| | | | | | | | | | | | | | | | | 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>
* Git trees are now always lazily sortedVicent Marti2011-02-072-52/+14
| | | | | | | | | | | 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>
* Fix detection of working dir on repositoriesVicent Marti2011-02-071-4/+30
| | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Add proper version managementv0.3.0Vicent Marti2011-02-071-0/+5
| | | | | | | | | | 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>
* Fix compilation in MSVCVicent Marti2011-02-071-4/+0
| | | | | | The git_odb_backend_* symbols were being redefined as external. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Merge branch 'join-path-tests' of https://github.com/nulltoken/libgit2Vicent Marti2011-02-071-1/+3
|\
| * Fixed a small issue in git__join_path(). Added tests to exercise ↵nulltoken2011-02-051-1/+3
| | | | | | | | git__join_path().
* | Merge branch 'chobie_git_dir_fix' of https://github.com/chobie/libgit2Vicent Marti2011-02-071-1/+1
|\ \
| * | fix can't detect repository index issues.Shuhei Tanuma2011-02-061-1/+1
| |/
* | Git does not like zero padded file attributes (git fsck)John Wiegley2011-02-071-1/+1
| |
* | Further correction to tree entry sorting (for git fsck)John Wiegley2011-02-071-2/+2
|/
* Merge branch 'sqlite-backend'Vicent Marti2011-02-053-0/+628
|\
| * Add support for SQLite backendsVicent Marti2011-02-053-2/+284
| | | | | | | | | | | | | | | | | | | | | | | | Configure again the build system to look for SQLite3. If the library is found, the SQLite backend will be automatically compiled. Enjoy *very* fast reads and writes. MASTER PROTIP: Initialize the backend with ":memory" as the path to the SQLite database for fully-hosted in-memory repositories. Rejoice. Signed-off-by: Vicent Marti <tanoku@gmail.com>
| * Move data from t03 to a separate headerVicent Marti2011-02-051-0/+346
| | | | | | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* | Fixes a Win32/MSVC compilation issue.nulltoken2011-02-051-1/+2
|/
* Add new utility method `git__joinpath`Vicent Marti2011-02-052-0/+32
| | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix directory/path manipulation methodsVicent Marti2011-02-054-49/+229
| | | | | | | | | | | | | | | | | | | | | | | | | The `dirname` and `dirbase` methods have been replaced with the Android implementation, which is actually compilant to some kind of standard. A new method `topdir` has been added, which returns the topmost directory in a path. These changes fix issue #49: `gitfo_prettify_dir_path` converts "./.git/" to ".git/", so the code at src/repository.c:190 goes out of bounds when trying to find the topmost directory. The new `git__topdir` method handles this gracefully, and the fixed `git__dirname` now returns the proper value for the repository's working dir. E.g. /repo/.git/ ==> working dir '/repo/' .git/ ==> working dir '.' Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Make more methods return error codesVicent Marti2011-02-057-16/+38
| | | | | | | | git_revwalk_next now returns an error code when the iteration is over. git_repository_index now returns an error code when the index file could not be opened. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Keep the tree entries always internally sortedVicent Marti2011-02-052-5/+23
| | | | | | | | | Don't allow access to any tree entries whilst the entries array is unsorted. We keep track on when the array is unsorted, and any methods that access the array while it is unsorted now sort the array before accessing it. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Merge branch 'master' of https://github.com/jwiegley/libgit2Vicent Marti2011-02-054-16/+91
|\
| * Use Git's own tree entry sorting algorithmJohn Wiegley2011-02-031-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If plain strcmp is used, as this code did before, the final sorting may end up different from what git-add would do (for example, 'boost' appearing before 'boost-build.jam', because Git sorts as if it were spelled 'boost/'). If the sorting is incorrect like this, Git 1.7.4 insists that unmodified files have been modified. For example, my test repository has these four entries: drwxr-xr-x 199 johnw wheel 6766 Feb 2 17:21 boost -rw-r--r-- 1 johnw wheel 849 Feb 2 17:22 boost-build.jam -rw-r--r-- 1 johnw wheel 989 Feb 2 17:21 boost.css -rw-r--r-- 1 johnw wheel 6308 Feb 2 17:21 boost.png Here is the output from git-ls-tree for these files, in a commit tree created using git-add and git-commit: 100644 blob 8b8775433aef73e9e12609610ae2e35cf1e7ec2c boost-build.jam 100644 blob 986c4050fa96d825a1311c8e871cdcc9a3e0d2c3 boost.css 100644 blob b4d51fcd5c9149fd77f5ca6ed2b6b1b70e8fe24f boost.png 040000 tree 46537eeaa4d577010f19b1c9e940cae9a670ff5c boost Here is the output for the same commit produced using libgit2: 040000 tree c27c0fd1436f28a6ba99acd0a6c17d178ed58288 boost 100644 blob 8b8775433aef73e9e12609610ae2e35cf1e7ec2c boost-build.jam 100644 blob 986c4050fa96d825a1311c8e871cdcc9a3e0d2c3 boost.css 100644 blob b4d51fcd5c9149fd77f5ca6ed2b6b1b70e8fe24f boost.png Due to this reordering, git-status claims the three blobs are always modified, no matter what I do using git-read-tree or git-reset or git-checkout to update the index.
| * Fixed bug where git__source_printf needs multiple attemptsJohn Wiegley2011-02-011-4/+1
| |
| * Fixed a bug with the way commits are writtenJohn Wiegley2011-02-011-2/+4
| |
| * Make git_tree_clear_entries visible to the userJohn Wiegley2011-02-012-3/+15
| |
| * Added git_tree_add_entry_unsorted and git_tree_sort_entriesJohn Wiegley2011-02-012-5/+48
| |
* | Fix more issues with Win32 EOLVicent Marti2011-02-022-6/+13
| | | | | | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* | Fix EOL issues in ref parsing under Win32Vicent Marti2011-02-021-5/+28
| | | | | | | | | | | | Reference files can be loaded using Win32 line endings, too. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* | Add required includes in "oid.h"Vicent Marti2011-02-011-0/+3
|/ | | | The file was previously failing to be included stand-alone.