Commit Graph

23 Commits

Author SHA1 Message Date
Vicent Marti
9462c47143 repository: Change ownership semantics
The ownership semantics have been changed all over the library to be
consistent. There are no more "borrowed" or duplicated references.

Main changes:

	- `git_repository_open2` and `3` have been dropped.

	- Added setters and getters to hotswap all the repository owned
	objects:

		`git_repository_index`
		`git_repository_set_index`
		`git_repository_odb`
		`git_repository_set_odb`
		`git_repository_config`
		`git_repository_set_config`
		`git_repository_workdir`
		`git_repository_set_workdir`

	Now working directories/index files/ODBs and so on can be
	hot-swapped after creating a repository and between operations.

	- All these objects now have proper ownership semantics with
	refcounting: they all require freeing after they are no longer
	needed (the repository always keeps its internal reference).

	- Repository open and initialization has been updated to keep in
	mind the configuration files. Bare repositories are now always
	detected, and a default config file is created on init.

	- All the tests affected by these changes have been dropped from the
	old test suite and ported to the new one.
2011-11-26 08:37:08 +01:00
Brodie Rao
ce8cd006ce fileops/repository: create (most) directories with 0777 permissions
To further match how Git behaves, this change makes most of the
directories libgit2 creates in a git repo have a file mode of
0777. Specifically:

- Intermediate directories created with git_futils_mkpath2file() have
  0777 permissions. This affects odb_loose, reflog, and refs.

- The top level folder for bare repos is created with 0777
  permissions.

- The top level folder for non-bare repos is created with 0755
  permissions.

- /objects/info/, /objects/pack/, /refs/heads/, and /refs/tags/ are
  created with 0777 permissions.

Additionally, the following changes have been made:

- fileops functions that create intermediate directories have grown a
  new dirmode parameter. The only exception to this is filebuf's
  lock_file(), which unconditionally creates intermediate directories
  with 0777 permissions when GIT_FILEBUF_FORCE is set.

- The test runner now sets the umask to 0 before running any
  tests. This ensurses all file mode checks are consistent across
  systems.

- t09-tree.c now does a directory permissions check. I've avoided
  adding this check to other tests that might reuse existing
  directories from the prefabricated test repos. Because they're
  checked into the repo, they have 0755 permissions.

- Other assorted directories created by tests have 0777 permissions.
2011-10-14 16:04:34 -07:00
Carlos Martín Nieto
6e6ec54beb Force the test's main function to use cdecl under Windows
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-06 16:33:24 +02:00
Jason Penny
205166d27c status: get blob object id of file on disk
Add git_status_hashfile() to get blob's object id for a file without adding
it to the object database or needing a repository at all.
This functionality is similar to `git hash-object` without '-w'.
2011-07-09 13:49:50 +02:00
Vicent Marti
afeecf4f26 odb: Direct writes are back
DIRECT WRITES ARE BACK AND FASTER THAN EVER. The streaming writer to the
ODB was an overkill for the smaller objects like Commit and Tags; most
of the streaming logic was taking too long.

This commit makes Commits, Tags and Trees to be built-up in memory, and
then written to disk in 2 pushes (header + data), instead of streaming
everything.

This is *always* faster, even for big files (since the git_filebuf class
still does streaming writes when the memory cache overflows). This is
also a gazillion lines of code smaller, because we don't have to
precompute the final size of the object before starting the stream (this
was kind of defeating the point of streaming, anyway).

Blobs are still written with full streaming instead of loading them in
memory, since this is still the fastest way.

A new `git_buf` class has been added. It's missing some features, but
it'll get there.
2011-07-09 02:40:16 +02:00
Carlos Martín Nieto
a030ae5020 Add a test for remote parsing
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:10 +02:00
Vicent Marti
b023321669 Remove custom backends
All the custom backend code will be moved to a separate project,
	together with the new MySQL backend.
2011-06-14 17:40:17 +02:00
Carlos Martín Nieto
55c197cdd3 Merge upstream/development 2011-04-11 17:43:56 +02:00
Dmitry Kovega
8a64bc292c redis backend 2011-04-08 03:27:01 +03:00
Carlos Martín Nieto
0bf8ca8820 config: add tests
These tests are basic, but they should tell us when we've broken
something.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-04 16:44:23 +02:00
Vicent Marti
bb3de0c472 Thread safe cache 2011-03-20 21:45:06 +02:00
Vicent Marti
3dccfed163 Cleanup the testing toolkit
Tests are now declared with detailed descriptions and a short test name:

	BEGIN_TEST(the_test0, "this is an example test that does something")
		...
	END_TEST

Modules are declared through a simple macro interface:

	BEGIN_MODULE(mod_name)
		ADD_TEST(the_test0);
		...
	END_MODULE

Error messages when tests fail have been greatly improved.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:52 +02: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
c041af95a2 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>
2011-02-05 19:45:57 +02:00
Vicent Marti
87d82994be Make the test return an error code on failure
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-02 02:32:21 +02:00
Vicent Marti
2a1732b439 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>
2011-02-02 02:15:25 +02:00
Peter Drahos
5b8bb8e7c6 Minor modifications for MinGW/Cygwin compatibility. 2010-12-12 00:20:31 +02:00
Vicent Marti
599955586d Fix segfault handler in Mac OS X
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-12-02 21:48:03 +02:00
Vicent Marti
1e35f929ef Add stack trace to the tests when building with GCC
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-12-02 04:19:14 +02:00
Ramsay Jones
cf33ac7a3d Makefile: Add CFLAGS to the "test_main.c" compile target
Also, add the <string.h> include to test_main.c, in order to
suppress the resulting "implicit declaration of strcmp()" warning.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Andreas Ericsson <ae@op5.se>
2009-06-05 12:12:42 +02:00
Shawn O. Pearce
b81dd80e8c Change test_main to run a single test case out of the suite
By passing the name of the test function on the command line
we execute exactly that one test, and then exit successfully
if the test did not fail.  This permits multiple functions in
the same .c file, so they could be called from a shell script
or debugged independently externally.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-03 18:42:54 -08:00
Shawn O. Pearce
b923f2f97d Fix Makefile to correctly handle 'make -j4 test'
If we have more than one test build running we cannot use the same
file for each test case; instead we need to use a per-test path so
there aren't any collisions.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-03 18:42:54 -08:00
Shawn O. Pearce
15bffce9f7 Create a basic test suite for the library and test oid functions
This is a horribly simple test suite that makes it fairly easy to
put together some basic function level unit tests on the library.
Its patterned somewhat after the test suite in git.git, but also
after the "Check" test library.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-01 18:24:39 -07:00