summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* tree: rename from_tree to validate and clarify the tree in the testcmn/null-oid-existing-treeCarlos Martín Nieto2018-07-271-0/+1
|
* tree: accept null ids in existing trees when updatingCarlos Martín Nieto2018-07-182-0/+15
| | | | | | | | | When we add entries to a treebuilder we validate them. But we validate even those that we're adding because they exist in the base tree. This disables using the normal mechanisms on these trees, even to fix them. Keep track of whether the entry we're appending comes from an existing tree and bypass the name and id validation if it's from existing data.
* cmake: enforce C90 standardPatrick Steinhardt2018-07-131-0/+1
| | | | | | | | | | | | | While the aim of libgit2 was to conform to C90 code, we never instructed the compiler to enforce C90 compliance. Thus, quite a few violations were able to get into our code base, which have been removed with the previous commits. As we are now able to build libgit2 with C90 enforced, we can set the C_STANDARD property for our own build targets. Note that we explicitly avoid setting the C standard for our third-party dependencies. At least the zlib target does not build with C90 enforced, and we do not want to fix them by deviating from upstream. Thus we simply enforce no standard for them.
* cmake: distinguish internal and system include directoriesPatrick Steinhardt2018-07-131-0/+1
| | | | | | | | | | | | | | | | | | | While we want to enforce strict C90 mode, this may cause issues with system provided header files which are themselves not strictly conforming. E.g. if a system header has C++ style comments, a compiler in strict C90 mode would produce an error and abort the build. As the user most likely doesn't want to change the system header, this would completely break the build on such systems. One example of this is mbedtls, which provides such header files. The problem can be worked around by distinguishing between system-provided and project-provided include directories. When adding include directories via "-isystem" instead of "-I", the compiler will skip certain checks and print out less warnings. To use system includes, we can simply add the "SYSTEM" flag to CMake's `INCLUDE_DIRECTORIES` and `TARGET_INCLUDE_DIRECTORIES` functions. Note that we have to split the include directories into two variables because of this, as we definitely still want to check for all warnings produced by our own header files.
* treewide: remove use of C++ style commentsPatrick Steinhardt2018-07-1359-156/+161
| | | | | | | | | C++ style comment ("//") are not specified by the ISO C90 standard and thus do not conform to it. While libgit2 aims to conform to C90, we did not enforce it until now, which is why quite a lot of these non-conforming comments have snuck into our codebase. Do a tree-wide conversion of all C++ style comments to the supported C style comments to allow us enforcing strict C90 compliance in a later commit.
* Merge pull request #4719 from pks-t/pks/delta-oobEdward Thomson2018-07-092-0/+22
|\ | | | | Delta OOB access
| * delta: fix out-of-bounds read of deltaPatrick Steinhardt2018-06-291-0/+9
| | | | | | | | | | | | | | | | | | | | | | When computing the offset and length of the delta base, we repeatedly increment the `delta` pointer without checking whether we have advanced past its end already, which can thus result in an out-of-bounds read. Fix this by repeatedly checking whether we have reached the end. Add a test which would cause Valgrind to produce an error. Reported-by: Riccardo Schirone <rschiron@redhat.com> Test-provided-by: Riccardo Schirone <rschiron@redhat.com>
| * delta: fix sign-extension of big left-shiftPatrick Steinhardt2018-06-292-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our delta code was originally adapted from JGit, which itself adapted it from git itself. Due to this heritage, we inherited a bug from git.git in how we compute the delta offset, which was fixed upstream in 48fb7deb5 (Fix big left-shifts of unsigned char, 2009-06-17). As explained by Linus: Shifting 'unsigned char' or 'unsigned short' left can result in sign extension errors, since the C integer promotion rules means that the unsigned char/short will get implicitly promoted to a signed 'int' due to the shift (or due to other operations). This normally doesn't matter, but if you shift things up sufficiently, it will now set the sign bit in 'int', and a subsequent cast to a bigger type (eg 'long' or 'unsigned long') will now sign-extend the value despite the original expression being unsigned. One example of this would be something like unsigned long size; unsigned char c; size += c << 24; where despite all the variables being unsigned, 'c << 24' ends up being a signed entity, and will get sign-extended when then doing the addition in an 'unsigned long' type. Since git uses 'unsigned char' pointers extensively, we actually have this bug in a couple of places. In our delta code, we inherited such a bogus shift when computing the offset at which the delta base is to be found. Due to the sign extension we can end up with an offset where all the bits are set. This can allow an arbitrary memory read, as the addition in `base_len < off + len` can now overflow if `off` has all its bits set. Fix the issue by casting the result of `*delta++ << 24UL` to an unsigned integer again. Add a test with a crafted delta that would actually succeed with an out-of-bounds read in case where the cast wouldn't exist. Reported-by: Riccardo Schirone <rschiron@redhat.com> Test-provided-by: Riccardo Schirone <rschiron@redhat.com>
* | Merge pull request #4687 from tiennou/fix/4672Edward Thomson2018-07-061-0/+71
|\ \ | | | | | | patch_parse: populate line numbers while parsing diffs
| * | patch_parse: populate line numbers while parsing diffsEtienne Samson2018-06-191-0/+71
| | |
* | | Merge pull request #4686 from tiennou/fix/more-worktree-from-barePatrick Steinhardt2018-07-065-52/+111
|\ \ \ | | | | | | | | Fix git_worktree_validate failing on bare repositories
| * | | tests: worktree/bare: test some pathsEtienne Samson2018-06-291-0/+18
| | | |
| * | | tests: add a helper to build sandbox subpaths quicklyEtienne Samson2018-06-293-20/+39
| | | |
| * | | tests: worktree/bare: fix git_worktree_validateEtienne Samson2018-06-291-0/+2
| | | |
| * | | tests: worktree/bare: check git_worktree_listEtienne Samson2018-06-291-0/+5
| | | |
| * | | tests: worktree/bare: gather all testsEtienne Samson2018-06-292-32/+47
| | | |
* | | | Merge pull request #4699 from nelhage/fetch-null-dstPatrick Steinhardt2018-07-061-0/+5
|\ \ \ \ | | | | | | | | | | git_refspec_transform: Handle NULL dst
| * | | | formatting fixNelson Elhage2018-06-291-1/+2
| | | | |
| * | | | Add a test.Nelson Elhage2018-06-251-0/+4
| | |/ / | |/| | | | | | | | | | Verified that this breaks before the fix and passes afterwards.
* | | | Merge pull request #4536 from libgit2/ethomson/index_dirtyEdward Thomson2018-06-306-21/+243
|\ \ \ \ | |_|/ / |/| | | Add a "dirty" state to the index when it has unsaved changes
| * | | settings: optional unsaved index safetyEdward Thomson2018-06-291-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the `GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY` option, which will cause commands that reload the on-disk index to fail if the current `git_index` has changed that have not been saved. This will prevent users from - for example - adding a file to the index then calling a function like `git_checkout` and having that file be silently removed from the index since it was re-read from disk. Now calls that would re-read the index will fail if the index is "dirty", meaning changes have been made to it but have not been written. Users can either `git_index_read` to discard those changes explicitly, or `git_index_write` to write them.
| * | | index: return a unique error code on dirty indexEdward Thomson2018-06-291-0/+22
| | | | | | | | | | | | | | | | | | | | When the index is dirty, return GIT_EINDEXDIRTY so that consumers can identify the exact problem programatically.
| * | | checkout: FORCE doesn't halt on dirty indexEdward Thomson2018-06-292-16/+0
| | | | | | | | | | | | | | | | | | | | If the index is dirty, allow `GIT_CHECKOUT_FORCE` to obliterate unsaved changes. This is in keeping with its name and description.
| * | | index: commit the changes to the index properlyEdward Thomson2018-06-295-13/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that the index has a "dirty" state, where it has changes that have not yet been committed or rolled back, our tests need to be adapted to actually commit or rollback the changes instead of assuming that the index can be operated on in its indeterminate state.
| * | | index: test dirty index bitEdward Thomson2018-06-291-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Test that any changes to the index will mark the index as dirty. Also ensure that when we initialize a new index, read the index contents from disk, or write the index contents to disk that we reset the dirty flag to zero. Further ensure that an unforced read with dirty contents (when the on-disk index has not changed) does _not_ reset the dirty flag as we have not updated the contents of our index and our unsaved contents remain intact.
| * | | checkout tests: validate GIT_CHECKOUT_NO_REFRESHEdward Thomson2018-06-291-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | Add tests that ensure that we re-read the on-disk image by default during checkout, but when the `GIT_CHECKOUT_NO_REFRESH` option is specified, we do _not_ re-read the index.
| * | | index::addall tests: write the indexEdward Thomson2018-06-261-0/+17
| | | | | | | | | | | | | | | | | | | | When running `git_index_add_all`, we should write the index to disk so that we can re-read it safely during status.
| * | | index::reuc tests: test that checkout succeedsEdward Thomson2018-06-261-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The index::reuc tests must test that the checkout itself succeeds, otherwise subsequent tests are not valid. In fact, the checkouts were failing because when checking out `SAFE`, they cannot update the files that are in conflict. Change the checkout level to `FORCE` to ensure that they get updated correctly.
| * | | index::names tests: add conflicts with high stagesEdward Thomson2018-06-261-0/+37
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We add entries into the main index to correspond with the NAME entries that we're going to test. NAME entries store the results of conflicts occuring with rename detection during merge, and they must correspond to conflicts in the index. This test was mistakenly adding regular entries. The checkout validation failed, since it requires NAME entries to correspond to high-stage (conflict) entries. Correct the test to actually create conflicts.
* | | refspec: rename `git_refspec__free` to `git_refspec__dispose`Patrick Steinhardt2018-06-291-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since commit 630a67366 (refspec: add public parsing api, 2018-02-07), we now have two functions `git_refspec_free` and `git_refspec__free`. The difference is that the first one will free the structure itself, while the second one will only free the structure's contents. Use our new `dispose` naming pattern for the latter function to help avoid confusion.
* | | Merge pull request #4519 from cynecx/refspec-parsingPatrick Steinhardt2018-06-291-0/+12
|\ \ \ | |_|/ |/| | refspec: add public parsing api
| * | refspec: add public parsing apicynecx2018-06-221-0/+12
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix typo Fix some type issues More fixes Address requested changes Add test Fix naming Fix condition and tests Address requested changes Fix typo
* | Clear revwalk sorting when resettingNika Layzell2018-06-221-0/+25
|/ | | | | | | Currently we fail to clear the sorting flag for revwalks when resetting. This caused a poor interaction with the limited flag during a recent patch. This patch clears the revwalk sorting flag and causes it to no longer persist over resets.
* Fix last references to deprecated git_buf_freeSven Strickroth2018-06-181-1/+1
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Require the length argument to git_mailmap_from_buffer and make ↵Nika Layzell2018-06-172-2/+4
| | | | mailmap_add_buffer internal
* mailmap: git_buf_free => git_buf_disposeNika Layzell2018-06-141-1/+1
|
* mailmap: API and style cleanupNika Layzell2018-06-144-14/+7
|
* mailmap: Updates tests for new API and featuresNika Layzell2018-06-1410-33/+153
|
* mailmap: API and style cleanupNika Layzell2018-06-143-35/+69
|
* mailmap: Switch mailmap parsing to use the git_parse moduleNika Layzell2018-06-144-64/+31
|
* mailmap: Clean up the mailmap fixture's .gitted directoryNika Layzell2018-06-1413-543/+0
|
* mailmap: Fix some other minor style nitsEmilio Cobos Álvarez2018-06-141-7/+7
|
* mailmap: Fix more bugs which snuck in when I rebasedNika Layzell2018-06-143-6/+5
|
* mailmap: Add a bunch of tests for the new mailmap functionalityNika Layzell2018-06-1458-0/+841
|
* mailmap: Support path fixtures in cl_git_repository_init()Nika Layzell2018-06-143-17/+23
|
* mailmap: Add some super-basic testsEmilio Cobos Álvarez2018-06-141-0/+98
|
* Merge pull request #4436 from pks-t/pks/packfile-stream-freeEdward Thomson2018-06-11157-574/+574
|\ | | | | pack: rename `git_packfile_stream_free`
| * Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-10157-574/+574
| |
* | stash test: free the commitEdward Thomson2018-06-111-0/+1
| |
* | stash test: free the referenceEdward Thomson2018-06-101-0/+1
| |