]> git.proxmox.com Git - libgit2.git/log
libgit2.git
13 years agoAdd printf method to the File Buffer
Vicent Marti [Tue, 22 Feb 2011 12:58:54 +0000 (14:58 +0200)]
Add printf method to the File Buffer

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoAdd --without-sqlite option to waf configure
Olivier Ramonat [Mon, 21 Feb 2011 12:14:01 +0000 (13:14 +0100)]
Add --without-sqlite option to waf configure

Disable sqlite support when ./waf configure is run with --without-sqlite

13 years agoRewrite all file IO for more performance
Vicent Marti [Mon, 21 Feb 2011 15:05:16 +0000 (17:05 +0200)]
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>
13 years agoFix repository initialization
Vicent Marti [Fri, 18 Feb 2011 12:11:53 +0000 (14:11 +0200)]
Fix repository initialization

Fixed several issues with path joining and bare repos.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoFix segfault when iterating a revlist backwards
Vicent Marti [Fri, 18 Feb 2011 10:23:53 +0000 (12:23 +0200)]
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>
13 years agoDisable threaded index writing by default
Vicent Marti [Fri, 18 Feb 2011 08:29:55 +0000 (10:29 +0200)]
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>
13 years agoFix refcounting initialization
Vicent Marti [Thu, 17 Feb 2011 22:08:34 +0000 (00:08 +0200)]
Fix refcounting initialization

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoFix type truncation in index entries
Vicent Marti [Thu, 17 Feb 2011 21:32:22 +0000 (23:32 +0200)]
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>
13 years agoImprove the performance when writing Index files
Vicent Marti [Thu, 17 Feb 2011 19:32:00 +0000 (21:32 +0200)]
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>
13 years agofix cast in tag.h
Tim Clem [Mon, 14 Feb 2011 21:22:44 +0000 (13:22 -0800)]
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

13 years agoInternal changes on the backend system
Vicent Marti [Wed, 9 Feb 2011 17:49:02 +0000 (19:49 +0200)]
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>
13 years agoHonor alternate entries in the ODB
Vicent Marti [Wed, 9 Feb 2011 10:46:54 +0000 (12:46 +0200)]
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>
13 years agoUse the new git__joinpath to build paths in methods
Vicent Marti [Wed, 9 Feb 2011 10:43:19 +0000 (12:43 +0200)]
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>
13 years agoMerge branch 'git-reference-creation-tests' of https://github.com/nulltoken/libgit2
Vicent Marti [Tue, 8 Feb 2011 17:28:12 +0000 (19:28 +0200)]
Merge branch 'git-reference-creation-tests' of https://github.com/nulltoken/libgit2

13 years agoFurther improve SQLite support for CMake users.
Przemyslaw Pawelczyk [Tue, 8 Feb 2011 12:14:19 +0000 (13:14 +0100)]
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.

13 years agoFix SQLite support for CMake users.
Przemyslaw Pawelczyk [Mon, 7 Feb 2011 23:30:08 +0000 (00:30 +0100)]
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 .

13 years agoAdded tests exercising git_reference_write() to create a new symbolic reference and...
nulltoken [Mon, 7 Feb 2011 16:37:54 +0000 (17:37 +0100)]
Added tests exercising git_reference_write() to create a new symbolic reference and a new object id reference.

13 years agoGit trees are now always lazily sorted
Vicent Marti [Mon, 7 Feb 2011 16:25:42 +0000 (18:25 +0200)]
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>
13 years agoFix detection of working dir on repositories
Vicent Marti [Mon, 7 Feb 2011 16:25:23 +0000 (18:25 +0200)]
Fix detection of working dir on repositories

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoAdd proper version management
Vicent Marti [Mon, 7 Feb 2011 08:35:58 +0000 (10:35 +0200)]
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>
13 years agoMerge branch 'master' of https://github.com/saschpe/libgit2 into saschpe-master
Vicent Marti [Mon, 7 Feb 2011 07:14:45 +0000 (09:14 +0200)]
Merge branch 'master' of https://github.com/saschpe/libgit2 into saschpe-master

Conflicts:
CMakeLists.txt

13 years agoCompile the SQLite backend with CMake too
Vicent Marti [Mon, 7 Feb 2011 06:47:50 +0000 (08:47 +0200)]
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>
13 years agoFix compilation in MSVC
Vicent Marti [Mon, 7 Feb 2011 06:09:11 +0000 (08:09 +0200)]
Fix compilation in MSVC

The git_odb_backend_* symbols were being redefined as external.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoMerge branch 'refs-handling-tests' of https://github.com/nulltoken/libgit2
Vicent Marti [Mon, 7 Feb 2011 06:04:32 +0000 (08:04 +0200)]
Merge branch 'refs-handling-tests' of https://github.com/nulltoken/libgit2

13 years agoMerge branch 'join-path-tests' of https://github.com/nulltoken/libgit2
Vicent Marti [Mon, 7 Feb 2011 06:04:04 +0000 (08:04 +0200)]
Merge branch 'join-path-tests' of https://github.com/nulltoken/libgit2

13 years agoMerge branch 'chobie_git_dir_fix' of https://github.com/chobie/libgit2
Vicent Marti [Mon, 7 Feb 2011 06:03:06 +0000 (08:03 +0200)]
Merge branch 'chobie_git_dir_fix' of https://github.com/chobie/libgit2

13 years agoGit does not like zero padded file attributes (git fsck)
John Wiegley [Mon, 7 Feb 2011 05:11:17 +0000 (00:11 -0500)]
Git does not like zero padded file attributes (git fsck)

13 years agoFurther correction to tree entry sorting (for git fsck)
John Wiegley [Mon, 7 Feb 2011 05:11:00 +0000 (00:11 -0500)]
Further correction to tree entry sorting (for git fsck)

13 years agofix can't detect repository index issues.
Shuhei Tanuma [Sun, 6 Feb 2011 06:48:52 +0000 (15:48 +0900)]
fix can't detect repository index issues.

13 years agoFix a memory leak in git__joinpath() tests.
nulltoken [Sun, 6 Feb 2011 06:48:17 +0000 (07:48 +0100)]
Fix a memory leak in git__joinpath() tests.

13 years agoFixed a small issue in git__join_path(). Added tests to exercise git__join_path().
nulltoken [Sat, 5 Feb 2011 18:22:44 +0000 (19:22 +0100)]
Fixed a small issue in git__join_path(). Added tests to exercise git__join_path().

13 years agoMade test index_write_test() remove the test file it has created.
nulltoken [Sat, 5 Feb 2011 16:18:27 +0000 (17:18 +0100)]
Made test index_write_test() remove the test file it has created.

It can now be run twice in a row without failing.

13 years agoMerge branch 'sqlite-backend'
Vicent Marti [Sat, 5 Feb 2011 17:49:42 +0000 (19:49 +0200)]
Merge branch 'sqlite-backend'

13 years agoAdd support for SQLite backends
Vicent Marti [Sat, 5 Feb 2011 17:45:57 +0000 (19:45 +0200)]
Add support for SQLite backends

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>
13 years agoMove data from t03 to a separate header
Vicent Marti [Sat, 5 Feb 2011 16:17:01 +0000 (18:17 +0200)]
Move data from t03 to a separate header

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoEnforced refs handling tests.
nulltoken [Sat, 5 Feb 2011 14:24:08 +0000 (15:24 +0100)]
Enforced refs handling tests.

 - Added a test to ensure that a nested symbolic reference is properly resolved.
 - Added comparisons of object ids.

13 years agoFixes a Win32/MSVC compilation issue.
nulltoken [Sat, 5 Feb 2011 14:03:48 +0000 (15:03 +0100)]
Fixes a Win32/MSVC compilation issue.

13 years agoAdd new utility method `git__joinpath`
Vicent Marti [Sat, 5 Feb 2011 11:12:02 +0000 (13:12 +0200)]
Add new utility method `git__joinpath`

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoFix directory/path manipulation methods
Vicent Marti [Sat, 5 Feb 2011 10:42:41 +0000 (12:42 +0200)]
Fix directory/path manipulation methods

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>
13 years agoMake more methods return error codes
Vicent Marti [Sat, 5 Feb 2011 07:29:37 +0000 (09:29 +0200)]
Make more methods return error codes

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>
13 years agoKeep the tree entries always internally sorted
Vicent Marti [Sat, 5 Feb 2011 07:11:17 +0000 (09:11 +0200)]
Keep the tree entries always internally sorted

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>
13 years agoMerge branch 'master' of https://github.com/jwiegley/libgit2
Vicent Marti [Sat, 5 Feb 2011 07:00:09 +0000 (09:00 +0200)]
Merge branch 'master' of https://github.com/jwiegley/libgit2

13 years agoUse Git's own tree entry sorting algorithm
John Wiegley [Thu, 3 Feb 2011 00:00:26 +0000 (19:00 -0500)]
Use Git's own tree entry sorting algorithm

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.

13 years agoFix more issues with Win32 EOL
Vicent Marti [Wed, 2 Feb 2011 04:16:50 +0000 (06:16 +0200)]
Fix more issues with Win32 EOL

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoFix EOL issues in ref parsing under Win32
Vicent Marti [Wed, 2 Feb 2011 02:01:14 +0000 (04:01 +0200)]
Fix EOL issues in ref parsing under Win32

Reference files can be loaded using Win32 line endings, too.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoMake the test return an error code on failure
Vicent Marti [Wed, 2 Feb 2011 00:32:21 +0000 (02:32 +0200)]
Make the test return an error code on failure

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoBuild the new test file with CMake too
Vicent Marti [Wed, 2 Feb 2011 00:31:58 +0000 (02:31 +0200)]
Build the new test file with CMake too

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoRewrite the unit testing suite
Vicent Marti [Wed, 2 Feb 2011 00:15:25 +0000 (02:15 +0200)]
Rewrite the unit testing suite

NIH Enterprises presents: a new testing system based on CuTesT, which is
faster than our previous one and fortunately uses no preprocessing on
the source files, which means we can run that from CMake.

The test suites have been gathered together into bigger files (one file
per suite, testing each of the different submodules of the library).

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoFixed bug where git__source_printf needs multiple attempts
John Wiegley [Tue, 1 Feb 2011 10:57:45 +0000 (05:57 -0500)]
Fixed bug where git__source_printf needs multiple attempts

13 years agoFixed a bug with the way commits are written
John Wiegley [Tue, 1 Feb 2011 10:00:52 +0000 (05:00 -0500)]
Fixed a bug with the way commits are written

13 years agoMake git_tree_clear_entries visible to the user
John Wiegley [Fri, 28 Jan 2011 07:41:59 +0000 (02:41 -0500)]
Make git_tree_clear_entries visible to the user

13 years agoAdded git_tree_add_entry_unsorted and git_tree_sort_entries
John Wiegley [Thu, 27 Jan 2011 19:20:23 +0000 (14:20 -0500)]
Added git_tree_add_entry_unsorted and git_tree_sort_entries

13 years agoAdd required includes in "oid.h"
Vicent Marti [Tue, 1 Feb 2011 01:21:53 +0000 (03:21 +0200)]
Add required includes in "oid.h"

The file was previously failing to be included stand-alone.

13 years agoRefactor reference parsing code
Vicent Marti [Fri, 28 Jan 2011 23:56:25 +0000 (01:56 +0200)]
Refactor reference parsing code

Several changes have been committed to allow the user to create
in-memory references and write back to disk. Peeling of symbolic
references has been made explicit. Added getter and setter methods for
all attributes on a reference. Added corresponding documentation.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoMerge nulltoken's reference parsing code
nulltoken [Mon, 27 Dec 2010 19:34:19 +0000 (20:34 +0100)]
Merge nulltoken's reference parsing code

All the commits have been squashed into a single one before refactoring
the final code, to keep everything tidy.

Individual commit messages are as follows:

Added repository reference looking up functionality placeholder.

Added basic reference database definition and caching infrastructure.

Removed useless constant.

Added GIT_EINVALIDREFNAME error and description. Added missing description for GIT_EBAREINDEX.

Added GIT_EREFCORRUPTED error and description.

Added GIT_ETOONESTEDSYMREF error and description.

Added resolving of direct and symbolic references.

Prepared the packed-refs parsing.

Added parsing of the packed-refs file content.

When no loose reference has been found, the full content of the packed-refs file is parsed. All of the new (i.e. not previously parsed as a loose reference) references are eagerly stored in the cached references storage.

The method packed_reference_file__parse() is in deer need of some refactoring. :-)

Extracted to a method the parsing of the peeled target of a tag.

Extracted to a method the parsing of a standard packed ref.

Fixed leaky removal of the cached references.

Ensured that a previously parsed packed reference isn't returned if a more up-to-date loose reference exists.

Enhanced documentation of git_repository_reference_lookup().

Moved some refs related constants from repository.c to refs.h.

Made parsing of a packed tag reference more robust.

Updated git_repository_reference_lookup() documentation.

Added some references to the test repository.

Added some tests covering tag references looking up.

Added some tests covering symbolic and head references looking up.

Added some tests covering packed references looking up.

13 years agoMade path prettifying functions return GIT_EINVALIDPATH instead of GIT_ERROR.
nulltoken [Wed, 26 Jan 2011 19:29:06 +0000 (20:29 +0100)]
Made path prettifying functions return GIT_EINVALIDPATH instead of GIT_ERROR.

13 years agoFixed naming convention related issue.
nulltoken [Tue, 25 Jan 2011 20:52:24 +0000 (21:52 +0100)]
Fixed naming convention related issue.

13 years agoMade git_repository_open2() and git_repository_open3() benefit from recently added...
nulltoken [Sun, 23 Jan 2011 18:01:57 +0000 (19:01 +0100)]
Made git_repository_open2() and git_repository_open3() benefit from recently added path prettifying function.

13 years agoAdded git_prettify_file_path().
nulltoken [Sun, 23 Jan 2011 15:15:11 +0000 (16:15 +0100)]
Added git_prettify_file_path().

13 years agoOptimized git_prettify_dir_path() parsing.
nulltoken [Sat, 22 Jan 2011 13:38:47 +0000 (14:38 +0100)]
Optimized git_prettify_dir_path() parsing.

13 years agoMade git_repository_open() and git_repository_init() benefit from recently added...
nulltoken [Fri, 21 Jan 2011 13:02:22 +0000 (14:02 +0100)]
Made git_repository_open() and git_repository_init() benefit from recently added path prettifying function.

13 years agoFixed a parsing issue in git_prettify_dir_path().
nulltoken [Sat, 22 Jan 2011 13:04:32 +0000 (14:04 +0100)]
Fixed a parsing issue in git_prettify_dir_path().

13 years agoReturn the created entry in git_tree_add_entry()
Vicent Marti [Sat, 29 Jan 2011 00:12:59 +0000 (02:12 +0200)]
Return the created entry in git_tree_add_entry()

Yes, we are breaking the API. Alpha software, deal with it.

We need a way of getting a pointer to each newly added entry to the
index, because manually looking up the entry after creation is
outrageously expensive.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoFix compilation on MinGW
Vicent Marti [Thu, 20 Jan 2011 23:57:13 +0000 (15:57 -0800)]
Fix compilation on MinGW

Require <sys/types.h> to find the definition for off64_t.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoFix initialization of in-memory trees
Vicent Marti [Thu, 20 Jan 2011 22:43:27 +0000 (14:43 -0800)]
Fix initialization of in-memory trees

In-memory tree objects were not being properly initialized, because the
internal entries vector was created on the 'parse' method.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoSmall enhancements to git_prettify_dir_path().
nulltoken [Thu, 20 Jan 2011 18:51:34 +0000 (19:51 +0100)]
Small enhancements to git_prettify_dir_path().

 - Secured buffer ahead reading.
 - Guard against potential multiple dot path traversal (cf http://cwe.mitre.org/data/definitions/33.html)

13 years agoFix signed/unsigned comparison warning
Vicent Marti [Thu, 20 Jan 2011 01:20:39 +0000 (17:20 -0800)]
Fix signed/unsigned comparison warning

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoMerge branch 'dir-path-prettifying' of https://github.com/nulltoken/libgit2
Vicent Marti [Thu, 20 Jan 2011 01:15:02 +0000 (17:15 -0800)]
Merge branch 'dir-path-prettifying' of https://github.com/nulltoken/libgit2

13 years agoSet proper shared library soname.
Sascha Peilicke [Tue, 18 Jan 2011 20:35:57 +0000 (21:35 +0100)]
Set proper shared library soname.

13 years agoAdd new Repository initialization method
Vicent Marti [Thu, 13 Jan 2011 02:54:14 +0000 (04:54 +0200)]
Add new Repository initialization method

Lets the user specify the ODB that will be used by the repository
manually.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoFix typo on Commit API
Vicent Marti [Thu, 13 Jan 2011 02:34:23 +0000 (04:34 +0200)]
Fix typo on Commit API

Proper function is 'git_commit_time_offset'.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoMove the compat definitions to types.h
Vicent Marti [Tue, 11 Jan 2011 23:42:07 +0000 (01:42 +0200)]
Move the compat definitions to types.h

Don't need a brand new header for two typedefs when we already have a
types.h header.

Change comment style to ANSI C.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoAdded git_prettify_dir_path().
nulltoken [Tue, 11 Jan 2011 19:12:53 +0000 (20:12 +0100)]
Added git_prettify_dir_path().

Clean up a provided absolute or relative directory path.

This prettification relies on basic operations such as coalescing multiple forward slashes into a single slash, removing '.' and './' current directory segments, and removing parent directory whenever '..' is encountered. If not empty, the returned path ends with a forward slash.

For instance, this will turn "d1/s1///s2/..//../s3" into "d1/s3/".

This only performs a string based analysis of the path. No checks are done to make sure the path actually makes sense from the file system perspective.

13 years agoRevised platform types to use 'best supported' size.
Alex Budovski [Tue, 11 Jan 2011 05:07:45 +0000 (16:07 +1100)]
Revised platform types to use 'best supported' size.

This will allow graceful migration to 64 bit file sizes and timestamps should
git's binary interface be extended to allow this.

13 years agoRemove unused variable.
Alex Budovski [Tue, 11 Jan 2011 06:50:37 +0000 (17:50 +1100)]
Remove unused variable.

13 years agoFix Windows build with forced bit truncation.
Alex Budovski [Mon, 10 Jan 2011 03:57:06 +0000 (14:57 +1100)]
Fix Windows build with forced bit truncation.

Windows uses a 64 bit time_t by default and assigning to unsigned int causes a
64 -> 32 bit truncation warning. This change forces the truncation,
acknowledging the implications detailed in the file comments. Also, blobs are
limited to 32 bit file sizes for the same reason (on all platforms).

13 years agoUse generic types in git_index_entry
Vicent Marti [Mon, 10 Jan 2011 03:01:38 +0000 (05:01 +0200)]
Use generic types in git_index_entry

Off_t is not cool. It can be 32 or 64 bits depending on the platform,
but on the Index format, it's always 32 bits.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoMerge branch 'master' of https://github.com/Neopallium/libgit2
Vicent Marti [Sat, 8 Jan 2011 20:24:28 +0000 (22:24 +0200)]
Merge branch 'master' of https://github.com/Neopallium/libgit2

13 years agoFixed two buffer handling errors in vector.c
Alex Budovski [Fri, 7 Jan 2011 00:35:43 +0000 (11:35 +1100)]
Fixed two buffer handling errors in vector.c

- remove() would read one-past array bounds.
- resize() would fail if the initial size was 1, because it multiplied by 1.75
  and truncated the resulting value. The buffer would always remain at size 1,
  but elements would repeatedly be appended (via insert()) causing a crash.

13 years agoRevised build configuration for MSVC.
Alex Budovski [Fri, 7 Jan 2011 01:07:15 +0000 (12:07 +1100)]
Revised build configuration for MSVC.

Major changes and rationale:
- /WX: absolutely vital when compiling in C-mode as the compiler is
  incredibly lenient on what is allowed to compile. It allows functions to be
  called without prototypes declared, treating them as functions returning int
  taking an unspecified (read: unrestricted) list of arguments, without any
  type checking! It will simply issue a warning, which is easily overlooked.

  A real example: it will allow you to call ceil(1.75) without first including
  <math.h> causing UB, returning bogus results like 1023 on the machine I
  tested on.

- Release build separate from debug.
  Presently release builds don't exist.  Consequently they are completely
  untested. Many bugs may only manifest themselves in release mode. The current
  configuration sets debug-only flags like /RTC1 which are incompatible with
  optimization (/O2).

  In addition, the Windows build of libgit2 has no optimized version. This
  change resolves this.

- Added checksum generation in image headers. This is so debuggers don't
  complain about checksum mismatches and provides a small amount of consistency
  to binaries.

13 years agoAdd Delphi bindings to the readme
Vicent Marti [Sat, 8 Jan 2011 19:54:14 +0000 (21:54 +0200)]
Add Delphi bindings to the readme

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoadded links to php and lua bindings
Scott Chacon [Sat, 8 Jan 2011 16:02:19 +0000 (08:02 -0800)]
added links to php and lua bindings

13 years agoFixed memory leak in git_commit__free().
Robert G. Jakabosky [Sat, 8 Jan 2011 10:22:22 +0000 (02:22 -0800)]
Fixed memory leak in git_commit__free().

13 years agoFind proper path to 'ldconfig' on wscript
Vicent Marti [Mon, 3 Jan 2011 23:17:07 +0000 (01:17 +0200)]
Find proper path to 'ldconfig' on wscript

Don't hardcode the '/sbin/ldconfig' path; also, don't run anything if
ldconfig cannot be found (Mac OS X, for instance).

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoSplit object methods from repository.c
Vicent Marti [Mon, 3 Jan 2011 20:34:27 +0000 (22:34 +0200)]
Split object methods from repository.c

All the relevant git_object methods have been moved to object.c

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoMake internal methods static
Vicent Marti [Mon, 3 Jan 2011 19:46:18 +0000 (21:46 +0200)]
Make internal methods static

Keep all the repository init code as static.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoMerge branch 'repo-init' of https://github.com/nulltoken/libgit2 into nulltoken-repo...
Vicent Marti [Mon, 3 Jan 2011 19:37:14 +0000 (21:37 +0200)]
Merge branch 'repo-init' of https://github.com/nulltoken/libgit2 into nulltoken-repo-init

13 years agoAdd generic hash function to util.c
Vicent Marti [Wed, 29 Dec 2010 22:31:58 +0000 (00:31 +0200)]
Add generic hash function to util.c

It's MurmurHash3 slightly edited to make it
cross-platform. Fast and neat.

Use this for hashing strings on hash tables instead
of a full SHA1 hash. It's very fast and well distributed.

Obviously not crypto-secure.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoFixed placement of pointer argument.
nulltoken [Sun, 26 Dec 2010 16:00:35 +0000 (17:00 +0100)]
Fixed placement of pointer argument.

13 years agoMerge branch 'master' into repo-init
nulltoken [Thu, 23 Dec 2010 08:22:15 +0000 (09:22 +0100)]
Merge branch 'master' into repo-init

13 years agoPrevent test manifests from being run
Vicent Marti [Wed, 22 Dec 2010 23:00:40 +0000 (01:00 +0200)]
Prevent test manifests from being run

The test runner was running the manifest and other crap files. Now it
filters out to just the executables.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoMerge branch 'call-ldconfig-on-unix' of https://github.com/marvil07/libgit2
Vicent Marti [Wed, 22 Dec 2010 22:49:34 +0000 (00:49 +0200)]
Merge branch 'call-ldconfig-on-unix' of https://github.com/marvil07/libgit2

13 years agoMerge branch 'waf-pkgconfig-typo' of https://github.com/marvil07/libgit2
Vicent Marti [Wed, 22 Dec 2010 22:48:35 +0000 (00:48 +0200)]
Merge branch 'waf-pkgconfig-typo' of https://github.com/marvil07/libgit2

13 years agoRevert "Properly export all external symbols in Win32"
Vicent Marti [Wed, 22 Dec 2010 22:44:41 +0000 (00:44 +0200)]
Revert "Properly export all external symbols in Win32"

It is not a good idea to export these internal symbols now that they are
not required to run the unit tests.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoLink tests with the raw objects
Vicent Marti [Wed, 22 Dec 2010 22:43:07 +0000 (00:43 +0200)]
Link tests with the raw objects

Fix the test building issues once for all; each test is linked
with the raw objects of the library, not with any compiled version. That
way we make sure the tests always run, and are always linked with the
latest and most up-to-date version of the code.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoRemove git_errno
Vicent Marti [Wed, 22 Dec 2010 22:15:09 +0000 (00:15 +0200)]
Remove git_errno

It was not being used by any methods (only by malloc and calloc), and
since it needs to be TLS, it cannot be exported on DLLs on Windows.

Burn it with fire. The API always returns error codes!

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoExport TLS symbols properly in Win32
Vicent Marti [Wed, 22 Dec 2010 20:51:24 +0000 (22:51 +0200)]
Export TLS symbols properly in Win32

There was no export definition for GIT_EXTERN_TLS() under MSVC.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoProperly export all external symbols in Win32
Vicent Marti [Wed, 22 Dec 2010 20:43:39 +0000 (22:43 +0200)]
Properly export all external symbols in Win32

Some external functions were not being exported because they were using
the 'extern' keyword instead of the generic GIT_EXTERN() macro.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoFix test builds in Win32
Vicent Marti [Wed, 22 Dec 2010 19:57:48 +0000 (21:57 +0200)]
Fix test builds in Win32

Use forward slashes for the TEST_RESOURCES definition. libgit2 uses only
forward slashes.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
13 years agoRun ldconfig on install at unix platforms.
Marco Villegas [Wed, 22 Dec 2010 18:39:13 +0000 (13:39 -0500)]
Run ldconfig on install at unix platforms.