summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Move libgit2 settings into libgit2.cethomson/initEdward Thomson2020-10-113-331/+331
|
* Rename global.c to libgit2.cEdward Thomson2020-10-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-10-1126-225/+262
| | | | | 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-10-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.
* global: separate global state from thread-local stateEdward Thomson2020-10-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 "threadstate". Use the normal subsystem initialization functions that we already have to set it up. This makes both the global initialization system and the threadstate system simpler to reason about.
* global init: check error message buffer allocationEdward Thomson2020-10-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-10-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-10-116-19/+38
| | | | | Move the settings global data teardown into its own separate function, instead of intermingled with the global state.
* win32: teach the allocator to deal with crtdbgEdward Thomson2020-10-113-15/+21
| | | | | Move the MSVC C runtime debugging bits into the allocator's global init function.
* init: move thread init to git_global_threads_initEdward Thomson2020-10-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 #5651 from libgit2/ethomson/clone_branchEdward Thomson2020-10-111-16/+50
|\ | | | | clone: update origin's HEAD
| * clone: update origin's HEADEdward Thomson2020-10-061-16/+50
| | | | | | | | | | Update `refs/remotes/origin/HEAD` as a symbolic link to the remote's default branch.
* | Avoid using atomics in pool.clhchavez2020-10-084-17/+27
| | | | | | | | Instead, globally initialize the system page size.
* | Improve the support of atomicslhchavez2020-10-085-32/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change: * Starts using GCC's and clang's `__atomic_*` intrinsics instead of the `__sync_*` ones, since the former supercede the latter (and can be safely replaced by their equivalent `__atomic_*` version with the sequentially consistent model). * Makes `git_atomic64`'s value `volatile`. Otherwise, this will make ThreadSanitizer complain. * Adds ways to load the values from atomics. As it turns out, unsynchronized read are okay only in some architectures, but if we want to be correct (and make ThreadSanitizer happy), those loads should also be performed with the atomic builtins. * Fixes two ThreadSanitizer warnings, as a proof-of-concept that this works: - Avoid directly accessing `git_refcount`'s `owner` directly, and instead makes all callers go through the `GIT_REFCOUNT_*()` macros, which also use the atomic utilities. - Makes `pool_system_page_size()` race-free. Part of: #5592
* | Fix error return for invalid extensions.Eric Huss2020-10-071-2/+2
| |
* | Change bare free to allocator free.Dan Tull2020-10-061-1/+1
|/ | | | | The info pointer was allocated with git__malloc, so needs to be free'd with git__free. This bug can lurk pretty easily since if there's no custom allocator this is fine.
* multipack: Introduce a parser for multi-pack-index fileslhchavez2020-10-054-5/+519
| | | | | | | This change is the first in a series to add support for git's multi-pack-index. This should speed up large repositories significantly. Part of: #5399
* Merge pull request #5494 from kevinjswinton/masterEdward Thomson2020-10-041-3/+1
|\ | | | | Fix binary diff showing /dev/null
| * Fix binary diff showing /dev/nullKevin Swinton2020-04-181-3/+1
| | | | | | | | | | | | Fixes issue where a changed binary file's content in the working tree isn't displayed correctly, instead showing an oid of zero, and with its path being reported incorrectly as "/dev/null".
* | p_chmod: Android compatibilitykevinlul2020-10-041-1/+13
| | | | | | | | | | | | Fix #5565 Pre-Android 5 did not implement a virtual filesystem atop FAT partitions for Unix permissions, which causes chmod to fail. However, Unix permissions have no effect on Android anyway as file permissions are not actually managed this way, so treating it as a no-op across all Android is safe.
* | Merge pull request #5576 from lollipopman/double-authEdward Thomson2020-10-041-2/+5
|\ \ | | | | | | httpclient: only free challenges for current_server type
| * | httpclient: only free challenges for current_server typeJesse Hathaway2020-07-101-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this commit we freed both the server and proxy auth challenges in git_http_client_read_response. This works when the proxy needs auth or when the server needs auth, but it does not work when both the proxy and the server need auth as we erroneously remove the server auth challenge before we have added them as server credentials. Instead only remove the challenges for the current_server type. Co-authored-by: Stephen Gelman <ssgelm@gmail.com>
* | | Merge pull request #5581 from libgit2/ethomson/mainbranchEdward Thomson2020-10-045-46/+148
|\ \ \ | | | | | | | | Respect `init.defaultBranch` setting
| * | | refs: remove "master" branch constantethomson/mainbranchEdward Thomson2020-08-031-1/+0
| | | | | | | | | | | | | | | | | | | | We don't use "master" as a hardcoded default in as many places; remove the now unused master branch constant.
| * | | remote: update the default remote branchEdward Thomson2020-08-031-14/+27
| | | | | | | | | | | | | | | | | | | | | | | | When the remote does not tell us its default, we have to guess what the default branch should be. Use our local initial branch configuration to inform the remote branch default when we clone.
| * | | clone: don't assume the default branch nameEdward Thomson2020-08-031-4/+4
| | | | | | | | | | | | | | | | | | | | We derive the branch name, even in our code, we shouldn't assume that the branch will be "master".
| * | | clone: respect init.defaultBranch when emptyEdward Thomson2020-08-031-2/+26
| | | | | | | | | | | | | | | | | | | | | | | | When cloning an empty repository, we need to guess what the branch structure should be; instead of hardcoding `master`, use the `init.defaultBranch` setting it if it provided.
| * | | repo: teach isempty about default branch configEdward Thomson2020-08-031-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | The git_repository_isempty function now respects the init.defaultbranch setting (instead of hardcoding "master") to understand if a repository is empty or not.
| * | | repo: add git_repository_initialbranchEdward Thomson2020-08-032-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | Provide a helper function to get the initial branch for a repository, respecting the `init.defaultBranch` configuration option, if set, and returning the "default default" (currently `master`) otherwise.
| * | | repo: honor the init.defaultBranch settingEdward Thomson2020-08-031-16/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As part of a push towards more inclusive language, git is reconsidering using "master" as the default branch name. As a first step, this setting will be configurable with the `init.defaultBranch` configuration option. Honor this during repository initialization. During initialization, we will create an initial branch: 1. Using the `initial_head` setting, if specified; 2. Using the `HEAD` configured in a template, if it exists; 3. Using the `init.defaultBranch` configuration option, if it is set; or 4. Using `master` in the absence of additional configuration.
* | | | Merge pull request #5620 from dlax/parse-patch-add-delete-no-indexEdward Thomson2020-10-041-0/+1
|\ \ \ \ | | | | | | | | | | patch_parse: handle absence of "index" header for new/deleted cases
| * | | | patch_parse: handle absence of "index" header for new/deleted casesDenis Laxalde2020-08-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This follows up on 11de594f85479e4804b07dc4f7b33cfe9212bea0 which added support for parsing patches without extended headers (the "index <hash>..<hash> <mode>" line); issue #5267. We now allow transition from "file mode" state to "path" state directly if there is no "index", which will happen for patches adding or deleting files as demonstrated in added test case.
* | | | | Merge pull request #5626 from csware/parse_boolEdward Thomson2020-10-041-6/+2
|\ \ \ \ \ | | | | | | | | | | | | boolean config parsing fails in some cases with mapped values
| * | | | | Support empty values for git_config_get_mapped and git_config_lookup_map_valueSven Strickroth2020-09-091-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
| * | | | | Fix parsing boolean config values when using git_config_get_mapped and ↵Sven Strickroth2020-09-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git_config_lookup_map_value Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | | | | | Merge pull request #5629 from csware/config-multiline-parseEdward Thomson2020-10-041-1/+1
|\ \ \ \ \ \ | | | | | | | | | | | | | | Fix config file parsing with multi line values containing quoted parts
| * | | | | | Fix config file parsing with multi line values containing quoted partsSven Strickroth2020-09-181-1/+1
| |/ / / / / | | | | | | | | | | | | | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | | | | | sysdir: fix formatting error message with NULL stringpks-release-build-warningsPatrick Steinhardt2020-09-181-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When trying to the template dir, we pass in a `NULL` pointer for the filename. That's perfectly fine, but if we're failing to find the template directory then we'll creat an error message with the `NULL` pointer passed in. Fix the issue by setting different error messages based on whether the filename is given or not. This even makes sense, as we're not searching for a file in case we have no `name`, but for a directory. So the error would've been misleading anyway.
* | | | | | patch_parse: silence maybe-uninitialized warningPatrick Steinhardt2020-09-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When building libgit2 with the release build type, then GCC complains about mode being potentially uninitialized. While this seems to be a false positive, let's silence this warning by zero-initializing the mode.
* | | | | | refs: fix potential free of uninitialized variablePatrick Steinhardt2020-09-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `signature` variable in `git_reference_rename` isn't initialized and neither does `git_reference__log_signature` always do. So if the latter function fails, we'll call `git_signature_free` on this unininitialized variable. Fix the issue by initializing the pointer with `NULL`.
* | | | | | Merge pull request #5632 from csware/winhttp_typoPatrick Steinhardt2020-09-181-2/+2
|\ \ \ \ \ \ | | | | | | | | | | | | | | Fix typo: Make ifndef macroname the same as the define name
| * | | | | | Fix typo: Make ifndef macroname the same as the define nameSven Strickroth2020-09-101-2/+2
| |/ / / / / | | | | | | | | | | | | | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | | | | | Merge pull request #5619 from ddevault/diffstat-segfaultEdward Thomson2020-09-171-5/+6
|\ \ \ \ \ \ | | | | | | | | | | | | | | diff stats: fix segfaults with new files
| * | | | | | diff stats: fix segfaults with new filesDrew DeVault2020-09-161-5/+6
| | |/ / / / | |/| | | |
* | | | | | WinHTTP: Try to use TLS1.3Sven Strickroth2020-09-141-5/+16
| |/ / / / |/| | | | | | | | | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | | | | Don't fail if a HTTP server announces he supports a protocol upgradeSven Strickroth2020-09-081-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cf. RFC7230 section 6.7, an Upgrade header in a normal response merely informs the client that the server supports upgrading to other protocols, and the client can ask for such an upgrade in a later request. The server requiring an upgrade is via the 426 Upgrade Required response code, not the mere presence of the Upgrade response header. (closes issue #5573) Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | | | | Merge pull request #5621 from kim/null-safe-git_net_url_is_default_portEdward Thomson2020-09-011-1/+6
|\ \ \ \ \ | |/ / / / |/| | | | Return false instead of segfaulting when checking for default port
| * | | | Return false instead of segfaulting when checking for default portKim Altintop2020-08-311-1/+6
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | `default_port_for_scheme` returns NULL if the scheme is not one of the builtin ones. This may cause a segmentation fault if a custom transport URL happens to contain a port number, and this code path is triggered (e.g. by setting git_fetch_options->update_fetchhead to 1).
* | | | 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