Commit Graph

1171 Commits

Author SHA1 Message Date
Vicent Marti
6b1eab3976 Fix MSVC warnings and errors
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-24 00:23:15 +02:00
Vicent Marti
5dc2bee153 Fix compilation in Win32
Currently, libgit2 compiles and passes all tests under MinGW, and
compiles but fails the test suite on MSVC 2010.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-24 00:23:15 +02:00
Vicent Marti
e06551e51c Add library dependencies to the build
The libgit2 shared library must be linked with all the dynamic libraries
it depends (z, openssl).

These libraries are now automatically detected during the configuration
phase.

Also, removed the linking dependency on libgit2 which Scott added: if
you link libgit2 with itself, the universe could implode, and we don't
want that to happen.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-24 00:23:15 +02:00
Scott Chacon
1177708930 add waf artifacts to .gitignore 2010-11-24 00:23:14 +02:00
Scott Chacon
c34a044f4e add library includes, remove Makefile and readme update for waf 2010-11-24 00:23:14 +02:00
Vicent Marti
d910be2105 Add separate commands for all possible actions
The build script now supports all the required features

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-24 00:23:14 +02:00
Vicent Marti
b2898c4500 Add more features to the build system
- Windows 32 compilation
	- Test system
	- Shared and static libraries

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-24 00:23:14 +02:00
Vicent Marti
357547fa12 Change to waf as the buildsystem
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-24 00:23:14 +02:00
Vicent Marti
30b171a185 Change blob API to return temp refs to the content
If the user wants permanent references, he can duplicate the temporary
one manually.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-20 17:37:32 +02:00
Vicent Marti
69a09b7c69 Fix wrong pointer check in git__strdup
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-19 17:17:46 +02:00
Vicent Marti
c3dd69a9e1 Fix resizing the index array
No longer segfaults when resizing an empty array.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-17 05:16:32 +02:00
Vicent Marti
50dd6ca54c Fix repository initialization
We cannot assume that non-bare repositories have an index file, because
'git index' doesn't create it by default.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-17 05:16:26 +02:00
Vicent Marti
d7c7cab8a4 Fix memory leak in t0401
Commit object must be internally free'd after each parse attempt, even
it fails.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-16 03:25:26 +02:00
Vicent Marti
111e362263 Fix freeing blob objects from the ODB
The internal contents of the blob were being free'd but not the blob
object itself.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-16 03:24:39 +02:00
Vicent Marti
c3a20d5cab Add support for 'index add'
Actually add files to the index by creating their corresponding blob and
storing it on the repository, then getting the hash and updating the
index file.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-16 02:59:28 +02:00
Vicent Marti
7a3924fc38 Fix overcomplicated return statement
Note to self: don't be stupid

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-16 02:59:24 +02:00
Vicent Marti
237da40181 Add support for blob files
Blob files can now be loaded from the repository like all the other base
Git types.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-16 02:59:13 +02:00
Scott Chacon
0be421994e accessor for index entry count 2010-11-11 03:28:46 +02:00
Colin Timmermans
69f0295c80 Fix compiler warning in commit.c 2010-11-07 01:31:37 +02:00
Colin Timmermans
1081d90945 Fix parsing of commits that have no newlines in the message. 2010-11-07 01:31:28 +02:00
Scott Chacon
4b7483a285 add initial README file 2010-11-07 01:31:08 +02:00
Vicent Marti
3f43678e88 Make the Index API public
Several private methods of the Index API are now public, including the
methods to remove, get and add index entries.

All the methods only take an integer value for the position of the entry
to get/remove. To get or remove entries based on their path names, look
them up first using the git_index_find method.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-07 01:24:45 +02:00
Dave Borowitz
88d035bd15 Update commit_time along with committer. 2010-11-05 03:55:14 +02:00
Dave Borowitz
f24fa0880c Test that commit attributes are set correctly. 2010-11-05 03:55:14 +02:00
Vicent Marti
a8bfce69dc Add string descriptions for all error codes
Old descriptions have been updated and new ones have been added for the
'git_strerror' function.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-05 03:55:04 +02:00
Vicent Marti
1795f87952 Improve error handling
All initialization functions now return error codes instead of pointers.
Error codes are now properly propagated on most functions. Several new
and more specific error codes have been added in common.h

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-05 03:20:17 +02:00
Vicent Marti
1714826fa0 Force PIC on the Makefile
Added -fPIC (position-independent code) to the EXTRA_CFLAGS var in the
Makefile. Required in x64 when building the shared library.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-04 01:08:36 +02:00
Dave Borowitz
1544bc31ca Only require an index for non-bare repos. 2010-11-02 16:02:37 -07:00
Vicent Marti
6fd195d76c Change git_repository initialization to use a path
The constructor to git_repository is now called

	'git_repository_open(path)'

and takes a path to a git repository instead of an existing ODB object.
Unit tests have been updated accordingly and the two test repositories
have been merged into one.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-02 18:42:42 +02:00
Vicent Marti
d80e9d55aa Fix in-memory commit getters trying to parse
Issue 9 on the tracker. The commit object getters for in-memory objects
were trying to parse an inexistant on-disk object when one of the commit
attributes which were still not set was queried.

We now return a NULL value when this happens.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-10-31 06:05:53 +02:00
Vicent Marti
5745077557 Do a full parse on commits before modifying them
Before changing the attributes of a commit, make sure that the internal
status is consistent with the one in the repository.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-10-29 02:53:16 +03:00
Vicent Marti
a13bc8e74f Add getter methods for object owners
You can know access the owning repository of any existing object, or the
repository on which a revision walker is working on.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-10-29 02:22:38 +03:00
Vicent Marti
aaf68dc443 Add unit tests for git_odb_read_header
Test the new method by loading all the objects in the sample ODB with a
full-read and a header-only read, and comparing the types and sizes.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-10-29 00:47:53 +03:00
Vicent Marti
adc0327ab3 Add git_odb_read_header method to the ODB
As requested, git_odb_read_header looks up an object on the ODB, but loads
only the header information (type & size) without loading any of the
actual file contents in memory.

It is significantly faster than doing a git_odb_read if you only need an
object's information and not its contents.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-10-29 00:44:15 +03:00
Vicent Marti
585190183b Fix internal memory management on the library
String mememory is now managed in a much more sane manner.

Fixes include:

	- git_person email and name is no longer limited to 64 characters
	- git_tree_entry filename is no longer limited to 255 characters
	- raw objects are properly opened & closed the minimum amount of
	times required for parsing
	- unit tests no longer leak
	- removed 5 other misc memory leaks as reported by Valgrind
	- tree writeback no longer segfaults on rare ocassions

The git_person struct is no longer public. It is now managed by the
library, and getter methods are in place to access its internal
attributes.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-10-28 02:07:18 +03:00
Ramsay Jones
2d16373cb8 msvc: Fix an "conversion, possible loss of data" warning
In particular, msvc complains thus:

    t0603-sort.c(23) : warning C4244: 'function' : conversion from \
        'time_t' to 'unsigned int', possible loss of data

Note that msvc, by default, defines time_t as a 64-bit type, whereas
srand() is expecting an (32-bit) unsigned int. In order to suppress
the warning, we simply cast the return value of the time() function
call to 'unsigned int'.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-10-27 00:59:09 +03:00
Ramsay Jones
e30056275c bswap.h: Add ntohs() and htons() functions
Since commit 70aab459, the msvc and MinGW builds have relied on
the built-in implementation of ntohl() and htonl(), rather than
linking the wsock32 library. The new index manipulation code now
calls ntohs()/htons() in addition to ntohl()/htonl(), so we need
to provide a built-in implementation of the 16-bit functions.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-10-27 00:59:05 +03:00
Benjamin C Meyer
0d95f32c55 Change /* to /** at the start of comment blocks in public api so doxygen
will generate documenation and not hide them.

Signed-off-by: Benjamin C Meyer <ben@meyerhome.net>
2010-10-25 22:32:52 -07:00
Benjamin C Meyer
0037e4919b Fix spelling mistakes in the documentation.
Signed-off-by: Benjamin C Meyer <ben@meyerhome.net>
2010-10-25 16:53:17 -07:00
Benjamin C Meyer
544d15194a Remove whitespace from the end of the line in documentation.
Signed-off-by: Benjamin C Meyer <ben@meyerhome.net>
2010-10-25 16:46:55 -07:00
Vicent Marti
e4def81aab Fix issue 3 (memory corruption resize_tree_array)
The tree array wasn't being initialized when instantiating a tree object
in memory instead of loading it from disk.

New unit tests added to check for the problem.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-10-08 13:52:17 +03:00
Vicent Marti
0ba7a03186 Add unit tests for object write-back
Basic write-back & in-memory editing for objects is now tested in t0403
(commits), t0802 (tags) and t0902 (trees).

Add new helper functions in test_helpers.c to remove the loose objects
created when doing write-back tests.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-10-07 00:42:55 +03:00
Vicent Marti
ec25391dbb Add write-back support for Tag files
Tag files can now be created and modified in-memory (all the setter
methods have been implemented), and written back to disk using the
generic git_object_write() method.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-10-07 00:20:08 +03:00
Vicent Marti
c4b5bedc97 Fix possible segfaults in src/tree.c (issue 1)
git_tree_entry_byname was dereferencing a NULL pointer when the searched
file couldn't be found on the tree.

New test cases have been added to check for entry access methods.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-10-07 00:14:09 +03:00
Vicent Marti
2a884588b4 Add write-back support for git_tree
All the setter methods for git_tree have been added, including the
setters for attributes on each git_tree_entry and methods to add/remove
entries of the tree.

Modified trees and trees created in-memory from scratch can be written
back to the repository using git_object_write().

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-09-21 17:17:10 +03:00
Vicent Marti
d45b4a9a1b Add support for in-memory objects
All repository objects can now be created from scratch in memory using
either the git_object_new() method, or the corresponding git_XXX_new()
for each object.

So far, only git_commits can be written back to disk once created in
memory.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-09-20 21:39:11 +03:00
Vicent Marti
0c3596f18a Add setter methods & write support for git_commit
All the required git_commit_set_XXX methods have been implemented; all
the attributes of a commit object can now be modified in-memory.

The new method git_object_write() automatically writes back the
in-memory changes of any object to the repository. So far it only
supports git_commit objects.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-09-20 02:04:06 +03:00
Vicent Marti
e802d8cca8 Implement internal methods to write on sources
The new 'git__source_printf' does an overflow-safe printf on a source
bfufer.

The new 'git__source_write' does an overflow-safe byte write on a source
buffer.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-09-19 03:53:57 +03:00
Vicent Marti
f49a2e4981 Give object structures more descriptive names
The 'git_obj' structure is now called 'git_rawobj', since
it represents a raw object read from the ODB.

The 'git_repository_object' structure is now called 'git_object',
since it's the base object class for all objects.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-09-19 03:21:06 +03:00
Vicent Marti
a7a7ddbe0f Add generic methods for object writeback
git_repository_object has now several internal methods to write back the
object information in the repository.

- git_repository__dbo_prepare_write()
	Prepares the DBO object to be modified

- git_repository__dbo_write()
	Writes new bytes to the DBO object

- git_repository__dbo_writeback()
	Writes back the changes to the repository

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-09-18 19:16:04 +03:00