summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* Use git_buf for path storage instead of stack-based buffersRussell Belfer2011-12-076-156/+212
| | | | | | | | | | | | | | | | | | | | 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.
* Plug a bunch of leaksCarlos Martín Nieto2011-11-283-3/+39
|
* tests: Add `refs` folder to the `bad_tag.git` repoVicent Marti2011-11-261-0/+0
|
* Rename all `_close` methodsVicent Marti2011-11-265-40/+40
| | | | | There's no difference between `_free` and `_close` semantics: keep everything with the same name to avoid confusions.
* repository: Change ownership semanticsVicent Marti2011-11-268-1705/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* filebuf: add GIT_FILEBUF_INIT and protect multiple opens and cleanupsRussell Belfer2011-11-223-5/+5
| | | | | | | | 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>
* Implement p_renameCarlos Martín Nieto2011-11-071-9/+9
| | | | | | Move the callers of git_futils_mv_atomic to use p_rename. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* Merge pull request #470 from schu/test-helpers-no-assertVicent Martí2011-11-071-2/+4
|\ | | | | test_helpers: do not rely on assert
| * test_helpers: do not rely on assertschu2011-10-301-2/+4
| | | | | | | | | | | | | | | | The functions loose_object_mode and loose_object_dir_mode call stat inside an assert statement which isn't evaluated when compiling in Release mode (NDEBUG) and leads to failing tests. Replace it. Signed-off-by: schu <schu-github@schulog.org>
* | refs: Partial rewrite for read-only refsVicent Marti2011-11-061-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new version of the references code is significantly faster and hopefully easier to read. External API stays the same. A new method `git_reference_reload()` has been added to force updating a memory reference from disk. In-memory references are no longer updated automagically -- this was killing us. If a reference is deleted externally and the user doesn't reload the memory object, nothing critical happens: any functions using that reference should fail gracefully (e.g. deletion, renaming, and so on). All generated references from the API are read only and must be free'd by the user. There is no reference counting and no traces of generated references are kept in the library. There is no longer an internal representation for references. There is only one reference struct `git_reference`, and symbolic/oid targets are stored inside an union. Packfile references are stored using an optimized struct with flex array for reference names. This should significantly reduce the memory cost of loading the packfile from disk.
* | Free all used references in the source treeschu2011-11-064-1/+88
| | | | | | | | | | | | | | Since references are not owned by the repository anymore we have to free them manually now. Signed-off-by: schu <schu-github@schulog.org>
* | refs: add test case checking "immutable" referencesschu2011-11-061-0/+32
| | | | | | | | Signed-off-by: schu <schu-github@schulog.org>
* | refs: split internal and external referencesschu2011-11-061-36/+36
|/ | | | | | | | | | | | | | | | | Currently libgit2 shares pointers to its internal reference cache with the user. This leads to several problems like invalidation of reference pointers when reordering the cache or manipulation of the cache from user side. Give each user its own git_reference instead of leaking the internal representation (struct reference). Add the following new API functions: * git_reference_free * git_reference_is_packed Signed-off-by: schu <schu-github@schulog.org>
* Merge pull request #468 from nulltoken/ntk/fix/issue-465Vicent Martí2011-10-2910-3/+9
|\ | | | | Status: fix segfault (#465) and order issues
| * status: Add a file in the test repository to cover the correct sorting of ↵nulltoken2011-10-2910-3/+9
| | | | | | | | | | | | entries when the working folder is being read In this case, "subdir.txt" should be listed before the "subdir" directory.
* | Merge pull request #456 from brodie/perm-fixesVicent Martí2011-10-2813-29/+94
|\ \ | |/ |/| Create objects, indexes, and directories with the right file permissions
| * *: correct and codify various file permissionsBrodie Rao2011-10-1410-10/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-149-21/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * fileops/posix: replace usage of "int mode" with "mode_t mode"Brodie Rao2011-10-142-4/+4
| | | | | | | | | | Note: Functions exported from fileops take const mode_t, while the underlying POSIX wrappers take mode_t.
* | global: Properly use `git__` memory wrappersVicent Marti2011-10-285-13/+13
| | | | | | | | | | Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
* | tests: propagate errors from open_temp_repo() instead of exitingBrodie Rao2011-10-141-4/+3
|/ | | | | | | This makes it slightly easier to debug test failures when one test opens a repo, has a failure, and doesn't get a chance to close it for the next test. Now, instead of getting no feedback, we at least see test failure information.
* Fix minor indentation issuesnulltoken2011-10-131-8/+7
|
* Add test commit containing subtrees and filesnulltoken2011-10-1312-2/+4
|
* signature: don't blow up trying to parse names containing '>'Brodie Rao2011-10-121-0/+8
| | | | | | | | | | | | | When trying to find the end of an email, instead of starting at the beginning of the signature, we start at the end of the name (after the first '<'). This brings libgit2 more in line with Git's behavior when reading out existing signatures. However, note that Git does not allow names like these through the usual porcelain; instead, it silently strips any '>' characters it sees.
* tag: allow the tagger field to be missing when parsing tagsBrodie Rao2011-10-121-2/+18
| | | | | | | | | Instead of bailing out with an error, this sets tagger to NULL when the field is missing from the object. This makes it possible to inspect tags like this one: http://git.kernel.org/?p=git/git.git;a=tag;h=f25a265a342aed6041ab0cc484224d9ca54b6f41
* tag: avoid a double-free when parsing tags without a tagger fieldBrodie Rao2011-10-126-0/+27
| | | | | | | | | | | | | | | | | | | | The v0.99 tag in the Git repo triggers this behavior: http://git.kernel.org/?p=git/git.git;a=tag;h=d6602ec5194c87b0fc87103ca4d67251c76f233a Ideally, we'd allow the tag to be instantiated even though the tagger field is missing, but this at the very least prevents libgit2 from crashing. To test this bug, a new repository has been added based on the test branch in testrepo.git. It contains a "e90810b" tag that looks like this: object e90810b8df3e80c413d903f631643c716887138d type commit tag e90810b This is a very simple tag.
* commit: properly parse empty commit messagesBrodie Rao2011-10-126-2/+8
| | | | | | | | | This ensures commit->message is always non-NULL, even if the commit message is empty or consists of only a newline. One such commit can be found in the wild in the jQuery repository: https://github.com/jquery/jquery/commit/25b424134f9927a5bf0bab5cba836a0aa6c3cfc1
* config: behave like git with [section.subsection]Carlos Martín Nieto2011-10-012-4/+22
| | | | | | | | The documentation is a bit misleading. The subsection name is always case-sensitive, but with a [section.subsection] header, the subsection is transformed to lowercase when the configuration is parsed. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* core: One last `long long`config-int-typesVicent Marti2011-09-301-2/+2
|
* config: Proper type declarations for 64 bit intsVicent Marti2011-09-301-32/+32
|
* Make repo config loading automatic or completely explicitCarlos Martín Nieto2011-09-272-48/+7
| | | | | | | | | | | git_repository_config wants to take the global and system paths again so that one can be explicit if needed. The git_repository_config_autoload function is provided for the cases when it's good enough for the library to guess where those files are located. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* Merge pull request #427 from schu/fix-unused-parametersVicent Martí2011-09-271-3/+3
|\ | | | | t18-status.c: fix unused warnings
| * t18-status.c: fix unused warningsschu2011-09-241-3/+3
| | | | | | | | Signed-off-by: schu <schu-github@schulog.org>
* | Revert "Rewrite getenv to use Win32 version on Windows"Vicent Marti2011-09-272-6/+6
|/ | | | This reverts commit e1b86444676b70154bf8ab450d429bdef57a8276.
* config: make git_config_[get|set]_long() able to properly deal with 8 bytes ↵nulltoken2011-09-223-1/+64
| | | | | | | | wide values Should fix issue #419. Signed-off-by: nulltoken <emeric.fermas@gmail.com>
* Rewrite getenv to use Win32 version on WindowsPaul Betts2011-09-212-6/+6
|
* refs: add additional test for reference renamingschu2011-09-201-0/+30
| | | | | Signed-off-by: nulltoken <emeric.fermas@gmail.com> Signed-off-by: schu <schu-github@schulog.org>
* Fix tests to use portable setenvPaul Betts2011-09-192-12/+14
|
* Merge pull request #384 from kiryl/warningsVicent Martí2011-09-185-11/+9
|\ | | | | Add more -W flags to CFLAGS
| * CMakefile: add -Wmissing-prototypes and fix warningsKirill A. Shutemov2011-08-304-10/+8
| | | | | | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
| * CMakefile: add -Wstrict-prototypes and fix warningsKirill A. Shutemov2011-08-301-1/+1
| | | | | | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* | Merge pull request #398 from carlosmn/config-autohomeVicent Martí2011-09-182-6/+48
|\ \ | | | | | | git_repository_config: open global config file automatically
| * | git_repository_config: open global config file automaticallyCarlos Martín Nieto2011-09-122-6/+48
| |/ | | | | | | | | | | If the global configuration file is missing, it is ignored. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* | Add some forgotten asserts in the status testsnulltoken2011-09-171-4/+4
| |
* | Fix a off-by-one error in the git_status_foreach testsnulltoken2011-09-171-1/+1
| | | | | | | | Provided the tests fail (which they should not) and the callback is invoked too many times, this prevents the tests from segfaulting.
* | Revert changes to t18Vicent Marti2011-09-161-1/+36
| | | | | | | | ...Ops, I broke the old test when porting it to Clay.
* | Add sample "Status" clay testsVicent Marti2011-09-161-36/+1
| |
* | status: enhance determination of statuses for a whole directorynulltoken2011-09-151-29/+230
| | | | | | | | | | - Should increase performance through usage of a walker - No callback invocation for unaltered entries
* | status: enhance determination of status for a single filenulltoken2011-09-153-2/+64
| | | | | | | | | | | | - fix retrieval of a file status when working against a newly initialized repository - reduce memory pressure - prevents a directory from being tested
* | Mark the resources in the test folder as binary to prevent unexpected ↵nulltoken2011-09-151-0/+1
|/ | | | line-feed conversion