summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* signature: don't leave a dangling pointer to the strings on parse failurecmn/tag-bad-signatureCarlos Martín Nieto2017-07-121-0/+1
| | | | | | | | If the signature is invalid but we detect that after allocating the strings, we free them. We however leave that pointer dangling in the structure the caller gave us, which can lead to double-free. Set these pointers to `NULL` after freeing their memory to avoid this.
* Merge pull request #4287 from AndreyG/reset/interface-cosmeticsPatrick Steinhardt2017-07-102-9/+9
|\ | | | | git_reset_*: pass parameters as const pointers
| * git_reset_*: pass parameters as const pointersAndrey Davydov2017-06-302-9/+9
| |
* | Merge pull request #4291 from pks-t/pks/regex-header-confusionPatrick Steinhardt2017-07-071-0/+1
|\ \ | |/ |/| tests: config: fix missing declaration causing error
| * tests: config: fix missing declaration causing errorPatrick Steinhardt2017-07-051-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | On systems where we pull in our distributed version of the regex library, all tests in config::readonly fail. This error is actually quite interesting: the test suite is unable to find the declaration of `git_path_exists` and assumes it has a signature of `int git_path_exists(const char *)`. But actually, it has a `bool` return value. Due to this confusion, some wrong conversion is done by the compiler and the `cl_assert(!git_path_exists("file"))` checks erroneously fail, even when the function does in fact return the correct value. The error is actually introduced by 56893bb9a (cmake: consistently use TARGET_INCLUDE_DIRECTORIES if available, 2017-06-28), unfortunately introduced by myself. Due to the delayed addition of include directories, we will now find the "config.h" header inside of the "deps/regex" directory instead of inside the "src/" directory, where it should be. As such, we are missing definitions for the `git_config_file__ondisk` and `git_path_exists` symbols. The correct fix here would be to fix the order in which include search directories are added. But due to the current restructuring of CMakeBuild.txt, I'm refraining from doing so and delay the proper fix a bit. Instead, we paper over the issue by explicitly including "path.h" to fix its prototype. This ignores the issue that `git_config_file__ondisk` is undeclared, as its signature is correctly identified by the compiler.
* Merge branch 'AndreyG/cmake/modernization'Patrick Steinhardt2017-06-281-1/+10
|\
| * cmake: consistently use TARGET_INCLUDE_DIRECTORIES if availablePatrick Steinhardt2017-06-281-5/+4
| | | | | | | | | | | | Instead of using INCLUDE_DIRECTORIES again for the libgit2_clar test suite, we should just be using TARGET_INCLUDE_DIRECTORIES again if the CMake version is greater than 2.8.11.
| * cmake: use `target_include_directories` for modern cmakeAndrey Davydov2017-06-281-1/+11
| | | | | | | | Apply `target_include_directories` when CMAKE_VERSION >= 2.8.12
* | Merge pull request #4280 from ids1024/htonsPatrick Steinhardt2017-06-271-1/+1
|\ \ | |/ |/| Convert port with htons() in p_getaddrinfo()
| * Convert port with htons() in p_getaddrinfo()Ian Douglas Scott2017-06-231-1/+1
| | | | | | | | `sin_port` should be in network byte order.
* | Merge pull request #4235 from pks-t/pks/out-of-tree-buildsPatrick Steinhardt2017-06-274-18/+29
|\ \ | | | | | | Out of tree builds
| * | tests: refs::crashes: create sandbox for creating symrefPatrick Steinhardt2017-06-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | The test `refs::crashes::double_free` operates on our in-source "testrepo.git" repository without creating a copy first. As the test will try to create a new symbolic reference, this will fail when we want to do a pure out-of-tree build with a read-only source tree. Fix the issue by creating a sandbox first.
| * | tests: index::tests: create sandboxed repo for lockingPatrick Steinhardt2017-06-231-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The test `index::tests::can_lock_index` operates on the "testrepo.git" repository located inside of our source tree. While this is okay for tests which do read-only operations on these resouces, this specific test tries to lock the index by creating a lock. This will obviously fail on out-of-tree builds with read-only source trees. Fix the issue by creating a sandbox first.
| * | cmake: generate clar.suite in binary directoryPatrick Steinhardt2017-06-231-3/+4
| | | | | | | | | | | | | | | | | | | | | Change the output path of generate.py to generate the clar.suite file inside of the binary directory. This fixes out of tree builds with read-only source trees as we now refrain from writing anything into the source tree.
| * | generate.py: generate clar cache in binary directoryPatrick Steinhardt2017-06-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | The source directory should usually not be touched when using out-of-tree builds. But next to the previously fixed "clar.suite" file, we are also writing the ".clarcache" into the project's source tree, breaking the builds. Fix this by also honoring the output directory for the ".clarcache" file.
| * | generate.py: enable overriding path of generated clar.suitePatrick Steinhardt2017-06-231-3/+6
| | | | | | | | | | | | | | | | | | | | | The generate.py script will currently always write the generated clar.suite file into the scanned directory, breaking out-of-tree builds with read-only source directories. Fix this issue by adding another option to allow overriding the output path of the generated file.
| * | generate.py: disallow generating test suites for multiple pathsPatrick Steinhardt2017-06-231-8/+11
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our generate.py script is used to extract and write test suite declarations into the clar.suite file. As is, the script accepts multiple directories on the command line and will generate this file for each of these directories. The generate.py script will always write the clar.suite file into the directory which is about to be scanned. This actually breaks out-of-tree builds with libgit2, as the file will be generated in the source tree instead of in the build tree. This is noticed especially in the case where the source tree is mounted read-only, rendering us unable to build unit tests. Due to us accepting multiple paths which are to be scanned, it is not trivial to fix though. The first solution which comes into mind would be to re-create the directory hierarchy at a given output path or use unique names for the clar.suite files, but this is rather cumbersome and magical. The second and cleaner solution would be to fold all directories into a single clar.suite file, but this would probably break some use-cases. Seeing that we do not ever pass multiple directories to generate.py, we will now simply retire support for this. This allows us to later on introduce an additional option to specify the path where the clar.suite file will be generated at, defaulting to "clar.suite" inside of the scanned directory.
* | Merge pull request #4278 from pks-t/pks/cmake-disable-http-parserPatrick Steinhardt2017-06-261-2/+3
|\ \ | |/ |/| cmake: Permit disabling external http-parser
| * cmake: Permit disabling external http-parserJason Cooper2017-06-221-2/+3
|/ | | | | | | | | | | | | When attempting to build libgit2 as an isolated static lib, CMake gleefully attempts to use the system http-parser. This is typically seen on Linux systems which install header files with every package, such as Gentoo. Allow developers to forcibly disable using the system http-parser with the config switch USE_EXT_HTTP_PARSER. Defaults to ON to maintain previous behavior. Signed-off-by: Jason Cooper <jason@lakedaemon.net>
* Merge pull request #4277 from pks-t/pks/merge-coverity-fixEdward Thomson2017-06-211-1/+1
|\ | | | | merge: fix potential free of uninitialized memory
| * merge: fix potential free of uninitialized memoryPatrick Steinhardt2017-06-211-1/+1
|/ | | | | | | | | | The function `merge_diff_mark_similarity_exact` may error our early and, when it does so, free the `ours_deletes_by_oid` and `theirs_deletes_by_oid` variables. While the first one can never be uninitialized due to the first call actually assigning to it, the second variable can be freed without being initialized. Fix the issue by initializing both variables to `NULL`.
* Merge pull request #4202 from mitesch/linear_exact_renameEdward Thomson2017-06-211-31/+152
|\ | | | | merge: perform exact rename detection in linear time
| * merge: perform exact rename detection in linear timeMichael Tesch2017-05-171-31/+152
| | | | | | | | | | | | | | | | | | The current exact rename detection has order n^2 complexity. We can do better by using a map to first aggregate deletes and using that to match deletes to adds. This results in a substantial performance improvement for merges with a large quantity of adds and deletes.
* | Merge pull request #4211 from pks-t/pks/trustyEdward Thomson2017-06-213-9/+34
|\ \ | | | | | | travis: upgrade container to Ubuntu 14.04
| * | travis: upgrade container to Ubuntu 14.04Patrick Steinhardt2017-06-211-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ubuntu 12.04 (Precise Pangolin) reaches end of life on April 28th, 2017. As such, we should update our build infrastructure to use the next available LTS release, which is Ubuntu 14.04 LTS (Trusty Tahr). Note that Trusty is still considered beta quality on Travis. But considering we are able to correctly build and test libgit2, this seems to be a non-issue for us. Switch over our default distribution to Trusty. As Precise still has extended support for paying customers, add an additional job which compiles libgit2 on the old release.
| * | travis: cibuild: set up our own sshd serverPatrick Steinhardt2017-06-211-8/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some tests of ours require to be running against an SSH server. Currently, we simply run against the SSH server provided and started by Travis itself. As our Linux tests run in a sudo-less environment, we have no control over its configuration and startup/shutdown procedure. While this has been no problem until now, it will become a problem as soon as we migrate over to newer Precise images, as the SSH server does not have any host keys set up. Luckily, we can simply set up our own unpriviledged SSH server. This has the benefit of us being able to modify its configuration even in a sudo-less environment. This commit sets up the unpriviledged SSH server on port 2222.
| * | tests: online::clone: use URL of test serverPatrick Steinhardt2017-06-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All our tests running against a local SSH server usually read the server's URL from environment variables. But online::clone::ssh_cert test fails to do so and instead always connects to "ssh://localhost/foo". This assumption breaks whenever the SSH server is not running on the standard port, e.g. when it is running as a user. Fix the issue by using the URL provided by the environment.
* | | Merge pull request #4273 from azdavis/fix-template-dir-empty-stringPatrick Steinhardt2017-06-212-3/+20
|\ \ \ | |/ / |/| | Fix template dir empty string
| * | repository: remove trailing whitespaceAriel Davis2017-06-191-2/+2
| | |
| * | repository: do not initialize templates if dir is an empty stringAriel Davis2017-06-191-1/+7
| | |
| * | tests: try to init with empty template pathAriel Davis2017-06-161-0/+11
|/ /
* | CHANGELOG: document git_filter_init and GIT_FILTER_INITv0.26.0-rc2v0.26.0Edward Thomson2017-06-141-0/+3
| |
* | Merge pull request #4267 from mohseenrm/masterEdward Thomson2017-06-143-1/+24
|\ \ | | | | | | adding GIT_FILTER_VERSION to GIT_FILTER_INIT as part of convention
| * | Adding git_filter_init for initializing `git_filter` struct + unit test Mohseen Mukaddam2017-06-133-1/+24
| | |
| * | adding GIT_FILTER_VERSION to GIT_FILTER_INIT as part of conventionMohseen Mukaddam2017-06-131-1/+1
| | |
* | | Merge pull request #4268 from pks-t/pks/homebrew-dupes-deprecationEdward Thomson2017-06-141-1/+1
|\ \ \ | | | | | | | | travis: replace use of deprecated homebrew/dupes tap
| * | | travis: replace use of deprecated homebrew/dupes tapPatrick Steinhardt2017-06-131-1/+1
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | The formulae provided by the homebrew/dupes tap are deprecated since at least April 4, 2017, with formulae having been migrated to homebrew/core. Replace the deprecated reference to "homebrew/dupes/zlib" with only "zlib".
* | | Merge pull request #4269 from pks-t/pks/testsEdward Thomson2017-06-146-33/+294
|\ \ \ | |/ / |/| | Test improvements
| * | tests: odb: add more low-level backend testsPatrick Steinhardt2017-06-131-0/+232
| | | | | | | | | | | | | | | | | | | | | Introduce a new test suite "odb::backend::simple", which utilizes the fake backend to exercise the ODB abstraction layer. While such tests already exist for the case where multiple backends are put together, no direct testing for functionality with a single backend exist yet.
| * | tests: odb: implement `exists_prefix` for the fake backendPatrick Steinhardt2017-06-132-0/+22
| | | | | | | | | | | | | | | | | | The fake backend currently implements all reading functions except for the `exists_prefix` one. Implement it to enable further testing of the ODB layer.
| * | tests: odb: use correct OID lengthPatrick Steinhardt2017-06-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The `search_object` function takes the OID length as one of its parameters, where its maximum length is `GIT_OID_HEXSZ`. The `exists` function of the fake backend used `GIT_OID_RAWSZ` though, leading to only the first half of the OID being used when finding the correct object.
| * | tests: odb: have the fake backend detect ambiguous prefixesPatrick Steinhardt2017-06-131-26/+32
| | | | | | | | | | | | | | | | | | | | | | | | In order to be able to test the ODB prefix functions, we need to be able to detect ambiguous prefixes in case multiple objects with the same prefix exist in the fake ODB. Extend `search_object` to detect ambiguous queries and have callers return its error code instead of always returning `GIT_ENOTFOUND`.
| * | tests: core: test initialization of `git_proxy_options`Patrick Steinhardt2017-06-131-0/+5
| | | | | | | | | | | | | | | | | | Initialization of the `git_proxy_options` structure is never tested anywhere. Include it in our usual initialization test in "core::structinit::compare".
| * | tests: network: add missing include for `git_repository_new`Patrick Steinhardt2017-06-131-0/+1
| | | | | | | | | | | | | | | | | | | | | A newly added test uses the `git_repository_new` function without the corresponding header file being included. While this works due to the compiler deducing the correct function signature, we should obviously just include the function's declaration file.
| * | cmake: disable optimization on debug buildsPatrick Steinhardt2017-06-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While our debug builds on MSVC platforms already tune the code optimizer to aid debugging code, all the other platforms still use the default optimization level. This makes it hard for developers on these platforms to actually debug code while maintaining his sanity due to optimizations like inlined code, elided variables etc. To help this common use case, we can simply follow the MSVC example and turn off code optimization with "-O0" for debug builds. While it would be preferable to instead use "-Og" supported by more modern compilers, we cannot guarantee that this level is available on all supported platforms.
| * | cmake: set "-D_DEBUG" on non-Windows platformsPatrick Steinhardt2017-06-131-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In our code base, we have some occasions where we use the "_DEBUG" preprocessor macro to enable additional code which should not be part of release builds. While we define this flag on MSVC platforms, it is guarded by the conditional `WIN32 AND NOT CYGWIN` on other platforms since 19be3f9e6 (Improve MSVC compiler, linker flags, 2013-02-13). While this condition can be fulfilled by the MSVC platform, it is never encountered due to being part of the `ELSE` part of `IF (MSVC)`. The intention of the conditional was most likely to avoid the preprocessor macro on Cygwin platforms, but to include it on everthing else. As such, the correct condition here would be `IF (NOT CYGWIN)` instead. But digging a bit further, the condition is only ever used in two places: 1. To skip the test in "core::structinit", which should also work on Cygwin. 2. In "src/win32/git2.rc", where it is used to set additional file flags. As this file is included in MSVC builds only, it cannot cause any harm to set "_DEBUG" on Cygwin here. As such, we can simply drop the conditional and always set "-D_DEBUG" on all platforms.
| * | cmake: remove stale comment on precompiled headersPatrick Steinhardt2017-06-131-3/+0
|/ / | | | | | | | | | | | | In commit 9f75a9ce7 (Turning on runtime checks when building debug under MSVC., 2012-03-30), we introduced a comment "Precompiled headers", which actually refers to no related commands. Seeing that the comment never had anything to refer to, we can simply remove it here.
* | Merge pull request #4265 from pks-t/pks/read-prefix-testsEdward Thomson2017-06-124-155/+299
|\ \ | | | | | | Read prefix tests
| * | tests: odb: add tests with multiple backendsPatrick Steinhardt2017-06-121-0/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previous to pulling out and extending the fake backend, it was quite cumbersome to write tests for very specific scenarios regarding backends. But as we have made it more generic, it has become much easier to do so. As such, this commit adds multiple tests for scenarios with multiple backends for the ODB. The changes also include a test for a very targeted scenario. When one backend found a matching object via `read_prefix`, but the last backend returns `GIT_ENOTFOUND` and when object hash verification is turned off, we fail to reset the error code to `GIT_OK`. This causes us to segfault later on, when doing a double-free on the returned object.
| * | tests: odb: allow passing fake objects to the fake backendPatrick Steinhardt2017-06-123-76/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now, the fake backend is quite restrained in the way how it works: we pass it an OID which it is to return later as well as an error code we want it to return. While this is sufficient for existing tests, we can make the fake backend a little bit more generic in order to allow us testing for additional scenarios. To do so, we change the backend to not accept an error code and OID which it is to return for queries, but instead a simple array of OIDs with their respective blob contents. On each query, the fake backend simply iterates through this array and returns the first matching object.