tests


Log

Author Commit Date CI Message
Edward Thomson 9d8510b3 2018-01-31T09:28:43 Merge pull request #4488 from libgit2/ethomson/conflict_marker_size Use longer conflict markers in recursive merge base
Edward Thomson cdab165d 2018-01-31T09:27:39 Merge pull request #4490 from libgit2/ethomson/apfs_precompose_fixes status::renames: test update for APFS (write NFD instead of NFC filename)
Patrick Steinhardt 275f103d 2018-01-12T08:59:40 odb: reject reading and writing null OIDs The null OID (hash with all zeroes) indicates a missing object in upstream git and is thus not a valid object ID. Add defensive measurements to avoid writing such a hash to the object database in the very unlikely case where some data results in the null OID. Furthermore, add shortcuts when reading the null OID from the ODB to avoid ever returning an object when a faulty repository may contain the null OID.
Patrick Steinhardt c0487bde 2018-01-12T08:23:43 tree: reject writing null-OID entries to a tree In commit a96d3cc3f (cache-tree: reject entries with null sha1, 2017-04-21), the git.git project has changed its stance on null OIDs in tree objects. Previously, null OIDs were accepted in tree entries to help tools repair broken history. This resulted in some problems though in that many code paths mistakenly passed null OIDs to be added to a tree, which was not properly detected. Align our own code base according to the upstream change and reject writing tree entries early when the OID is all-zero.
Edward Thomson 9af7fbc3 2018-01-21T14:00:50 status::renames: write NFD instead of NFC filename Update the status::renames test to create an NFD format filename in the core.precomposedunicode tests. Previously, we would create an NFC format filename. This was to take advantage of HFS+ filesystems, which always use canonically decomposed formats, and would actually write the filename to disk as an NFD filename. So previously, we could create an NFC filename, but read it normally as an NFD filename. But APFS formats do not force canonically decomposed formats for filenames, so creating an NFC filename does not get converted to NFD. Instead, the filename will be written in NFC format. Our test, therefore, does not work - when we write an NFC filename, it will _remain_ NFC. Update the test to write NFD always. This will ensure that the file will actually be canonically decomposed on all platforms: HFS+, which forces NFD, and APFS, which does not. Thus, our test will continue to ensure that an NFD filename is canonically precomposed on all filesystems.
Edward Thomson 185b0d08 2018-01-20T19:41:28 merge: recursive uses larger conflict markers Git uses longer conflict markers in the recursive merge base - two more than the default (thus, 9 character long conflict markers). This allows users to tell the difference between the recursive merge conflicts and conflicts between the ours and theirs branches. This was introduced in git d694a17986a28bbc19e2a6c32404ca24572e400f. Update our tests to expect this as well.
Patrick Steinhardt 820fb712 2018-01-18T07:48:28 tests: online::clone: fix memory leak due to not freeing URL
Brian Lopez 4893a9c0 2018-01-17T13:54:42 Merge pull request #4451 from libgit2/charliesome/trailer-info Implement message trailer parsing API
Brian Lopez 1e758fd3 2018-01-16T22:20:50 just use git_message_trailer in tests
Brian Lopez 6062032e 2018-01-16T20:54:05 try and fix windows build
Brian Lopez d43974fb 2018-01-16T13:40:26 Change trailer API to return a simple array
Patrick Steinhardt 782402c2 2018-01-12T13:09:23 tests: refs::iterator: fix memory leak due to ref names not being free'd The test refs::iterator::foreach_name iterates through every reference and copies its name into a local vector. While the test makes sure to free the vector afterwards, the copied reference names are not being free'd. Fix that.
Patrick Steinhardt 093e671e 2018-01-12T12:55:40 tests: network::fetchlocal: let cleanup function handle sandbox cleanup Two tests in network::fetchlocal explicitly set a cleanup function to free and remove the created sandbox repositories. This is not necessary, though, as the cleanup function executed after each test already takes care of cleaning up after them. Remove the code to avoid needless code duplication.
Brian Lopez 5734768b 2018-01-10T19:19:34 Merge remote-tracking branch 'origin/master' into charliesome/trailer-info
Brian Lopez f4f0e7eb 2018-01-04T08:24:43 switch back to braced array initializers
Brian Lopez 6bc7301e 2018-01-03T16:16:22 Don't use newer C syntax for declaration in tests
Edward Thomson eebc5e0d 2018-01-03T15:15:16 Merge pull request #4257 from pks-t/pks/stale-test Execute stale tests
Patrick Steinhardt 5874e151 2017-11-20T13:26:33 tests: create new test target for all SSH-based tests Some tests shall be run against our own SSH server we spin up in Travis. As those need to be run separate from our previous tests which run against git-daemon, we have to do this in a separate step. Instead of bundling all that knowledge in the CI script, move it into the test build instructions by creating a new test target.
Patrick Steinhardt 54a1bf05 2017-06-07T13:06:53 tests: online::clone: inline creds-test with nonexistent URL Right now, we test our credential callback code twice, once via SSH on localhost and once via a non-existent GitHub repository. While the first URL makes sense to be configurable, it does not make sense to hard-code the non-existing repository, which requires us to call tests multiple times. Instead, we can just inline the URL into another set of tests.
Patrick Steinhardt fea60920 2017-06-07T12:48:48 tests: online::clone: construct credential-URL from environment We support two types of passing credentials to the proxy, either via the URL or explicitly by specifying user and password. We test these types by modifying the proxy URL and executing the tests twice, which is in fact unnecessary and requires us to maintain the list of environment variables and test executions across multiple CI infrastructures. To fix the situation, we can just always pass the host, port, user and password to the tests. The tests can then assemble the complete URL either with or without included credentials, allowing us to test both cases in-process.
Patrick Steinhardt 543ec149 2017-06-07T11:06:01 tests: perf: build but exclude performance tests by default Our performance tests (or to be more concrete, our single performance test) are not built by default, as they are always #ifdef'd out. While it is true that we don't want to run performance tests by default, not compiling them at all may cause code rot and is thus an unfavorable approach to handle this. We can easily improve this situation: this commit removes the #ifdef, causing the code to always be compiled. Furthermore, we add `-xperf` to the default command line parameters of `generate.py`, thus causing the tests to be excluded by default. Due to this approach, we are now able to execute the performance tests by passing `-sperf` to `libgit2_clar`. Unfortunately, we cannot execute the performance tests on Travis or AppVeyor as they rely on history being available for the libgit2 repository. As both do a shallow clone only, though, this is not given.
Patrick Steinhardt b8c14499 2017-06-07T11:00:26 tests: iterator::workdir: fix reference count in stale test The test `iterator::workdir::filesystem_gunk` is usually not executed, as it is guarded by the environment variable "GITTEST_INVASIVE_SPEED" due to its effects on speed. As such, it has become stale and does not account for new references which have meanwhile been added to the testrepo, causing it to fail. Fix this by raising the number of expected references to 15.
Patrick Steinhardt 9aba7636 2017-06-07T10:59:31 tests: iterator_helpers: assert number of iterator items When the function `expect_iterator_items` surpasses the number of expected items, we simply break the loop. This causes us to trigger an assert later on which has message attached, which is annoying when trying to locate the root error cause. Instead, directly assert that the current count is still smaller or equal to the expected count inside of the loop.
Patrick Steinhardt 72c28ab0 2017-06-07T10:59:03 tests: status::worktree: indicate skipped tests on Win32 Some function bodies of tests which are not applicable to the Win32 platform are completely #ifdef'd out instead of calling `cl_skip()`. This leaves us with no indication that these tests are not being executed at all and may thus cause decreased scrutiny when investigating skipped tests. Improve the situation by calling `cl_skip()` instead of just doing nothing.
Brian Lopez e8bc8558 2018-01-02T13:29:49 Merge remote-tracking branch 'origin/master' into charliesome/trailer-info
Edward Thomson d6210245 2017-12-30T13:09:43 Merge pull request #4159 from richardipsum/notes-commit Support using notes via a commit rather than a ref
Edward Thomson 2b7a3393 2017-12-30T12:47:57 Merge pull request #4455 from libgit2/ethomson/branch_symlinks refs: traverse symlinked directories
Edward Thomson e14bf97e 2017-12-30T08:09:22 Merge pull request #4443 from libgit2/ethomson/large_loose_blobs Inflate large loose blobs
Edward Thomson 7a830f28 2017-12-30T00:46:17 refs:iterator: add tests to recurse symlinks Ensure that we can recurse into directories via symbolic links.
Edward Thomson 083b1a2e 2017-12-28T10:38:31 Merge pull request #4021 from carlosmn/cmn/refspecs-fetchhead FETCH_HEAD and multiple refspecs
Carlos Martín Nieto c081f0d0 2017-12-26T17:50:59 fetch: go over FETCH_HEAD just once when counting the prefixes in test
Carlos Martín Nieto c0bfda87 2016-12-02T17:36:04 fetch: add a failing test for FETCH_HEAD with multiple fetch refspecs
Edward Thomson 4110fc84 2017-12-23T23:30:29 Merge pull request #4285 from pks-t/pks/patches-with-whitespace patch_parse: fix parsing unquoted filenames with spaces
lhchavez c3514b0b 2017-12-23T14:59:07 Fix unpack double free If an element has been cached, but then the call to packfile_unpack_compressed() fails, the very next thing that happens is that its data is freed and then the element is not removed from the cache, which frees the data again. This change sets obj->data to NULL to avoid the double-free. It also stops trying to resolve deltas after two continuous failed rounds of resolution, and adds a test for this.
Edward Thomson 06f3aa5f 2017-12-23T10:07:44 Merge pull request #4429 from novalis/delete-modify-submodule-merge Do not attempt to check out submodule as blob when merging a submodule modify/deltete conflict
Edward Thomson 456e5218 2017-12-20T16:13:31 tests: add GITTEST_SLOW env var check Writing very large files may be slow, particularly on inefficient filesystems and when running instrumented code to detect invalid memory accesses (eg within valgrind or similar tools). Introduce `GITTEST_SLOW` so that tests that are slow can be skipped by the CI system.
Edward Thomson 3e6533ba 2017-12-10T17:25:00 odb_loose: reject objects that cannot fit in memory Check the size of objects being read from the loose odb backend and reject those that would not fit in memory with an error message that reflects the actual problem, instead of error'ing later with an unintuitive error message regarding truncation or invalid hashes.
Edward Thomson dacc3291 2017-11-30T15:49:05 odb: test loose reading/writing large objects Introduce a test for very large objects in the ODB. Write a large object (5 GB) and ensure that the write succeeds and provides us the expected object ID. Introduce a test that writes that file and ensures that we can subsequently read it.
Edward Thomson 86219f40 2017-11-30T15:40:13 util: introduce `git__prefixncmp` and consolidate implementations Introduce `git_prefixncmp` that will search up to the first `n` characters of a string to see if it is prefixed by another string. This is useful for examining if a non-null terminated character array is prefixed by a particular substring. Consolidate the various implementations of `git__prefixcmp` around a single core implementation and add some test cases to validate its behavior.
Charlie Somerville e24f3b59 2017-12-19T13:49:55 tests: add message trailer parsing test cases
Edward Thomson fa8cf14f 2017-12-16T21:49:45 Merge pull request #4447 from pks-t/pks/diff-file-contents-refcount-blob diff_file: properly refcount blobs when initializing file contents
Patrick Steinhardt 2388a9e2 2017-12-15T10:47:01 diff_file: properly refcount blobs when initializing file contents When initializing a `git_diff_file_content` from a source whose data is derived from a blob, we simply assign the blob's pointer to the resulting struct without incrementing its refcount. Thus, the structure can only be used as long as the blob is kept alive by the caller. Fix the issue by using `git_blob_dup` instead of a direct assignment. This function will increment the refcount of the blob without allocating new memory, so it does exactly what we want. As `git_diff_file_content__unload` already frees the blob when `GIT_DIFF_FLAG__FREE_BLOB` is set, we don't need to add new code handling the free but only have to set that flag correctly.
lhchavez c8aaba24 2017-12-06T03:03:18 libFuzzer: Fix missing trailer crash This change fixes an invalid memory access when the trailer is missing / corrupt. Found using libFuzzer.
lhchavez 400caed3 2017-12-06T03:22:58 libFuzzer: Fix a git_packfile_stream leak This change ensures that the git_packfile_stream object in git_indexer_append() does not leak when the stream has errors. Found using libFuzzer.
David Turner 2a3e0635 2017-12-04T16:56:07 Do not attempt to check out submodule as blob when merging a submodule modify/deltete conflict
Richard Ipsum 4623c25f 2017-09-23T17:19:58 notes: Add test that read of noteless commit fails
Edward Thomson 429bb357 2017-12-01T11:45:53 Merge pull request #4318 from Uncommon/amend_status Add git_status_file_at
David Catmull 4ccacdc8 2017-07-21T17:07:10 status: Add a baseline field to git_status_options for comparing to trees other than HEAD
Patrick Steinhardt 59ffb512 2017-11-24T10:37:09 Merge pull request #4298 from tiennou/gather-reflog-messages-tests Gather the reflog entry content tests
Etienne Samson da635eda 2017-11-22T23:47:29 tests: move free functions at the end
Carlos Martín Nieto 1e64a446 2016-12-02T16:09:21 fetch: expand fetchhead test to cover providing multiple refspecs
Etienne Samson ebe5d8ec 2017-07-21T20:12:01 tests: move static method to the top
Etienne Samson f01a8587 2017-07-21T17:45:44 tests: make reflog_check_entry more clar-y
Etienne Samson b9b1f9f8 2017-07-14T03:21:02 tests: clarify which steps corresponds to each checks
Etienne Samson 53672128 2017-07-21T17:35:30 tests: gather the reflog entry content tests
Christine Poerschke 19f37f97 2017-11-13T13:16:28 add test status codes legend to the 'Started' test trace motivation: (for someone new to the tests) it's puzzling to find the odd 'S' interspersed in the test output proposed alternative test output (extract): $ cmake --build . && ./libgit2_clar -srepo -v ... Loaded 340 suites: Started (test status codes: OK='.' FAILURE='F' SKIPPED='S') repo::config... repo::discover.......... repo::env. repo::getters... repo::hashfile.. repo::head...................... repo::headtree.... repo::init.........................S repo::message.. repo::new.. repo::open............. repo::pathspec.......... repo::reservedname..... repo::setters..... repo::shallow.... repo::state.............
Carlos Martín Nieto 15f8d9a2 2017-11-13T11:44:30 Merge pull request #4412 from cpoerschke/master-tests-repo-init-tweak s/Init/Index comment tweak for test_repo_init__init_with_initial_commit
Christine Poerschke 732c0b6d 2017-11-12T15:17:31 s/Init/Index comment tweak for test_repo_init__init_with_initial_commit
Patrick Steinhardt fd1492e8 2017-11-12T15:34:42 Merge pull request #4408 from hkleynhans/pos_neg_zero_offset_sig signature: distinguish +0000 and -0000 UTC offsets
Henry Kleynhans f063dafb 2017-11-12T10:56:50 signature: distinguish +0000 and -0000 UTC offsets Git considers '-0000' a valid offset for signature lines. They need to be treated as _not_ equal to a '+0000' signature offset. Parsing a signature line stores the offset in a signed integer which does not distinguish between `+0` and `-0`. This patch adds an additional flag `sign` to the `git_time` in the `signature` object which is populated with the sign of the offset. In addition to exposing this information to the user, this information is also used to compare signatures. /cc @pks-t @ethomson
Patrick Steinhardt 80226b5f 2017-09-22T13:39:05 patch_parse: allow parsing ambiguous patch headers The git patch format allows for having unquoted paths with whitespaces inside. This format becomes ambiguous to parse, e.g. in the following example: diff --git a/file b/with spaces.txt b/file b/with spaces.txt While we cannot parse this in a correct way, we can instead use the "---" and "+++" lines to retrieve the file names, as the path is not followed by anything here but spans the complete remaining line. Because of this, we can simply bail outwhen parsing the "diff --git" header here without an actual error and then proceed to just take the paths from the other headers.
Yoney 32758631 2017-11-11T15:38:27 clar: verify command line arguments before execute When executing `libgit2_clar -smerge -invalid_option`, it will first execute the merge test suite and afterwards output help because of the invalid option. With this changa, it verifies all options before execute. If there are any invalid options, it will output help and exit without actually executing the test suites.
Edward Thomson 0393ecc6 2017-11-11T13:29:27 Merge pull request #4308 from pks-t/pks/header-state-machine patch_parse: implement state machine for parsing patch headers
Patrick Steinhardt 88450c1c 2017-11-09T21:49:30 Merge pull request #4283 from tiennou/generic-tls CMake: make HTTPS support more generic
Carlos Martín Nieto 8233f6e3 2017-11-04T23:34:14 Merge pull request #4386 from novalis/gitignore-ignore-space ignore spaces in .gitignore files
Carlos Martín Nieto 42627933 2017-11-04T18:03:26 Merge remote-tracking branch 'upstream/master' into pks/conditional-includes
Carlos Martín Nieto c44b9170 2017-10-31T09:52:33 tests: resolve the real path for the sandbox in includeIf tests We put our repository in the temporary directory which makes macOS map the path into a virtual path. `realpath(3)` can resolve it and we do so during repository opening, but that makes its path have a different prefix from the sandbox path clar thinks we have. Resolve the sandbox path before putting it into the test config files so the paths match as expected.
Carlos Martín Nieto bb8bc4b8 2017-10-30T06:21:55 config: add failing test for preserving case when writing keys While most parts of a configuration key are case-insensitive, we should still be case-preserving and write down whatever string the caller provided.
David Turner 5cb6a2c9 2017-10-29T12:28:43 Ignore trailing whitespace in .gitignore files (as git itself does)
Etienne Samson 9980be03 2017-09-06T22:13:58 cmake: Add USE_HTTPS as a CMake option It defaults to ON, e.g. "pick whatever default is appropriate for the platform". It accepts one of SecureTransport, OpenSSL, WinHTTP, or OFF. It errors if the backend library couldn't be found.
Etienne Samson d3ef11e0 2017-03-19T03:31:41 clar: exit immediately on initialization failure
Etienne Samson e9369856 2017-03-21T00:25:15 stream: Gather streams to src/streams
Etienne Samson 08c1b8fc 2017-08-28T21:24:13 cmake: simplify some HTTPS tests
Patrick Steinhardt 4da74c83 2017-10-20T07:29:17 cmake: use project-relative binary and source directories Due to our split of CMake files into multiple modules, we had to replace some uses of the `${CMAKE_CURRENT_SOURCE_DIR}` and `${CMAKE_CURRENT_BINARY_DIR}` variables and replace them with `${CMAKE_SOURCE_DIR}` and `${CMAKE_BINARY_DIR}`. This enabled us to still be able to refer to top-level files when defining build instructions inside of a subdirectory. When replacing all variables, it was assumed that the absolute set of variables is always relative to the current project. But in fact, this is not the case, as these variables always point to the source and binary directory as given by the top-levl project. So the change actually broke the ability to include libgit2 directly as a subproject, as source files cannot be found anymore. Fix this by instead using project-specific source and binary directories with `${libgit2_SOURCE_DIR}` and `${libgit2_BINARY_DIR}`.
Patrick Steinhardt f7d837c8 2017-05-24T12:12:29 config_file: implement "gitdir/i" conditional Next to the "gitdir" conditional for including other configuration files, there's also a "gitdir/i" conditional. In contrast to the former one, path matching with "gitdir/i" is done case-insensitively. This commit implements the case-insensitive condition.
Patrick Steinhardt 071b6c06 2017-05-24T11:13:36 config_file: implement conditional "gitdir" includes Upstream git.git has implemented the ability to include other configuration files based on conditions. Right now, this only includes the ability to include a file based on the gitdir-location of the repository the currently parsed configuration file belongs to. This commit implements handling these conditional includes for the case-sensitive "gitdir" condition.
Patrick Steinhardt 529e873c 2017-05-23T11:51:00 config: pass repository when opening config files Our current configuration logic is completely oblivious of any repository, but only cares for actual file paths. Unfortunately, we are forced to break this assumption by the introduction of conditional includes, which are evaluated in the context of a repository. Right now, only one conditional exists with "gitdir:" -- it will only include the configuration if the current repository's git directory matches the value passed to "gitdir:". To support these conditionals, we have to break our API and make the repository available when opening a configuration file. This commit extends the `open` call of configuration backends to include another repository and adjusts existing code to have it available. This includes the user-visible functions `git_config_add_file_ondisk` and `git_config_add_backend`.
Patrick Steinhardt 09c15a7f 2017-10-09T09:08:19 tests: checkout::tree: check that the status list catches mode changes While we verify that we have no mode changes after calling `git_checkout_tree`, we do not verify that the `p_chmod` calls actually resulted in a changed entry. While we should assume that this works due to separate tests for the status list, we should test for the change being listed to avoid programming errors in the test.
Patrick Steinhardt 880dfc50 2017-10-09T09:06:24 tests: checkout::tree: extract check for status entrycount There are multiple locations where we have the same code to check whether the count of status list entries of a repository matches an expected number. Extract that into a common function.
Patrick Steinhardt 38e769cb 2017-10-09T09:00:29 Merge pull request #4369 from libgit2/ethomson/checkout_typechange Checkout typechange-only deltas
Edward Thomson 19e8faba 2016-06-15T01:59:56 checkout: test force checkout when mode changes Test that we can successfully force checkout a target when the file contents are identical, but the mode has changed.
Richard Ipsum 60bee89d 2017-03-19T18:34:07 notes: Add git_note_commit_iterator_new This also adds tests for this function.
Richard Ipsum 9a02725d 2017-03-15T18:17:42 notes: Add git_note_commit_remove This also adds tests for this function.
Richard Ipsum 7096bf1e 2017-03-15T11:54:45 notes: Add git_note_commit_read This also adds tests for this function.
Richard Ipsum a46e743d 2017-09-23T17:46:46 notes: Add git_note_commit_create This adds a new function that will allow creation of notes without necessarily updating a particular ref, the notes tree is obtained from the git_commit object parameter, a new commit object pointing to the current tip of the notes tree is optionally returned via the 'note_commit_out' parameter, optionally the blob id for the note is returned through the 'note_blob_out' object.
Patrick Steinhardt b112b1e9 2017-10-06T11:24:11 refs: do not use peeled OID if peeling to a tag If a reference stored in a packed-refs file does not directly point to a commit, tree or blob, the packed-refs file will also will include a fully-peeled OID pointing to the first underlying object of that type. If we try to peel a reference to an object, we will use that peeled OID to speed up resolving the object. As a reference for an annotated tag does not directly point to a commit, tree or blob but instead to the tag object, the packed-refs file will have an accomodating fully-peeled OID pointing to the object referenced by that tag. When we use the fully-peeled OID pointing to the referenced object when peeling, we obviously cannot peel that to the tag anymore. Fix this issue by not using the fully-peeled OID whenever we want to peel to a tag. Note that this does not include the case where we want to resolve to _any_ object type. Existing code may make use from the fact that we resolve those to commit objects instead of tag objects, even though that behaviour is inconsistent between packed and loose references. Furthermore, some tests of ours make the assumption that we in fact resolve those references to a commit.
Patrick Steinhardt d8d2f21e 2017-09-06T07:52:12 cmake: unify version check for target include directories There are two locations where we check whether CMake supports `TARGET_INCLUDE_DIRECTORIES`. While the first one uses `VERSION_LESS 2.8.12`, the second one uses `VERSION_GREATER 2.8.11`, which are obviously equivalent to each other. It'd still be easier to grep for specific CMake versions being required for some features if both used the same conditional mentioning the actual target version required. So this commit refactors these conditions to make them equal.
Patrick Steinhardt 1d9dd882 2017-09-05T15:06:29 cmake: distinguish libgit2 objects and sources Distinguish variables keeping track of our internal libgit2 sources and the final objects which shall be linked into the library. This will ease the transition to use object libraries for our bundled dependencies instead of linking them in.
Patrick Steinhardt cc4c44a9 2017-09-01T09:37:05 patch_parse: fix parsing patches only containing exact renames Patches which contain exact renames only will not contain an actual diff body, but only a list of files that were renamed. Thus, the patch header is immediately followed by the terminating sequence "-- ". We currently do not recognize this character sequence as a possible terminating sequence. Add it and create a test to catch the failure.
Patrick Steinhardt 583e4141 2017-08-30T14:35:57 tests: deterministically generate test suite definitions The script "generate.py" is used to parse all test source files for unit tests. These are then written into a "clar.suite" file, which can be included by the main test executable to make available all test suites and unit tests. Our current algorithm simply collects all test suites inside of a dict, iterates through its items and dumps them in a special format into the file. As the order is not guaranteed to be deterministic for Python dictionaries, this may result in arbitrarily ordered C structs. This obviously defeats the purpose of reproducible builds, where the same input should always result in the exact same output. Fix this issue by sorting the test suites by name previous to dumping them as structs. This enables reproducible builds for the libgit2_clar file.
Edward Thomson 3c216453 2017-08-25T21:06:46 Merge pull request #4296 from pks-t/pks/pattern-based-gitignore Fix negative ignore rules with patterns
Patrick Steinhardt 477b3e04 2017-07-10T12:25:43 submodule: refuse lookup in bare repositories While it is technically possible to look up submodules inside of a bare repository by reading the submodule configuration of a specific commit, we do not offer this functionality right now. As such, calling both `git_submodule_lookup` and `git_submodule_foreach` should error out early when these functions encounter a bare repository. While `git_submodule_lookup` already does return an error due to not being able to parse the configuration, `git_submodule_foreach` simply returns success and never invokes the callback function. Fix the issue by having both functions check whether the repository is bare and returning an error in that case.
Patrick Steinhardt a889c05f 2017-07-10T11:55:33 tests: submodule: add explicit cleanup function in lookup tests
Patrick Steinhardt 64d1e0b3 2017-07-10T11:52:08 tests: submodule: fix declaration of test The testcase "submodule::lookup::cached" was declared with a single underscore separating the test suide and test name, only. As the clar parser only catches tests with two underscores, it was never executed. Add in the second underscore to actually have it detected and executed.
Patrick Steinhardt 2d9ff8f5 2017-07-10T09:36:19 ignore: honor case insensitivity for negative ignores When computing negative ignores, we throw away any rule which does not undo a previous rule to optimize. But on case insensitive file systems, we need to keep in mind that a negative ignore can also undo a previous rule with different case, which we did not yet honor while determining whether a rule undoes a previous one. So in the following example, we fail to unignore the "/Case" directory: /case !/Case Make both paths checking whether a plain- or wildcard-based rule undo a previous rule aware of case-insensitivity. This fixes the described issue.
Patrick Steinhardt 38b44c3b 2017-07-07T17:10:57 tests: status: additional test for negative ignores with pattern This test is by Carlos Martín Nieto.
Patrick Steinhardt b8922fc8 2017-07-07T13:27:27 ignore: keep negative rules containing wildcards Ignore rules allow for reverting a previously ignored rule by prefixing it with an exclamation mark. As such, a negative rule can only override previously ignored files. While computing all ignore patterns, we try to use this fact to optimize away some negative rules which do not override any previous patterns, as they won't change the outcome anyway. In some cases, though, this optimization causes us to get the actual ignores wrong for some files. This may happen whenever the pattern contains a wildcard, as we are unable to reason about whether a pattern overrides a previous pattern in a sane way. This happens for example in the case where a gitignore file contains "*.c" and "!src/*.c", where we wouldn't un-ignore files inside of the "src/" subdirectory. In this case, the first solution coming to mind may be to just strip the "src/" prefix and simply compare the basenames. While that would work here, it would stop working as soon as the basename pattern itself is different, like for example with "*x.c" and "!src/*.c. As such, we settle for the easier fix of just not optimizing away rules that contain a wildcard.
Patrick Steinhardt 8e31cc25 2017-06-28T12:51:14 cmake: keep track of libraries and includes via lists Later on, we will move detection of required libraries, library directories as well as include directories into a separate CMakeLists.txt file inside of the source directory. Obviously, we want to avoid duplication here regarding these parameters. To prepare for the split, put the parameters into three variables LIBGIT2_LIBS, LIBGIT2_LIBDIRS and LIBGIT2_INCLUDES, tracking the required libraries, linking directory as well as include directories. These variables can later be exported into the parent scope from inside of the source build instructions, making them readily available for the other subdirectories.
Patrick Steinhardt a390a846 2017-07-01T13:06:00 cmake: move defines into "features.h" header In a future commit, we will split out the build instructions for our library directory and move them into a subdirectory. One of the benefits is fixing scoping issues, where e.g. defines do not leak to build targets where they do not belong to. But unfortunately, this does also pose the problem of how to propagate some defines which are required by both the library and the test suite. One way would be to create another variable keeping track of all added defines and declare it inside of the parent scope. While this is the most obvious and simplest way of going ahead, it is kind of unfortunate. The main reason to not use this is that these defines become implicit dependencies between the build targets. By simply observing a define inside of the CMakeLists.txt file, one cannot reason whether this define is only required by the current target or whether it is required by different targets, as well. Another approach would be to use an internal header file keeping track of all defines shared between targets. While configuring the library, we will set various variables and let CMake configure the file, adding or removing defines based on what has been configured. Like this, one can easily keep track of the current environment by simply inspecting the header file. Furthermore, these dependencies are becoming clear inside the CMakeLists.txt, as instead of simply adding a define, we now call e.g. `SET(GIT_THREADSAFE 1)`. Having this header file though requires us to make sure it is always included before any "#ifdef"-preprocessor checks are executed. As we have already refactored code to always include the "common.h" header file before any statement inside of a file, this becomes easy: just make sure "common.h" includes the new "features.h" header file first.
Patrick Steinhardt 35087f0e 2017-06-28T15:42:54 cmake: create separate CMakeLists.txt for tests Our CMakeLists.txt is very unwieldy in its current size, spanning more than 700 lines of code. Furthermore, it has several issues regarding scoping, where for example some defines, includes, etc. from our test suite are also applied to our normal library code. To fix this, we can separate out build instructions for our tests and move them into their own CMakeLists.txt in the "tests" directory. This reduced complexity of the root CMakeLists.txt file and fixes the issues regarding leaking build context from tests into the library.