Commit Graph

58 Commits

Author SHA1 Message Date
schu
63396a3998 signature: adjust API to return error codes
git_signature_new() and git_signature_now() currently don't return error
codes. Change the API to return error codes and not pointers to let the
user handle errors properly.

Signed-off-by: schu <schu-github@schulog.org>
2011-08-03 16:05:32 +02:00
schu
eed2714ba5 reflog: avoid users writing a wrong ancestor OID
Disallow NULL as ancestor OID when writing a reflog entry for an
existing reference.

Signed-off-by: schu <schu-github@schulog.org>
2011-08-01 17:02:42 +02:00
Carlos Martín Nieto
cd0fe1ac27 Free sig in reflog test
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-07-13 00:23:15 +02:00
nulltoken
7757be33a2 reflog: Fix reflog writer/reader
- Use a space to separate oids and signature
 - Enforce test coverage
 - Make test run in a temporary folder in order not to alter the test repository
2011-07-10 19:17:07 +02:00
schu
27df4275f2 reflog: add API to read or write a reference log
So far libgit2 didn't support reference logs (reflog). Add a new
git_reflog_* API for basic reading and writing of reflogs:

* git_reflog_read
* git_reflog_write
* git_reflog_free

Signed-off-by: schu <schu-github@schulog.org>
2011-07-09 02:40:16 +02:00
nulltoken
6d4f090df6 reference_renaming: add additional tests
Add some more test checking forced reference renaming.

Signed-off-by: nulltoken <emeric.fermas@gmail.com>
Acked-by: schu <schu-github@schulog.org>
2011-07-07 21:29:14 +02:00
schu
0ffcf78a30 reference_rename: git compliant reference renaming
So far libgit2 didn't handle the following scenarios:

* Rename of reference m   -> m/m
* Rename of reference n/n -> n

Fixed.

Since we don't write reflogs, we have to delete any old reflog for the
renamed reference. Otherwise git.git will possibly fail when it finds
invalid logs.

Reported-by: nulltoken <emeric.fermas@gmail.com>
Signed-off-by: schu <schu-github@schulog.org>
2011-07-06 12:25:27 +02:00
schu
a6e0f315f5 Add test case checking renaming of a branch to a new name prefixed with
the old name succeeds, e.g. refs/heads/foo -> refs/heads/foo/bar

Reported-by: nulltoken <emeric.fermas@gmail.com>
Signed-off-by: schu <schu-github@schulog.org>
2011-07-06 12:25:27 +02:00
Vicent Marti
f79026b491 fileops: Cleanup
Cleaned up the structure of the whole OS-abstraction layer.

fileops.c now contains a set of utility methods for file management used
by the library. These are abstractions on top of the original POSIX
calls.

There's a new file called `posix.c` that contains
emulations/reimplementations of all the POSIX calls the library uses.
These are prefixed with `p_`. There's a specific posix file for each
platform (win32 and unix).

All the path-related methods have been moved from `utils.c` to `path.c`
and have their own prefix.
2011-07-05 02:04:03 +02:00
Kirill A. Shutemov
932d1baf29 cleanup: remove trailing spaces
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-01 18:02:56 +02:00
Vicent Marti
7376ad9927 refs: Remove duplicate rename method
`git_reference_rename` now takes a `force` flag
2011-06-29 11:01:35 +02:00
Vicent Marti
d5afc0390c Remove redundant methods from the API
A bunch of redundant methods have been removed from the external API.

- All the reference/tag creation methods with `_f` are gone. The force
flag is now passed as an argument to the normal create methods.

- All the different commit creation methods are gone; commit creation
now always requires a `git_commit` pointer for parents and a `git_tree`
pointer for tree, to ensure that corrupted commits cannot be generated.

- All the different tag creation methods are gone; tag creation now
always requires a `git_object` pointer to ensure that tags are not
created to inexisting objects.
2011-06-28 19:36:27 +02:00
Vicent Marti
3101a3e5b8 refs: Do not overflow when normalizing refnames 2011-06-23 02:29:11 +02:00
Vicent Marti
fa48608ec3 oid: Rename methods
Yeah. Finally. Fuck the old names, this ain't POSIX
and they don't make any sense at all.
2011-06-16 02:36:21 +02:00
Vicent Marti
9d77d83a81 Revert "threads: Fix TLS declarations"
This commit uploaded an old broken test. Oops!
2011-06-07 03:38:09 +02:00
Vicent Martí
2c9e7fa35e Merge pull request #232 from schu/ref-available-cb
reference_rename: respect all references v2
2011-06-06 18:24:37 -07:00
Vicent Marti
64fe8c62f9 threads: Fix TLS declarations
Cleanup the thread-utils file. Do not define TLS if libgit2 is not
threadsafe.
2011-06-07 03:22:32 +02:00
schu
fd21c6f67f Add test case checking we do not corrupt the repository when renaming
Signed-off-by: schu <schu-github@schulog.org>
2011-06-05 19:20:57 +02:00
schu
286349c6ec Fix tiny typo
Signed-off-by: nulltoken <emeric.fermas@gmail.com>
Signed-off-by: schu <schu-github@schulog.org>
2011-05-29 20:15:27 +02:00
Carlos Martín Nieto
bbd68c6768 ref test: update a forgotten repo -> repo2
Commit 34e5d87e05 left one of these unchanged we're trying
to read from a free'd repository.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-05-05 11:40:39 +02:00
nulltoken
34e5d87e05 Change implementation of refs tests that alter the current repository to make them run against a temporary clone of the test repository 2011-05-01 21:35:32 +02:00
Carlos Martín Nieto
2fe3692c23 tests: don't leak objects
If we don't create any leaks in the tests, we can use them to search
for leaks in the implementation.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-13 21:50:11 +02:00
Vicent Marti
d79f1da65a refs: Fix issue when packing weak tags
Weak tags (e.g. tags that point directly to a normal object instead of a
tag object) were failing to be packed.
2011-04-08 12:14:33 -07:00
nulltoken
f3564e1e29 Fix tag reference name in testrepo.git
The git test repository was holding a wrongly named tag reference ("very-simple") pointing at a tag named "e90810b".
This mistake (mine :-/ ) originates back to https://github.com/libgit2/libgit2/commit/9282e92

Whole credit goes to @tclem for having spotted this.
2011-04-04 13:12:23 +03:00
nulltoken
2b9b99b6ed Add test ensuring one can not create an oid reference which targets at an unknown id 2011-03-29 21:29:30 +02:00
nulltoken
4d00dfd438 Replace gitfo_unlink() calls with git_reference_delete() in refs related tests 2011-03-29 21:21:47 +02:00
Carlos Martín Nieto
553fbd640f Check for looser reference names
res/dummy/a and refs/stash must pass. The other rules are already
tested by the rest of the checks.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:19 +03:00
Vicent Marti
95cde17ca4 Enforce coding conventions in refs.c
Internal methods are static and without the git prefix.
'Force' methods have a `_f` prefix to match the other 'force' methods.
2011-03-29 19:58:19 +03:00
Carlos Martín Nieto
fc1eeb9dfc Make overwrite test more comprehensive
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:19 +03:00
Carlos Martín Nieto
ec99193655 force-rename test: check for the right name
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:19 +03:00
Carlos Martín Nieto
591a9423f5 Add tests covering overwriting references
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:18 +03:00
Vicent Marti
b5abb881a6 Do not segfault when listing unpacked references 2011-03-15 19:55:01 +02:00
Vicent Marti
7ad96e51ca Remove duplicate refs in git_reference_listall 2011-03-15 05:38:50 +02:00
Vicent Marti
0057182807 Add new method git_reference_listall
Lists all the references in a repository. Listing may be filtered by
reference type.

This should applease Lord Clem.
2011-03-14 23:52:32 +02:00
Vicent Marti
5de079b86d Change the object creation/lookup API
The methods previously known as

	git_repository_lookup
	git_repository_newobject
	git_repository_lookup_ref

are now part of their respective namespaces:

	git_object_lookup
	git_object_new
	git_reference_lookup

This makes the API more consistent with the new references API.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:52 +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
nulltoken
8fc050961c Add test deleteref::deleting_a_ref_which_is_both_packed_and_loose_should_remove_both_tracks_in_the_filesystem() 2011-03-03 20:23:52 +02:00
nulltoken
d561403f08 Add test for corner case in reference renaming 2011-03-03 20:23:52 +02:00
nulltoken
268bee3d4f Add test renameref::rename_a_loose_reference() 2011-03-03 20:23:52 +02:00
nulltoken
6b02b21516 Add test renameref::can_not_rename_a_reference_with_an_invalid_name() 2011-03-03 20:23:51 +02:00
nulltoken
65cc1f44e1 Add test renameref::can_not_rename_a_reference_with_an_invalid_name() 2011-03-03 20:23:51 +02:00
nulltoken
de05ff6c78 Add test renameref::renaming_a_packed_reference_makes_it_loose() 2011-03-03 20:23:51 +02:00
nulltoken
52b2c2092a Enhance the packrefs::create_packfile() test 2011-03-03 20:23:51 +02:00
nulltoken
e4029c5201 Added copydir_recurs() to test_helpers.c
Test helper function which recursively copies the content of a
directory. This function has been tweaked to prevent stack overflows by
reusing the same path buffers on all recursive calls.
2011-03-03 20:23:51 +02:00
nulltoken
c38f9013e4 Removed a duplicate constant. 2011-03-03 20:23:50 +02:00
Vicent Marti
87d3acf45e Finish the References API
The following methods have been implemented:

	git_reference_packall
	git_reference_rename
	git_reference_delete

The library now has full support for packed references, including
partial and total writing. Internal documentation has been updated with
the details.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:50 +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
nulltoken
2de3b35cd4 Added test covering creation of nested symbolic references. 2011-03-03 20:23:49 +02:00