Commit Graph

352 Commits

Author SHA1 Message Date
Lambert CLARA
9d76b934f1 Fix wrong test in t04-commit
Replace all must_pass(strcmp()) by must_be_true(strcmp()==0)
2011-08-04 22:49:39 +02:00
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
5274c31a89 signature.c: fix off-by-one error
Signed-off-by: schu <schu-github@schulog.org>
2011-08-03 01:17:31 +02:00
Lambert CLARA
7d3ec3caac Fix memory leak when wrong object type is looked up from cache
Update unit test accordingly : no need to close
2011-08-02 19:23:00 +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
20a7e8208e Remove extra git_index_read from the tests
When you open an index with git_index_open, the file is read before
the function returns. Thus, calling git_index_read after that is
useless.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-07-26 15:53:52 +02:00
Kirill A. Shutemov
84ef7f3636 tests: fix cast warnings
/home/kas/git/public/libgit2/tests/t00-core.c: In function ‘test_cmp’:
/home/kas/git/public/libgit2/tests/t00-core.c:78:10: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/tests/t00-core.c:78:22: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/tests/t07-hashtable.c: In function ‘hash_func’:
/home/kas/git/public/libgit2/tests/t07-hashtable.c:42:7: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/tests/t08-tag.c: In function ‘_gittest__write0’:
/home/kas/git/public/libgit2/tests/t08-tag.c:141:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/tests/t08-tag.c: In function ‘_gittest__write2’:
/home/kas/git/public/libgit2/tests/t08-tag.c:192:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/tests/t08-tag.c: In function ‘_gittest__write3’:
/home/kas/git/public/libgit2/tests/t08-tag.c:227:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/tests/t04-commit.c: In function ‘_gittest__write0’:
/home/kas/git/public/libgit2/tests/t04-commit.c:650:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/tests/t04-commit.c:651:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/tests/t04-commit.c: In function ‘_gittest__root0’:
/home/kas/git/public/libgit2/tests/t04-commit.c:723:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/tests/t04-commit.c:724:21: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/tests/t12-repo.c: In function ‘write_file’:
/home/kas/git/public/libgit2/tests/t12-repo.c:360:24: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-25 21:12:47 +02:00
Vicent Martí
324f0eecb6 Merge pull request #325 from carlosmn/valgrind
More memory leaks
2011-07-13 18:03:12 -07:00
nulltoken
f4ad64c109 tree: fix insertion of entries with invalid filenames 2011-07-13 07:58:17 +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
d4760a42f9 status: refactor the tests to remove some code duplication 2011-07-12 22:20:15 +02:00
Carlos Martín Nieto
55e1609b2f Don't leak the buf when testing it
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-07-12 18:19:56 +02:00
Vicent Marti
b08683ffb2 config: Rename del to `delete 2011-07-12 02:38:20 +02:00
nulltoken
bfbb55628b tag: Add creation of lightweight tag 2011-07-11 19:42:21 +02:00
Vicent Marti
eb1fd1d0cb What the fuck was this doing in src? 2011-07-11 19:42:21 +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
Vicent Marti
c52736fa52 status: Cleanup
The `hashfile` function has been moved to ODB, next to `git_odb_hash`.

Global state has been removed from the dirent call in `status.c`,
because global state is killing the rainforest and causing global
warming.
2011-07-09 15:05:14 +02:00
Jason Penny
3b2a423c3f status: nonexistent file with git_status_file()
Throws GIT_ENOTFOUND error if given a filename that is not in
HEAD, index, nor the work tree.
2011-07-09 13:49:50 +02:00
Jason Penny
2b90cc26de status: consolidate some test code
Refactored copy of test repo to a function.
2011-07-09 13:49:50 +02:00
Jason Penny
34dfea2774 status: handle subdirs for git_status_file 2011-07-09 13:49:50 +02:00
Jason Penny
6b251490a8 status: add subdir to test repo 2011-07-09 13:49:50 +02:00
Jason Penny
20361b2f69 status: get status for single file
Add git_status_file to be able to retrieve status of single file by
supplying a path.
2011-07-09 13:49:50 +02:00
Jason Penny
3af6b34a76 status: get file statuses and run callback
Add git_status_foreach() to run a callback on each file passing the path
and a status value.
2011-07-09 13:49:50 +02:00
Jason Penny
210940da84 status: new test repo 2011-07-09 13:49:50 +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
Jason Penny
7361857c50 Update tests/NAMING 2011-07-09 13:49:49 +02:00
Vicent Marti
06c43821b9 Remove unused methods
The direct-writes commit left some (slow) internals methods that
were no longer needed. These have been removed.

Also, the Reflog code was using the old `git_signature__write`, so
it has been rewritten to use a normal buffer and the new `writebuf`
signature writer. It's now slightly simpler and faster.
2011-07-09 02:40:16 +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
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
nulltoken
2b5af615e1 tag: add pattern based retrieval of list of tag names 2011-07-07 15:37:07 +02:00
Vicent Marti
c1e857484e test-core: Fix warning in uniq test 2011-07-07 12:23:47 +02:00
nulltoken
bdcc46111c Fix MSVC compilation warnings 2011-07-07 12:12:34 +02:00
Vicent Marti
de18f27668 vector: Timsort all of the things
Drop the GLibc implementation of Merge Sort and replace it with Timsort.

The algorithm has been tuned to work on arrays of pointers (void **),
so there's no longer a need to abstract the byte-width of each element
in the array.

All the comparison callbacks now take pointers-to-elements, not
pointers-to-pointers, so there's now one less level of dereferencing.

E.g.

	 int index_cmp(const void *a, const void *b)
	 {
	-	const git_index_entry *entry_a = *(const git_index_entry **)(a);
	+	const git_index_entry *entry_a = (const git_index_entry *)(a);

The result is up to a 40% speed-up when sorting vectors. Memory usage
remains lineal.

A new `bsearch` implementation has been added, whose callback also
supplies pointer-to-elements, to uniform the Vector API again.
2011-07-07 02:54:07 +02:00
Vicent Marti
c63aa49459 test: Abort when the temp workdir cannot be created 2011-07-07 02:54:07 +02:00
nulltoken
26911cbd92 Fix MSVC compilation warnings 2011-07-06 12:27:51 -07:00
Vicent Martí
bf9a2e98b8 Merge pull request #296 from kiryl/index-optimization
Index optimization
2011-07-06 10:55:06 -07:00
Vicent Marti
858dba58bf refs: Cleanup reference renaming
`git_futils_rmdir_r`: rename, clean up.

`git_reference_rename`: cleanup. Do not use 3x4096 buffers on the stack
or things will get ugly very fast. We can reuse the same buffer.
2011-07-06 18:08:13 +02:00
nulltoken
1b938a5826 Remove duplicated recursive directory removal related code 2011-07-06 12:25:27 +02:00
nulltoken
1ee5fd903d Fix windows specific issues
- msvc compilation warnings
 - not released file handle that prevents file removal
2011-07-06 12:25:27 +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
7ea50f6077 Add tests for git_futils_rmdir_resurs()
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
Carlos Martín Nieto
7a7ef2dceb Restore config10 test file
Removing a section variable doesn't remove its section
header. Overwrite the config10 file so there are no changes after the
test is run.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-07-05 17:47:10 +02:00
Kirill A. Shutemov
476c42acc5 vector: implement git_vector_uniq()
The routine remove duplictes from the vector. Only the last added element
of elements with equal keys remains in the vector.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-05 17:52:39 +03:00
Vicent Martí
f12aa9dc5e Merge pull request #300 from carlosmn/gsoc2011/master
A bit of networking
2011-07-05 04:31:37 -07:00
Carlos Martín Nieto
7d69f78897 Add variable writing tests
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-07-05 02:32:18 +02:00
Carlos Martín Nieto
156af801e6 Add test for section header at end of file
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-07-05 02:32:18 +02:00
Carlos Martín Nieto
2601fcfc1e Add tests for deleting a config var
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-07-05 02:32:17 +02:00
nulltoken
a01acc47bb signature: straighten the creation of a signature
- Fails on empty name and/or email
 - Trims leading and trailing spaces of name and email
2011-07-05 02:21:26 +02:00