summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | | | Merge pull request #5615 from libgit2/pks/azure-remove-docjobEdward Thomson2020-08-311-37/+0
|\ \ \ \ \ \ | |_|/ / / / |/| | | | | azure: Remove job generating documentation
| * | | | | azure: Remove job generating documentationpks/azure-remove-docjobPatrick Steinhardt2020-08-241-37/+0
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the recent addition of GitHub Actions to our CI infrastructure, we now have two jobs which generate documentation: once in GHA, once in Azure. Naturally, as they both want to update the same branch, they race against each other and one of both jobs will fail. Fix this by removing the documentation job from Azure.
* | | | | Merge pull request #5617 from muhkuh-sys/masterEdward Thomson2020-08-281-1/+1
|\ \ \ \ \ | | | | | | | | | | | | Fix crash in git_describe_commit when opts are NULL.
| * | | | | Fix crash in git_describe_commit when opts are NULL.Christoph Thelen2020-08-271-1/+1
|/ / / / / | | | | | | | | | | | | | | | | | | | | The argument "opts" can be NULL, which selects default options. Do not access "opts" directly but only the normalized copy.
* | | | | Merge pull request #5600 from andrewhickman/fix-double-freePatrick Steinhardt2020-08-241-2/+5
|\ \ \ \ \ | | | | | | | | | | | | Fix `git_mwindow_scan_recently_used` spuriously returning true
| * | | | | Preserve behaviour of `git_mwindow_scan_recently_used` with `*out_window` setAndrew Hickman2020-08-051-2/+9
| | | | | |
| * | | | | Fix `git_mwindow_scan_recently_used` spuriously returning trueAndrew Hickman2020-08-051-5/+1
| |/ / / /
* | | | | Merge pull request #5599 from libgit2/ethomson/zlibPatrick Steinhardt2020-08-241-2/+8
|\ \ \ \ \ | | | | | | | | | | | | zstream: handle Z_BUF_ERROR appropriately in get_output_chunk
| * | | | | pack: check pack_window_open returnEdward Thomson2020-08-051-1/+4
| | | | | |
| * | | | | zstream: handle Z_BUF_ERROR appropriately in get_output_chunkEdward Thomson2020-08-051-1/+4
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our processing loop in git_zstream_get_output_chunk does not handle `Z_BUF_ERROR` appropriately at the end of a compressed window. From the zlib manual, inflate will return: > Z_BUF_ERROR if no progress was possible or if there was not enough > room in the output buffer when Z_FINISH is used. Note that Z_BUF_ERROR > is not fatal, and inflate() can be called again with more input and > more output space to continue decompressing. In our loop, we were waiting until we got the expected size, then ensuring that we were at `Z_STREAM_END`. We are not guaranteed to be, since zlib may be in the `Z_BUF_ERROR` state where it has consumed a full window's worth of data, but it doesn't know that it's really at the end of the stream. There _could_ be more compressed data, but it doesn't _know_ that there's not until we make a subsequent call. We can change the loop to look for the end of stream instead of our expected size. This allows us to call inflate one last time when we are at the end of a window (and in the `Z_BUF_ERROR` state), allowing it to recognize the end of the stream, and move from the `Z_BUF_ERROR` state to the `Z_STREAM_END` state. If we do this, we need another exit condition: when `bytes == 0`, then no progress could be made and we should stop trying to inflate. This will be an error case, caught by the size and/or end-of-stream test.
* | | | | Merge pull request #5610 from SirWindfield/patch-1Patrick Steinhardt2020-08-241-1/+1
|\ \ \ \ \ | |/ / / / |/| | | | docs: fix typo
| * | | | docs: fix typoSven2020-08-181-1/+1
|/ / / /
* | | | Merge pull request #5596 from libgit2/ethomson/sanitizer_ciEdward Thomson2020-08-031-0/+2
|\ \ \ \ | | | | | | | | | | sanitizer ci: skip negotiate tests
| * | | | sanitizer ci: skip negotiate testsethomson/sanitizer_ciEdward Thomson2020-08-031-0/+2
|/ / / / | | | | | | | | | | | | | | | | We don't build with SPNEGO enabled on our focal-based sanitizer builds, so we need to disable the negotiate tests.
* | | | Merge pull request #5569 from lhchavez/ci-sanitizersEdward Thomson2020-08-034-8/+138
|\ \ \ \ | | | | | | | | | | Add CI support for Memory and UndefinedBehavior Sanitizers
| * | | | Add CI support for Memory and UndefinedBehavior Sanitizerslhchavez2020-07-094-8/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds two new build targets: MSan and UBSan. This is because even though OSS-Fuzz is great and adds a lot of coverage, it only does that for the fuzz targets, so the rest of the codebase is not necessarily run with the Sanitizers ever :( So this change makes sure that MSan/UBSan warnings don't make it into the codebase. As part of this change, the Ubuntu focal container is introduced. It builds mbedTLS and libssh2 as debug libraries into /usr/local and as MSan-enabled libraries into /usr/local/msan. This latter part is needed because MSan requires the binary and all its dependent libraries to be built with MSan support so that memory allocations and deallocations are tracked correctly to avoid false positives.
* | | | | Merge pull request #5563 from pks-t/pks/worktree-headsEdward Thomson2020-08-038-245/+119
|\ \ \ \ \ | | | | | | | | | | | | Access HEAD via the refdb backends
| * | | | | tests: verify renaming branch really updates worktree HEADPatrick Steinhardt2020-07-121-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case where a branch is getting renamed, all HEADs of the main repository and of its worktrees that point to the old branch need to get updated to point to the new branch. We already do so and have a test for this, but the test only verifies that we're able to lookup the updated HEAD, not what it contains. Let's make the test more specific by verifying the updated HEAD also has the correct updated symbolic target.
| * | | | | refs: remove function to read HEAD directlyPatrick Steinhardt2020-07-122-52/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the last user of `git_reference__read_head` gone, let's remove it as it's been reading references without consulting the refdb backends.
| * | | | | repository: retrieve worktree HEAD via refdbPatrick Steinhardt2020-07-122-22/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function `git_repository_head_for_worktree` currently uses `git_reference__read_head` to directly read a given worktree's HEAD from the filesystem. This is broken in case the repository uses a different refdb implementation than the filesystem-based one, so let's instead open the worktree as a real repository and use `git_reference_lookup`. This also fixes the case where the worktree's HEAD is not a symref, but a detached HEAD, which would have resulted in an error previously.
| * | | | | repository: remove function to iterate over HEADsPatrick Steinhardt2020-07-123-111/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function `git_repository_foreach_head` is broken, as it directly interacts with the on-disk representation of the reference database, thus assuming that no other refdb is used for the given repository. As this is an internal function only and all users have been replaced, let's remove this function.
| * | | | | branch: determine whether a branch is checked out via refdbPatrick Steinhardt2020-07-121-20/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently determine whether a branch is checked out via `git_repository_foreach_head`. As this function reads references directly from the disk, it breaks our refdb abstraction in case the repository uses a different reference backend implementation than the filesystem-based one. So let's use `git_repository_foreach_worktree` instead -- while it's less efficient, it is at least correct in all corner cases.
| * | | | | refs: update HEAD references via refdbPatrick Steinhardt2020-07-121-65/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When renaming a reference, we need to iterate over every HEAD and potentially update it in case it is a symbolic reference pointing to the previous name of the renamed reference. Most importantly, this doesn't only include HEADs from the repo we're renaming the reference in, but we also need to iterate over HEADs from linked worktrees. In order to update the HEADs, we directly read them from the worktree's gitdir and thus assume that both repository and worktrees use the filesystem-based reference backend. But this breaks as soon as one got a repository with a different refdb and breaks our own abstractions. So let's instead update HEAD references via the refdb by first opening each worktree as a repository and then using the usual functions to read and update HEADs. This is a lot less efficient than the current code, but it's not like we can really help this: going via the refdb is mandatory.
| * | | | | repository: introduce new function to iterate over all worktreesPatrick Steinhardt2020-07-123-0/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Given a Git repository, it's non-trivial to iterate over all worktrees that are associated with it, including the "main" repository. This commit adds a new internal function `git_repository_foreach_worktree` that does this for us.
* | | | | | Merge pull request #5582 from libgit2/pks-config-map-optimizationEdward Thomson2020-08-031-27/+35
|\ \ \ \ \ \ | | | | | | | | | | | | | | config_entries: Avoid excessive map operations
| * | | | | | config_entries: Avoid excessive map operationspks-config-map-optimizationPatrick Steinhardt2020-07-131-27/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When appending config entries, we currently always first get the currently existing map entry and then afterwards update the map to contain the current config value. In the common scenario where keys aren't being overridden, this is the best we can do. But in case a key gets set multiple times, then we'll also perform these two map operations. In extreme cases, hashing the map keys will thus start to dominate performance. Let's optimize the pattern by using a separately allocated map entry. Currently, we always put the current list entry into the map and update it to get any overridden multivar. As these list entries are also used to iterate config entries, we cannot update them in-place in the map and are thus forced to always set the map to contain the new entry. But with a separately allocated map entry, we can now create one once per config key and insert it into the map. Whenever appending a new config value with the same key, we can now just update the map entry in-place instead of having to replace the map entry completely. This reduces calls to the hashing function by half and trades the improved runtime for one more allocation per unique config key. Given that the refactoring arguably improves code readability by splitting concerns of the `config_entry_list` type and not having to track it in two different structures, this alone would already be reason enough to take the trade. Given a pathological case of a gitconfig with 100.000 repeated keys and a section of length 10.000 characters, this reduces runtime by half from approximately 14 seconds to 7 seconds as expected.
* | | | | | | Merge pull request #5396 from lhchavez/mwindow-file-limitEdward Thomson2020-07-124-54/+281
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | mwindow: set limit on number of open files
| * | | | | | | Minor nits and style formattinglhchavez2020-07-122-19/+18
| | | | | | | |
| * | | | | | | Create the repository within the testlhchavez2020-06-272057-37/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change moves the humongous static repository with 1025 commits into the test file, now with a more modest 16 commits.
| * | | | | | | Review feedbacklhchavez2020-06-263-58/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Change the default of the file limit to 0 (unlimited). * Changed the heuristic to close files to be the file that contains the least-recently-used window such that the window is the most-recently-used in the file, and the file does not have in-use windows. * Parameterized the filelimit test to check for a limit of 1 and 100 open windows.
| * | | | | | | mwindow: set limit on number of open fileslhchavez2020-06-212060-18/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are some cases in which repositories accrue a large number of packfiles. The existing mwindow limit applies only to the total size of mmap'd files, not on their number. This leads to a situation in which having lots of small packfiles could exhaust the allowed number of open files, particularly on macOS, where the default ulimit is very low (256). This change adds a new configuration parameter (GIT_OPT_SET_MWINDOW_FILE_LIMIT) that sets the maximum number of open packfiles, with a default of 128. This is low enough so that even macOS users should not hit it during normal use. Based on PR #5386, originally written by @josharian. Fixes: #2758
* | | | | | | | Merge pull request #5570 from libgit2/pks/refdb-refactoringsEdward Thomson2020-07-125-174/+254
|\ \ \ \ \ \ \ \ | |_|/ / / / / / |/| | | | | | | refdb: a set of preliminary refactorings for the reftable backend
| * | | | | | | refdb: avoid unlimited spinning in case of symref cyclespks/refdb-refactoringsPatrick Steinhardt2020-07-121-13/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To determine whether another reflog entry needs to be written for HEAD on a reference update, we need to see whether HEAD directly or indirectly points to the reference we're updating. The resolve logic is currently completely unbounded except an error occurs, which effectively means that we'd be spinning forever in case we have a symref loop in the repository refdb. Let's fix the issue by using `git_refdb_resolve` instead, which is always bounded.
| * | | | | | | refs: replace reimplementation of reference resolverPatrick Steinhardt2020-07-121-49/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The refs code currently has a second implementation that resolves references in order to find any final symbolic reference pointing to a nonexistent target branch. As we've just extended `git_refdb_resolve` to also return such references, let's use that one instead in order to reduce code duplication.
| * | | | | | | refdb: return resolved symbolic refs pointing to nonexistent refsPatrick Steinhardt2020-07-123-1/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In some cases, resolving references requires us to also know about the final symbolic reference that's pointing to a nonexistent branch, e.g. in an empty repository where the main branch is yet unborn but HEAD already points to it. Right now, the resolving logic is thus split up into two, where one is the new refdb implementation and the second one is an ad-hoc implementation inside "refs.c". Let's extend `git_refdb_resolve` to also return such final dangling references pointing to nonexistent branches so we can deduplicate the resolving logic.
| * | | | | | | refs: move resolving of references into the refdbPatrick Steinhardt2020-07-123-40/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolving of symbolic references is currently implemented inside the "refs" layer. As a result, it's hard to call this function from low-level parts that only have a refdb available, but no repository, as the "refs" layer always operates on the repository-level. So let's move the function into the generic "refdb" implementation to lift this restriction.
| * | | | | | | tests: reflog: remove unused signaturePatrick Steinhardt2020-07-121-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's two tests that create a commit signature, but never make any use of it. Let's remove these to avoid any confusion.
| * | | | | | | refdb: extract function to check whether to append HEAD to the reflogPatrick Steinhardt2020-07-123-39/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The logic to determine whether a reflog entry should be for the HEAD reference is non-trivial. Currently, the only user of this is the filesystem-based refdb, but with the advent of the reftable refdb we're going to add a second user that's interested in having the same behaviour. Let's pull out a new function that checks whether a given reference should cause a entry to be written to the HEAD reflog as a preparatory step.
| * | | | | | | refdb: extract function to check whether a reflog should be writtenPatrick Steinhardt2020-07-123-39/+69
| | |_|/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The logic to determine whether a reflog should be written is non-trivial. Currently, the only user of this is the filesystem-based refdb, but with the advent of the reftable refdb we're going to add a second user that's interested in having the same behaviour. Let's pull out a new function that checks whether a given reference should cause a reflog to be written as a preparatory step.
* | | | | | | Merge pull request #5547 from pks-t/pks/cmake-modernization-pt2Patrick Steinhardt2020-07-125-160/+40
|\ \ \ \ \ \ \ | |/ / / / / / |/| | | | | | CMake modernization pt2
| * | | | | | cmake: remove CheckPrototypeDefinition modulePatrick Steinhardt2020-07-122-125/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the past, we've imported the CheckPrototypeDefinition into our own module directory as it wasn't yet available in all supported CMake versions. Now that we require at least CMake v3.5, we don't need to bundle it anymore as it's included with the distribution already. Let's drop the included modules and always use upstream's version.
| * | | | | | cmake: use target-specific compile definitionsPatrick Steinhardt2020-07-121-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We set up some compile definitions as part of our src/CMakeLists.txt. While the definitions are global, we really only need them as part of the git2internal target which compiles all the objects. Let's thus use `target_compile_definitions` instead of `add_definitions`.
| * | | | | | cmake: use git2internal target to populate sourcesPatrick Steinhardt2020-07-121-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modern CMake is usually target-driven in that a target is first defined and then the likes of `target_sources`, `target_include_directories` etc. are used to further populate the target. We still use old-style CMake, where we first set up a set of variables and then populate the target in a single call. Let's migrate to modern CMake usage by starting to populate the sources of our git2internal target piece-by-piece. While this is a small step, it allows us to convert to target-based build instructions piece-by-piece.
| * | | | | | cmake: specify project versionPatrick Steinhardt2020-07-123-23/+22
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently do not set up a project version within CMake, meaning that it can't be use by other projects including libgit2 as a sub-project and also not by other tools like IDEs. This commit changes this to always set up a project version, but instead of extracting it from the "version.h" header we now set it up directly. This is mostly to avoid mis-use of the previous `LIBGIT2_VERSION` variables, as we should now always use the `libgit2_VERSION` ones that are set up by CMake if one provides the "VERSION" keyword to the `project()` call. While this is one more moving target we need to adjust on releases, this commit also adjusts our release script to verify that the project version was incremented as expected.
* | | | | | Merge pull request #5568 from lhchavez/ubsanEdward Thomson2020-07-093-9/+15
|\ \ \ \ \ \ | | | | | | | | | | | | | | Make the tests run cleanly under UndefinedBehaviorSanitizer
| * | | | | | Make the tests run cleanly under UndefinedBehaviorSanitizerlhchavez2020-06-303-9/+15
| | |/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change makes the tests run cleanly under `-fsanitize=undefined,nullability` and comprises of: * Avoids some arithmetic with NULL pointers (which UBSan does not like). * Avoids an overflow in a shift, due to an uint8_t being implicitly converted to a signed 32-bit signed integer after being shifted by a 32-bit signed integer. * Avoids a unaligned read in libgit2. * Ignores unaligned reads in the SHA1 library, since it only happens on Intel processors, where it is _still_ undefined behavior, but the semantics are moderately well-understood. Of notable omission is `-fsanitize=integer`, since there are lots of warnings in zlib and the SHA1 library which probably don't make sense to fix and I could not figure out how to silence easily. libgit2 itself also has ~100s of warnings which are mostly innocuous (e.g. use of enum constants that only fit on an `uint32_t`, but there is no way to do that in a simple fashion because the data type chosen for enumerated types is implementation-defined), and investigating whether there are worrying warnings would need reducing the noise significantly.
* | | | | | Merge pull request #5567 from lhchavez/msanEdward Thomson2020-07-099-13/+21
|\ \ \ \ \ \ | | | | | | | | | | | | | | Make the tests pass cleanly with MemorySanitizer
| * | | | | | Make the tests pass cleanly with MemorySanitizerlhchavez2020-06-309-13/+21
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change: * Initializes a few variables that were being read before being initialized. * Includes https://github.com/madler/zlib/pull/393. As such, it only works reliably with `-DUSE_BUNDLED_ZLIB=ON`.
* | | | | | Merge pull request #5561 from A-Ovchinnikov-mx/a-ovchin/windres-rcEdward Thomson2020-07-092-6/+19
|\ \ \ \ \ \ | |_|_|/ / / |/| | | | | Enable building git2.rc resource script with GCC
| * | | | | Use __GNUC__ macro in the resource scriptAlexander Ovchinnikov2020-07-012-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | Fix the default LIBGIT2_FILENAME for GNU windres