summaryrefslogtreecommitdiff
path: root/tests/t00-core.c
Commit message (Collapse)AuthorAgeFilesLines
* Removing test suites that have been ported to Clar:Ben Straub2012-03-311-636/+0
| | | | | | | | | | | | | | | | | * t00 / 6e86fb3 (mentioned in #406) * t01 / fc60c4a (mentioned in #406) * t03 / bcbabe6 * t04 / PR #606 * t05 / d96f2c3 * t06 / 6c106ee * t07 / 2ef582b * t08 / b482c42 * t09 / 9a39a36 * t10 / 00a4893 * t12 / 7c3a4a7 * t13 / 1cb9b31 * t17 / cdaa6ff (mentioned in #406) * t18 / efabc08
* Clean up GIT_UNUSED macros on all platformsRussell Belfer2012-03-021-3/+3
| | | | | | | | | | | | | | | | | | | It turns out that commit 31e9cfc4cbcaf1b38cdd3dbe3282a8f57e5366a5 did not fix the GIT_USUSED behavior on all platforms. This commit walks through and really cleans things up more thoroughly, getting rid of the unnecessary stuff. To remove the use of some GIT_UNUSED, I ended up adding a couple of new iterators for hashtables that allow you to iterator just over keys or just over values. In making this change, I found a bug in the clar tests (where we were doing *count++ but meant to do (*count)++ to increment the value). I fixed that but then found the test failing because it was not really using an empty repo. So, I took some of the code that I wrote for iterator testing and moved it to clar_helpers.c, then made use of that to make it easier to open fixtures on a per test basis even within a single test file.
* Simplify GIT_UNUSED macrosRussell Belfer2012-03-021-2/+2
| | | | | | | Since casting to void works to eliminate errors with unused parameters on all platforms, avoid the various special cases. Over time, it will make sense to eliminate the GIT_UNUSED macro completely and just have GIT_UNUSED_ARG.
* Move path related functions from fileops to pathRussell Belfer2012-01-171-7/+7
| | | | | | | | | | | This takes all of the functions that look up simple data about paths (such as `git_futils_isdir`) and moves them over to path.h (becoming `git_path_isdir`). This leaves fileops.h just with functions that actually manipulate the filesystem or look at the file contents in some way. As part of this, the dir.h header which is really just for win32 support was moved into win32 (with some minor changes).
* Use git_buf for path storage instead of stack-based buffersRussell Belfer2011-12-071-68/+76
| | | | | | | | | | | | | | | | | | | | This converts virtually all of the places that allocate GIT_PATH_MAX buffers on the stack for manipulating paths to use git_buf objects instead. The patch is pretty careful not to touch the public API for libgit2, so there are a few places that still use GIT_PATH_MAX. This extends and changes some details of the git_buf implementation to add a couple of extra functions and to make error handling easier. This includes serious alterations to all the path.c functions, and several of the fileops.c ones, too. Also, there are a number of new functions that parallel existing ones except that use a git_buf instead of a stack-based buffer (such as git_config_find_global_r that exists alongsize git_config_find_global). This also modifies the win32 version of p_realpath to allocate whatever buffer size is needed to accommodate the realpath instead of hardcoding a GIT_PATH_MAX limit, but that change needs to be tested still.
* filebuf: add GIT_FILEBUF_INIT and protect multiple opens and cleanupsRussell Belfer2011-11-221-3/+3
| | | | | | | | Update all stack allocations of git_filebuf to use GIT_FILEBUF_INIT and make git_filebuf_open and git_filebuf_cleanup safe to be called multiple times on the same buffer. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Merge pull request #456 from brodie/perm-fixesVicent Martí2011-10-281-13/+13
|\ | | | | Create objects, indexes, and directories with the right file permissions
| * *: correct and codify various file permissionsBrodie Rao2011-10-141-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following files now have 0444 permissions: - loose objects - pack indexes - pack files - packs downloaded by fetch - packs downloaded by the HTTP transport And the following files now have 0666 permissions: - config files - repository indexes - reflogs - refs This brings libgit2 more in line with Git. Note that git_filebuf_commit() and git_filebuf_commit_at() have both gained a new mode parameter. The latter change fixes an important issue where filebufs created with GIT_FILEBUF_TEMPORARY received 0600 permissions (due to mkstemp(3) usage). Now we chmod() the file before renaming it into place. Tests have been added to confirm that new commit, tag, and tree objects are created with the right permissions. I don't have access to Windows, so for now I've guarded the tests with "#ifndef GIT_WIN32".
| * fileops/repository: create (most) directories with 0777 permissionsBrodie Rao2011-10-141-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | global: Properly use `git__` memory wrappersVicent Marti2011-10-281-4/+4
|/ | | | | Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
* core: One last `long long`Vicent Marti2011-09-301-2/+2
|
* config: make git_config_[get|set]_long() able to properly deal with 8 bytes ↵nulltoken2011-09-221-0/+44
| | | | | | | | wide values Should fix issue #419. Signed-off-by: nulltoken <emeric.fermas@gmail.com>
* CMakefile: add -Wstrict-prototypes and fix warningsKirill A. Shutemov2011-08-301-1/+1
| | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* tests: fix cast warningsKirill A. Shutemov2011-07-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | /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>
* test-core: Fix warning in uniq testVicent Marti2011-07-071-6/+17
|
* Fix MSVC compilation warningsnulltoken2011-07-071-1/+1
|
* vector: Timsort all of the thingsVicent Marti2011-07-071-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix MSVC compilation warningsnulltoken2011-07-061-6/+6
|
* Merge pull request #296 from kiryl/index-optimizationVicent Martí2011-07-061-0/+23
|\ | | | | Index optimization
| * vector: implement git_vector_uniq()Kirill A. Shutemov2011-07-051-0/+23
| | | | | | | | | | | | | | 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>
* | refs: Cleanup reference renamingVicent Marti2011-07-061-3/+3
| | | | | | | | | | | | | | `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.
* | Remove duplicated recursive directory removal related codenulltoken2011-07-061-3/+3
| |
* | Fix windows specific issuesnulltoken2011-07-061-2/+3
| | | | | | | | | | - msvc compilation warnings - not released file handle that prevents file removal
* | Add tests for git_futils_rmdir_resurs()schu2011-07-061-0/+53
|/ | | | Signed-off-by: schu <schu-github@schulog.org>
* fileutils: Finish dropping the old `prettify_path`Vicent Marti2011-07-051-234/+0
|
* fileops: CleanupVicent Marti2011-07-051-41/+41
| | | | | | | | | | | | | | | | 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.
* cleanup: remove trailing spacesKirill A. Shutemov2011-07-011-1/+1
| | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* filebuf: fix endless loop on writing buf > WRITE_BUFFER_SIZEKirill A. Shutemov2011-06-301-0/+14
| | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* Add test case checking GIT_FILEBUF_APPENDschu2011-06-201-0/+18
| | | | Signed-off-by: schu <schu-github@schulog.org>
* Fix filebuf0 test which was failing on Windowsnulltoken2011-06-121-1/+4
|
* Add test for git_filebuf_open error codeCarlos Martín Nieto2011-06-071-0/+12
| | | | Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* Fileops: Added a fourth argument to the path prettifying functions to use an ↵unknown2011-06-031-3/+3
| | | | | | alternate basepath. Fixed a Windows TO-DO in the prettifying functions.
* Fix path normalization testsVicent Marti2011-04-101-2/+2
| | | | | They were backtracking too deep into the filesystem on Linux, where the tests were running directly on `tmp/`.
* Fix detection of attempt to escape the root directory on Windowsnulltoken2011-03-231-0/+32
|
* Change gitfo_prettify_dir_path() and gitfo_prettify_file_path() behaviornulltoken2011-03-231-155/+172
| | | | Those functions now return prettified rooted path.
* Add proper threading support to libgit2Vicent Marti2011-03-151-13/+0
| | | | | | | We now depend on libpthread on all Unix platforms (should be installed by default) and use a simple wrapper for Windows threads under Win32. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix searching in git_vectorVicent Marti2011-03-031-2/+2
| | | | | | | | | | | | | | | | | | We now store only one sorting callback that does entry comparison. This is used when sorting the entries using a quicksort, and when looking for a specific entry with the new search methods. The following search methods now exist: git_vector_search(vector, entry) git_vector_search2(vector, custom_search_callback, key) git_vector_bsearch(vector, entry) git_vector_bsearch2(vector, custom_search_callback, key) The sorting state of the vector is now stored internally. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Cleanup the testing toolkitVicent Marti2011-03-031-65/+58
| | | | | | | | | | | | | | | | | | | 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>
* Slightly changed the behavior of git__joinpath() and git__joinpath_n().nulltoken2011-03-031-2/+21
|
* Added some dirname and basename tests to ensure that trailing slashes are ↵nulltoken2011-03-031-0/+5
| | | | ignored.
* Improve the performance when writing Index filesVicent Marti2011-02-171-1/+1
| | | | | | | | | | | | | | 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>
* Use the new git__joinpath to build paths in methodsVicent Marti2011-02-091-16/+6
| | | | | | | | | | | | | | | | | 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>
* Fix a memory leak in git__joinpath() tests.nulltoken2011-02-061-0/+2
|
* Fixed a small issue in git__join_path(). Added tests to exercise ↵nulltoken2011-02-051-0/+29
| | | | git__join_path().
* Fix directory/path manipulation methodsVicent Marti2011-02-051-41/+57
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Rewrite the unit testing suiteVicent Marti2011-02-021-0/+596
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>