summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Fix Issue #4047 Check return codes and free objectsexample_generalDouglas Swanson2017-10-071-3/+28
|
* Merge pull request #4363 from cjhoward92/typedef-push-update-referenceEdward Thomson2017-10-071-4/+16
|\ | | | | remote: add typedef to normalize push_update_reference callback
| * remote: add typedef to normalize push_update_reference callbackCarson Howard2017-10-061-4/+16
| | | | | | Very many callbacks in libgit2 have some sort of typedef to normalize the name at git_<name_of_operation>_cb. Add a typedef for push_update_references in the remote so the name follows the same conventions.
* | Merge pull request #4367 from pks-t/pks/peel-peeled-to-tagEdward Thomson2017-10-072-1/+19
|\ \ | |/ |/| refs: do not use peeled OID if peeling to a tag
| * refs: do not use peeled OID if peeling to a tagPatrick Steinhardt2017-10-062-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #4362 from jacwah/graphdocPatrick Steinhardt2017-10-061-0/+3
|\ \ | | | | | | Document that a commit is not a descendant of itself
| * | graph: document that a commit isn't a descendant of itselfJacob Wahlgren2017-10-061-0/+3
| |/
* | Merge pull request #4364 from andoma/masterPatrick Steinhardt2017-10-062-1/+4
|\ \ | |/ |/| Use SOCK_CLOEXEC when creating sockets
| * Use SOCK_CLOEXEC when creating socketsAndreas Smas2017-10-032-1/+4
|/
* Merge pull request #4339 from pks-t/pks/static-linkingCarlos Martín Nieto2017-09-287-28/+24
|\ | | | | Static linking for bundled deps
| * travis: keep installing our custom libcurl buildCarlos Martín Nieto2017-09-281-0/+7
| | | | | | | | | | The block in the script installs the packages if we're _not_ on Precise. This was dropped in c17c3f8a ("travis: drop support for Ubuntu Precise") in error.
| * cmake: fix static linking for bundled depsPatrick Steinhardt2017-09-204-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our bundled deps are being built as simple static libraries which are then linked into the libgit2 library via `TARGET_LINK_LIBRARIES`. While this works for a dynamically built libgit2 library, using this function to link two static libraries does not have the expected outcome of merging those static libraries into one big library. This leads to symbols of our bundled deps being undefined in the resulting libgit2 archive. As we have bumped our minimum CMake version to 2.8.11, we can now easily make use of object libraries for our bundled dependencies. So build instructions are still self-contained inside of the dependency directories and the resulting object libraries can just be added to the LIBGIT2_OBJECTS list, which will cause them to be linked into the final resulting static library. This fixes the issue of undefined symbols.
| * cmake: unify version check for target include directoriesPatrick Steinhardt2017-09-201-1/+3
| | | | | | | | | | | | | | | | | | | | 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.
| * cmake: always use object library for git2internalPatrick Steinhardt2017-09-201-13/+8
| | | | | | | | | | | | As we have bumped our minimum CMake version to 2.8.11, we can now unconditionally make use of object libraries. So remove the version check for the git2internal object library and always use it.
| * cmake: bump minimum version to 2.8.11Patrick Steinhardt2017-09-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our current minimum CMake version is 2.8. This version does not yet allow us to use object libraries (introduced in 2.8.8) and target include directories (introduced in 2.8.12), which are both mechanisms we want to use to fix some specific problems. We previously were not able to bump our CMake version to a version supporting object libraries because Ubuntu Precise only had CMake version 2.8.7 in its repositories. But due to Precise being end of life now, we shouldn't need to honor it anymore. A current survey of some of the more conservative distributions brings up the following versions of CMake: - CentOS 5: 2.6.2 - CentOS 6: 2.8.12.2 - Debian 7: 2.8.11 - Fedora 23: 3.3.2 - OpenSUSE 13.2: 3.0.2 - Ubuntu Precise: 2.8.7 - Ubuntu Trusty: 2.8.12 The only two outliers here are CentOS 5 and Ubuntu Precise. CentOS is currently unsupported due to our minimum version being 2.8 and Ubuntu Precise is not maintained anymore. So the next smallest version supported by all major distributions is 2.8.11. While this does not yet support target include directories, it at least enables us to use object libraries. So this becomes our new minimum required version.
| * cmake: distinguish libgit2 objects and sourcesPatrick Steinhardt2017-09-202-6/+9
| | | | | | | | | | | | | | 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.
| * travis: drop support for Ubuntu PrecisePatrick Steinhardt2017-09-202-11/+0
|/ | | | | | | | | | | | | | | | Ubuntu Precise is end of life since April 2017. At that point in time, Precise was still the main distro on which Travis CI built upon, with the Trusty-based images still being in a beta state. But since June 21st, Trusty has officially moved out of beta and is now the default image for all new builds. Right now, we build on both old and new images to assure we support both. Unfortunately, this leaves us with the highest minimum version for CMake being 2.8.7, as Precise has no greater version in its repositories. And because of this limitation, we cannot actually use object libraries in our build instructions. But considering Precise is end of life and Trusty is now the new default for Travis, we can and should drop support for this old and unmaintained distribution. And so we do.
* Merge pull request #4334 from pks-t/pks/reproducible-buildsEdward Thomson2017-09-202-3/+14
|\ | | | | Reproducible builds
| * cmake: enable reproducible static linkingPatrick Steinhardt2017-09-151-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By default, both ar(1) and ranlib(1) will insert additional information like timestamps into generated static archives and indices. As a consequence, generated static archives are not deterministic when created with default parameters. Both programs do support a deterministic mode, which will simply zero out undeterministic information with `ar D` and `ranlib -D`. Unfortunately, CMake does not provide an easy knob to add these command line parameters. Instead, we have to redefine the complete command definitons stored in the variables CMAKE_C_ARCHIVE_CREATE, CMAKE_C_ARCHIVE_APPEND and CMAKE_C_ARCHIVE_FINISH. Introduce a new build option `ENABLE_REPRODUCIBLE_BUILDS`. This option is available on Unix-like systems with the exception of macOS, which does not have support for the required flags. If the option is being enabled, we add those flags to the invocation of both `ar` and `ranlib` to enable deterministically building the static archive.
| * tests: deterministically generate test suite definitionsPatrick Steinhardt2017-08-301-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #4348 from pks-t/pks/win32-hash-memleakEdward Thomson2017-09-161-0/+1
|\ \ | | | | | | diff: cleanup hash ctx in `git_diff_patchid`
| * | diff: cleanup hash ctx in `git_diff_patchid`Patrick Steinhardt2017-09-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After initializing the hash context in `git_diff_patchid`, we never proceed to call `git_hash_ctx_cleanup` on it. While this doesn't really matter on most hash implementations, this causes a memory leak on Win32 due to CNG system requiring a `malloc` call. Fix the memory leak by always calling `git_hash_ctx_cleanup` before exiting.
* | | Merge pull request #4347 from pks-t/pks/appveyor-vs2015Edward Thomson2017-09-152-5/+15
|\ \ \ | |/ / |/| | Fix AppVeyor build failures due to CRTDBG linking issue
| * | appveyor: add jobs to also build on Visual Studio 2015Patrick Steinhardt2017-09-151-0/+6
| | | | | | | | | | | | | | | In order to cover a wider range of build environments, add two more jobs which build and test libgit2 on Visual Studio 14 2015.
| * | appveyor: explicitly specify build imagesPatrick Steinhardt2017-09-151-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AppVeyor currently does provide three standard build worker images with VS2013, VS2015 and VS2017. Right now, we are using the implicitly, which is the VS2015 one. We want to be more explicit about this, so that we can easily switch build images based on the job. So starting from this commit, we explicitly set the `APPVEYOR_BUILD_WORKER_IMAGE` variable per job, which enables us to choose different images. To be able to test a wider range of build configurations, this commit also switches the jobs for VC2010 over to use the older, VS2013 based images. As the next commit will introduce two new jobs for building with VS2015, we have then covered both build environments. Also, let us be a bit more explicit regarding the CMake generator. Instead of only saying "Visual Studio 10", use the more descriptive value "Visual Studio 10 2010" to at least avoid some confusion surrounding the versioning scheme of Visual Studio.
| * | cmake: fix linker error with dbghelper libraryPatrick Steinhardt2017-09-151-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the MSVC_CRTDBG option is set by the developer, we will link in the dbghelper library to enable memory lead detection in MSVC projects. We are doing so by adding it to the variable `CMAKE_C_STANDARD_LIBRARIES`, so that it is linked for every library and executable built by CMake. But this causes our builds to fail with a linker error: ``` LINK: fatal error LNK1104: cannot open file 'advapi32.lib;Dbghelp.lib' ``` The issue here is that we are treating the variable as if it were an array of libraries by setting it via the following command: ``` SET(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}" "Dbghelp.lib") ``` The generated build commands will then simply stringify the variable, concatenating all the contained libraries with a ";". This causes the observed linking failure. To fix the issue, we should just treat the variabable as a simple string. So instead of adding multiple members, we just add the "Dbghelp.lib" library to the existing string, separated by a space character.
* | Merge pull request #4344 from slavikus/fix-dirty-buffer-in-git-push-update-tipsEdward Thomson2017-09-121-0/+3
|\ \ | | | | | | Clear the remote_ref_name buffer in git_push_update_tips()
| * | Clear the remote_ref_name buffer in git_push_update_tips()Slava Karpenko2017-09-111-0/+3
| | | | | | | | | | | | | | | | | | If fetch_spec was a non-pattern, and it is not the first iteration of push_status vector, then git_refspec_transform would result in the new value appended via git_buf_puts to the previous iteration value. Forcibly clearing the buffer on each iteration to prevent this behavior.
* | | Merge pull request #4346 from pks-t/pks/wo-features-headerEdward Thomson2017-09-122-2/+8
|\ \ \ | |/ / |/| | features.h: allow building without CMake-generated feature header
| * | features.h: allow building without CMake-generated feature headerPatrick Steinhardt2017-09-122-2/+8
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In commit a390a8464 (cmake: move defines into "features.h" header, 2017-07-01), we have introduced a new "features.h" header. This file is being generated by the CMake build system based on how the libgit2 build has been configured, replacing the preexisting method of simply setting the defines inside of the CMake build system. This was done to help splitting up the build instructions into multiple separate subdirectories. An overlooked shortcoming of this approach is that some projects making use of libgit2 build the library with custom build systems, without making use of CMake. For those users, the introduction of the "features.h" file makes their life harder as they would have to also generate this file. Fix this issue by guarding all inclusions of the generated header file by the `LIBGIT2_NO_FEATURES_H` define. Like this, other build systems can skip the feature header and simply define all used features by specifying `-D` flags for the compiler again.
* | Merge pull request #4342 from mothacehe/masterCarlos Martín Nieto2017-09-101-0/+2
|\ \ | |/ |/| README: Mention Guile-Git bindings.
| * README: Mention Guile-Git bindings.Mathieu Othacehe2017-09-091-0/+2
|/
* Merge pull request #4296 from pks-t/pks/pattern-based-gitignoreEdward Thomson2017-08-253-36/+120
|\ | | | | Fix negative ignore rules with patterns
| * ignore: honor case insensitivity for negative ignoresPatrick Steinhardt2017-08-252-4/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * tests: status: additional test for negative ignores with patternPatrick Steinhardt2017-08-251-0/+27
| | | | | | | | This test is by Carlos Martín Nieto.
| * ignore: keep negative rules containing wildcardsPatrick Steinhardt2017-08-252-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * ignore: return early to avoid useless indentationPatrick Steinhardt2017-08-251-26/+24
| |
| * ignore: fix indentation of comment blockPatrick Steinhardt2017-08-251-6/+6
| |
* | Merge pull request #4305 from pks-t/pks/submodule-with-bare-repoEdward Thomson2017-08-2514-1/+56
|\ \ | | | | | | Submodules with bare repo
| * | submodule: refuse lookup in bare repositoriesPatrick Steinhardt2017-08-2514-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | tests: submodule: add explicit cleanup function in lookup testsPatrick Steinhardt2017-08-251-0/+5
| | |
| * | tests: submodule: fix declaration of testPatrick Steinhardt2017-08-251-1/+2
| |/ | | | | | | | | | | | | 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.
* | Merge pull request #4279 from pks-t/pks/error-buildsEdward Thomson2017-08-252-12/+28
|\ \ | |/ |/| -Werror builds for Travis
| * travis: error on compiler warningsPatrick Steinhardt2017-08-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | One of our goals is to have our code free of any warnings. Due to the recent switch to Ubuntu 14.04 on Travis, the last warning regarding some preprocessor-magic in the curl-headers has been fixed and as such, the goal of zero warnings is now reached for Travis CI. In order to avoid introducing new warnings via pull requests, we can now enable building with `-Werror` and turn compiler warnings into errors instead, causing the CI jobs to fail. This build does so by passing the newly introdcued `-DENABLE_WERROR` flag to CMake for all Travis jobs.
| * cmake: add switch to build with -WerrorPatrick Steinhardt2017-08-251-1/+9
| | | | | | | | | | | | | | | | Add a simple switch to enable building with "-Werror=<warning>" instead of "-W<warning". Due to the encapsulated `ENABLE_WARNINGS` macro, this is as simple as adding a new variable "ENABLE_WERROR`, which can be passed on the command line via `-DENABLE_WERROR=ON`. The variable defaults to NO to not bother developers in their day to day work.
| * cmake: encapsulate enabling/disabling compiler warningsPatrick Steinhardt2017-08-251-10/+18
|/ | | | | | | | | | | | There are multiple sites where we enable or disable compiler warning via "-W<warning>" or "-Wno-<warning>". As we want to extend this mechanism later on to conditionally switch these over to "-Werror=<warning>", we encapsulate the logic into its their own macros `ENABLE_WARNINGS` and `DISABLE_WARNINGS`. Note that we in fact have to use a macro here. Using a function would not modify the CFLAGS inside of the callers scope, but in the function's scope only.
* Merge pull request #4282 from pks-t/pks/remove-unused-clar-fixturesEdward Thomson2017-08-2413-461/+561
|\ | | | | Split up CMakeLists.txt build instructions
| * cmake: fix output location of import libraries and DLLsPatrick Steinhardt2017-08-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As observed by Edward Thomson, the libgit2 DLL built by Windows will not end up in the top-level build directory but instead inside of the 'src/' subdirectory. While confusing at first because we are actually setting the LIBRARY_OUTPUT_DIRECTORY to the project's binary directory, the manual page of LIBRARY_OUTPUT_DIRECTORY clears this up: There are three kinds of target files that may be built: archive, library, and runtime. Executables are always treated as runtime targets. Static libraries are always treated as archive targets. Module libraries are always treated as library targets. For non-DLL platforms shared libraries are treated as library targets. For DLL platforms the DLL part of a shared library is treated as a runtime target and the corresponding import library is treated as an archive target. All Windows-based systems including Cygwin are DLL platforms. So in fact, DLLs and import libraries are not treated as libraries at all by CMake but instead as runtime and archive targets. To fix the issue, we can thus simply set the variables RUNTIME_OUTPUT_DIRECTORY and ARCHIVE_OUTPUT_DIRECTORY to the project's root binary directory.
| * cmake: always include our own headers firstPatrick Steinhardt2017-08-161-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | With c26ce7840 (Merge branch 'AndreyG/cmake/modernization', 2017-06-28), we have recently introduced a regression in the way we are searching for headers. We have made sure to always include our own headers first, but due to the changes in c26ce7840 this is no longer guaranteed. In fact, this already leads the compiler into picking "config.h" from the "deps/regex" dependency, if it is used. Fix the issue by declaring our internal include directories up front, before any of the other search directories is added.
| * cmake: move library build instructions into subdirectoryPatrick Steinhardt2017-08-162-390/+398
| | | | | | | | | | | | | | | | | | | | To fix leaking build instructions into different targets and to make the build instructions easier to handle, create a new CMakeLists.txt file containing build instructions for the libgit2 target. By now, the split is rather easy to achieve. Due to the preparatory steps, we can now simply move over all related build instructions, only needing to remove the "src/" prefix from some files.