summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Move libgit2 settings into libgit2.cethomson/init-bakEdward Thomson2020-07-113-323/+329
|
* Rename global.c to libgit2.cEdward Thomson2020-07-111-0/+0
| | | | | | | Now that we've identified that our global settings really aren't global at all, and refactored the library to match that, change global.c to libgit2.c, which is especially nice since the prefix of the functions matches the filename.
* runtime: move init/shutdown into the "runtime"Edward Thomson2020-07-1127-215/+259
| | | | | Provide a mechanism for system components to register for initialization and shutdown of the libgit2 runtime.
* thread: don't use the global tlsdata for thread exitEdward Thomson2020-07-112-11/+18
| | | | | | We want to store a pointer to emulate `pthread_exit` on Windows. Do this within the threading infrastructure so that it could potentially be re-used outside of the context of libgit2 itself.
* thread: restore the git_thread_exit testsEdward Thomson2020-07-111-1/+7
| | | | We were never properly testing git_thread_exit. Do so.
* global: separate global state from thread-local stateEdward Thomson2020-07-117-239/+258
| | | | | | | | | | | | | Our "global initialization" has accumulated some debris over the years. It was previously responsible for both running the various global initializers (that set up various subsystems) _and_ setting up the "global state", which is actually the thread-local state for things like error reporting. Separate the thread local state out into "tlsdata". Use the normal subsystem initialization functions that we already have to set it up. This makes both the global initialization system and the tlsdata system simpler to reason about.
* global init: check error message buffer allocationEdward Thomson2020-07-111-2/+5
| | | | | | Ensure that we can allocate the error message buffer. In keeping with our typical policiess, we allow (small) memory leaks in the case where we're out of memory.
* mwindow: localize mutexEdward Thomson2020-07-115-18/+15
| | | | | | Move the mwindow mutex into the mwindow code itself, initializing it in the mwindow global initialization function instead of in the global initializer.
* settings: localize global dataEdward Thomson2020-07-117-19/+38
| | | | | Move the settings global data teardown into its own separate function, instead of intermingled with the global state.
* win32: stack tracing uses the normal initEdward Thomson2020-07-115-15/+18
| | | | | The win32 debug stack handling is not special; it should use the same initialization functionality that everybody else does.
* init: move thread init to git_global_threads_initEdward Thomson2020-07-115-5/+7
| | | | | Instead of treating win32 thread initialization specially in the win32 git_libgit2_init function, add a git_global_threads_init function.
* 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
| * | Review: Rename the stringize macroAlexander Ovchinnikov2020-07-011-5/+5
| | |
| * | Enable building git2.rc resource script with GCCAlexander Ovchinnikov2020-07-012-4/+17
| |/
* | Merge pull request #5571 from lhchavez/ntlmclient-sanitizersEdward Thomson2020-07-021-11/+8
|\ \ | |/ |/| Make NTLMClient Memory and UndefinedBehavior Sanitizer-clean
| * Make NTLMClient Memory and UndefinedBehavior Sanitizer-cleanlhchavez2020-06-301-11/+8
|/ | | | | | | | | | | This change makes the code pass the libgit2 tests cleanly when MSan/UBSan are enabled. Notably: * Changes malloc/memset combos into calloc for easier auditing. * Makes `write_buf` return early if the buffer length is empty to avoid arithmetic with NULL pointers (which UBSan does not like). * Initializes a few arrays that were sometimes being read before being written to.
* Merge pull request #5559 from pks-t/pks/diff-print-fixupsEdward Thomson2020-06-231-52/+55
|\ | | | | Random fixes for diff-printing
| * diff_print: adjust code to match current coding stylePatrick Steinhardt2020-06-171-44/+32
| |
| * diff_print: return out-of-memory situation when printing binaryPatrick Steinhardt2020-06-171-0/+3
| | | | | | | | | | | | We currently don't check for out-of-memory situations on exiting `format_binary` and, as a result, may return a partially filled buffer. Fix this by checking the buffer via `git_buf_oom`.
| * diff_print: do not call abort(3P)Patrick Steinhardt2020-06-171-3/+2
| | | | | | | | | | | | | | | | | | | | Calling abort(3P) in a library is rather rude and shouldn't happen, as we effectively prohibit any corrective actions made by the application linking to it. We thus shouldn't call it at all, but instead use our new `GIT_ASSERT` macros. Remove the call to abort(3P) in case a diff delta has an unexpected type to fix this.
| * diff_print: handle errors when printing to filePatrick Steinhardt2020-06-171-5/+18
| | | | | | | | | | | | | | | | | | | | | | When printing the diff to a `FILE *` handle, we neither check the return value of fputc(3P) nor the one of fwrite(3P). As a result, we'll silently return successful even if we didn't print anything at all. Futhermore, the arguments to fwrite(3P) are reversed: we have one item of length `content_len`, and not `content_len` items of one byte. Fix both issues by checking return values as well as reversing the arguments to fwrite(3P).
* | Merge pull request #5419 from lhchavez/fix-git_index_add_from_buffer-docsPatrick Steinhardt2020-06-171-2/+1
|\ \ | |/ |/| index: Update the documentation for git_index_add_from_buffer()
| * index: Update the documentation for git_index_add_from_buffer()lhchavez2020-02-231-2/+1
| | | | | | | | | | This change makes the docs reflect reality. The id and size were never updated in the entry!
* | Merge pull request #5550 from libgit2/ethomson/github_actionsEdward Thomson2020-06-167-8/+267
|\ \ | | | | | | Introduce CI with GitHub Actions
| * | Introduce CI with GitHub Actionsethomson/github_actionsEdward Thomson2020-06-164-2/+263
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add CI using GitHub Actions and GitHub Packages: * This moves our Linux build containers into GitHub Packages; we will identify the most recent commit that updated the docker descriptions, and then look for a docker image in libgit2's GitHub Packages registry for a container with the tag corresponding to that description. If there is not one, we will build the container and then push it to GitHub Packages. * We no longer need to manage authentication with our own credentials or PAT tokens. GitHub Actions provides a GITHUB_TOKEN that can publish artifacts, packages and commits to our repository within a workflow run. * We will use a matrix to build our various CI steps. This allows us to keep configuration in a single place without multiple YAML files.
| * | docker: don't take BASE as an argumentEdward Thomson2020-06-112-4/+2
| | | | | | | | | | | | | | | | | | The xenial image depends on ubuntu:xenial; the bionic one on ubuntu:bionic. No need for this to be a variable, that's just additional (unnecessary) state to manage in the CI setup(s).
| * | azure pipelines: use bundled zlibEdward Thomson2020-06-101-2/+2
| | | | | | | | | | | | | | | | | | Azure Pipelines has a version of zlib hanging out on the filesystem; avoid trying to use it as it's either 64 _or_ 32 bit, so exactly one of our builds will fail.
* | | Merge pull request #5552 from libgit2/pks/small-fixesEdward Thomson2020-06-133-63/+17
|\ \ \ | | | | | | | | Random code cleanups and fixes
| * | | checkout: remove unused code for deferred removalspks/small-fixesPatrick Steinhardt2020-06-081-53/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With commit 05f690122 (checkout: remove blocking dir when FORCEd, 2015-03-31), the last case was removde that actually queued a deferred removal. This is now more than five years in the past and nobody complained, so we can rest quite assured that the deferred removal is not really needed at all. Let's remove all related code to simplify the already complicated checkout logic.
| * | | tests: refs: modernize coding style of testcasePatrick Steinhardt2020-06-081-8/+3
| | | | | | | | | | | | | | | | | | | | The coding style of the testcase refs::create::propagate_eexists is not really up-to-date. Convert it to use a more modern coding style.
| * | | revparse: remove superfluous tab characterPatrick Steinhardt2020-06-081-1/+1
| | | |
| * | | revparse: detect out-of-memory cases when parsing curly brace contentsPatrick Steinhardt2020-06-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When extracting curly braces (e.g. the "upstream" part in "HEAD@{upstream}"), we put the curly braces' contents into a `git_buf` structure, but don't check the return value of `git_buf_putc`. So when we run out-of-memory, we'll use a partially filled buffer without noticing. Let's fix this issue by checking `git_buf_putc`'s return value.
* | | | Merge pull request #5553 from pks-t/pks/example-log-docfixEdward Thomson2020-06-121-9/+18
|\ \ \ \ | |_|/ / |/| | | examples: log: fix documentation generation
| * | | examples: log: fix documentation generationPatrick Steinhardt2020-06-081-9/+18
| |/ / | | | | | | | | | | | | | | | Docurium seems to be confused by our use of `/** comment */;` use in the log example. Let's just switch it around to help Docurium get this right.
* | | Merge pull request #5551 from pks-t/pks/missing-declarationsPatrick Steinhardt2020-06-1052-124/+148
|\ \ \ | | | | | | | | Missing declarations
| * | | cmake: enable warnings for missing function declarationsPatrick Steinhardt2020-06-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Over time, we have accumulated quite a lot of functions with missing prototypes, missing `static` keywords or which were completely unused. It's easy to miss these mistakes, but luckily GCC and Clang both have the `-Wmissing-declarations` warning. Enabling this will cause them to emit warnings for every not-static function that doesn't have a previous declaration. This is a very sane thing to enable, and with the preceding commits all these new warnings have been fixed. So let's always enable this warning so we won't introduce new instances of them.
| * | | refs: add missing function declarationPatrick Steinhardt2020-06-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | The function `git_reference__is_note` is not declared anywhere. Let's add the declaration to avoid having non-static functions without declaration.
| * | | tree-wide: do not compile deprecated functions with hard deprecationPatrick Steinhardt2020-06-0931-6/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When compiling libgit2 with -DDEPRECATE_HARD, we add a preprocessor definition `GIT_DEPRECATE_HARD` which causes the "git2/deprecated.h" header to be empty. As a result, no function declarations are made available to callers, but the implementations are still available to link against. This has the problem that function declarations also aren't visible to the implementations, meaning that the symbol's visibility will not be set up correctly. As a result, the resulting library may not expose those deprecated symbols at all on some platforms and thus cause linking errors. Fix the issue by conditionally compiling deprecated functions, only. While it becomes impossible to link against such a library in case one uses deprecated functions, distributors of libgit2 aren't expected to pass -DDEPRECATE_HARD anyway. Instead, users of libgit2 should manually define GIT_DEPRECATE_HARD to hide deprecated functions. Using "real" hard deprecation still makes sense in the context of CI to test we don't use deprecated symbols ourselves and in case a dependant uses libgit2 in a vendored way and knows it won't ever use any of the deprecated symbols anyway.
| * | | tree-wide: add missing header includesPatrick Steinhardt2020-06-093-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We're missing some header includes leading to missing function prototypes. While we currently don't warn about these, we should have their respective headers included in order to detect the case where a function signature change results in an incompatibility.
| * | | tree-wide: mark local functions as staticPatrick Steinhardt2020-06-0920-61/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We've accumulated quite some functions which are never used outside of their respective code unit, but which are lacking the `static` keyword. Add it to reduce their linkage scope and allow the compiler to optimize better.
| * | | tree-wide: remove unused functionsPatrick Steinhardt2020-06-084-53/+0
|/ / / | | | | | | | | | | | | We have some functions which aren't used anywhere. Let's remove them to get rid of unneeded baggage.
* | | Revert .github/workflows/main.ymlEdward Thomson2020-06-071-111/+0
| | |
* | | yoEdward Thomson2020-06-072-10/+2
| | |
* | | Update main.ymlEdward Thomson2020-06-071-1/+1
| | |
* | | Update main.ymlEdward Thomson2020-06-071-36/+36
| | |