summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* config: test that unreadable files are treated as notfoundethomson/config_unreadableEdward Thomson2020-05-231-0/+17
|
* config: ignore unreadable configuration filesWil Shipley2020-05-231-0/+9
| | | | | | | | | | | | Modified `config_file_open()` so it returns 0 if the config file is not readable, which happens on global config files under macOS sandboxing (note that for some reason `access(F_OK)` DOES work with sandboxing, but it is lying). Without this read check sandboxed applications on macOS can not open any repository, because `config_file_read()` will return GIT_ERROR when it cannot read the global /Users/username/.gitconfig file, and the upper layers will just completely abort on GIT_ERROR when attempting to load the global config file, so no repositories can be opened.
* Merge pull request #5515 from pks-t/pks/flaky-checkout-testEdward Thomson2020-05-232-22/+19
|\ | | | | tests: checkout: fix flaky test due to mtime race
| * checkout::index: free the indexEdward Thomson2020-05-231-0/+2
| |
| * checkout: fix file being treated as unmodified due to racy indexPatrick Steinhardt2020-05-161-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When trying to determine whether a file changed, we try to avoid heavy operations by fist taking a look at the index, seeing whether the index entry is modified already. This doesn't seem to cut it, though, as we currently have the racy checkout::index::can_disable_pathspec_match test case: sometimes the files get restored to their original contents, sometimes they aren't. The issue is caused by a racy index [1]: in case we modify a file, add it to the index and then modify it again in-place without changing its file, then we may end up with a modified file that has the same stat(3P) info as we've currently got it in its corresponding index entry. The mitigation for this is to treat files with the same mtime as the index are treated as racily modified. We already have this logic in place for the index, but not when doing a checkout. Fix the issue by only consulting the index entry in case it has an older mtime as the index. Previously, the following script reliably had at least 20 failures, while now there is no failure to be observed anymore: ```bash j=0 for i in $(seq 100) do if ! ./libgit2_clar -scheckout::index::can_disable_pathspec_match >/dev/null then j=$(($j + 1)) fi done echo "Failures: $j" ``` [1]: https://git-scm.com/docs/racy-git
| * tests: checkout: fix stylistic issues and static variablePatrick Steinhardt2020-05-161-19/+13
| | | | | | | | | | | | | | | | The test case checkout::index::can_disable_pathspec_match has some shortcomings when it comes to coding style, which didn't fit our own coding style. Furthermore, it had an unnecessary static local variable. The test has been refactored to address these issues.
* | Merge pull request #5523 from libgit2/pks/cmake-sort-reproducible-buildsEdward Thomson2020-05-235-25/+36
|\ \ | |/ |/| cmake: Sort source files for reproducible builds
| * cmake: Sort source files for reproducible buildspks/cmake-sort-reproducible-buildsPatrick Steinhardt2020-05-155-25/+36
| | | | | | | | | | | | | | | | | | | | | | We currently use `FILE(GLOB ...)` in most places to find source and header files. This is problematic in that the order of files returned depends on the operating system's directory iteration order and may thus not be deterministic. As a result, we link object files in unspecified order, which may cause the linker to emit different code across runs. Fix this issue by sorting all code used as input to the libgit2 library to improve the reliability of reproducible builds.
* | Merge pull request #5517 from libgit2/pks/futils-symlink-argsEdward Thomson2020-05-122-6/+6
|\ \ | | | | | | futils: fix order of declared parameters for `git_futils_fake_symlink`
| * | futils: fix order of declared parameters for `git_futils_fake_symlink`pks/futils-symlink-argsPatrick Steinhardt2020-05-122-6/+6
| |/ | | | | | | | | | | | | | | | | While the function `git_futils_fake_symlink` is declared with arguments `new, old`, the implementation uses the reverse order `old, new`. Let's fix the ordering issues to be `new, old` for both, which matches what symlink(3P) has. While at it, we also rename these parameters: `old` and `new` doesn't really make a lot of sense in the context of symlinks, which is why this commit renames them to be called `target` and `path`.
* | Merge pull request #5516 from suhaibmujahid/update-releasePatrick Steinhardt2020-05-121-0/+11
|\ \ | | | | | | Check the version in package.json
| * | feat: Check the version in package.jsonSuhaib Mujahid2020-05-121-0/+11
|/ /
* | Merge pull request #5513 from libgit2/pks/tests-fix-32-bit-formatterEdward Thomson2020-05-121-1/+1
|\ \ | |/ |/| tests: merge: fix printf formatter on 32 bit arches
| * tests: merge: fix printf formatter on 32 bit archesPatrick Steinhardt2020-05-121-1/+1
|/ | | | | | | | | We currently use `PRIuMAX` to print an integer of type `size_t` in merge::trees::rename::cache_recomputation. While this works just fine on 64 bit arches, it doesn't on 32 bit ones. As a result, our nightly builds on x86 and arm32 fail. Fix the issue by using `PRIuZ` instead.
* Merge pull request #5511 from suhaibmujahid/patch-1Edward Thomson2020-05-121-1/+1
|\ | | | | Update package.json
| * Update package.jsonSuhaib Mujahid2020-05-111-1/+1
| |
* | Merge pull request #5509 from libgit2/ethomson/assert_macrosEdward Thomson2020-05-114-1/+155
|\ \ | | | | | | Introduce GIT_ASSERT macros
| * | assert: allow non-int returning functions to assertethomson/assert_macrosEdward Thomson2020-05-112-14/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Include GIT_ASSERT_WITH_RETVAL and GIT_ASSERT_ARG_WITH_RETVAL so that functions that do not return int (or more precisely, where `-1` would not be an error code) can assert. This allows functions that return, eg, NULL on an error code to do that by passing the return value (in this example, `NULL`) as a second parameter to the GIT_ASSERT_WITH_RETVAL functions.
| * | assert: optionally fall-back to assert(3)Edward Thomson2020-05-113-27/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fall back to the system assert(3) in debug builds, which may aide in debugging. "Safe" assertions can be enabled in debug builds by setting GIT_ASSERT_HARD=0. Similarly, hard assertions can be enabled in release builds by setting GIT_ASSERT_HARD to nonzero.
| * | Introduce GIT_ASSERT macrosEdward Thomson2020-05-113-1/+68
| |/ | | | | | | | | | | | | | | | | | | | | | | Provide macros to replace usages of `assert`. A true `assert` is punishing as a library. Instead we should do our best to not crash. GIT_ASSERT_ARG(x) will now assert that the given argument complies to some format and sets an error message and returns `-1` if it does not. GIT_ASSERT(x) is for internal usage, and available as an internal consistency check. It will set an error message and return `-1` in the event of failure.
* | Merge pull request #5512 from A-Ovchinnikov-mx/patch-1Edward Thomson2020-05-111-0/+15
|\ \ | |/ |/| README.md: Add instructions for building in MinGW environment
| * Update README.mdA-Ovchinnikov-mx2020-05-111-0/+15
|/ | | Add instructions for building libgit2 in MinGW environment
* Merge pull request #5510 from phkelley/stash-to-index-crashEdward Thomson2020-05-111-2/+2
|\ | | | | Fix uninitialized stack memory and NULL ptr dereference in stash_to_index
| * Fix uninitialized stack memory and NULL ptr dereference in stash_to_indexPhilip Kelley2020-05-101-2/+2
|/ | | | Caught by static analysis.
* checkout: Fix removing untracked files by path in subdirectoriesSegev Finer2020-05-112-2/+33
| | | | | | | | The checkout code didn't iterate into a subdir if it didn't match the pathspec, but since the pathspec might match files in the subdir we should recurse into it (In contrast to gitignore handling). Fixes #5089
* Merge pull request #5378 from libgit2/ethomson/checkout_pathspecsEdward Thomson2020-05-112-9/+79
|\ | | | | Honor GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH for all checkout types
| * checkout: filter pathspecs for _all_ checkout typesethomson/checkout_pathspecsEdward Thomson2020-05-101-9/+20
| | | | | | | | | | | | | | | | | | | | We were previously applying the pathspec filter for the baseline iterator during checkout, as well as the target tree. This was an oversight; in fact, we should apply the pathspec filter to _all_ checkout targets, not just trees. Add a helper function to set the iterator pathspecs from the given checkout pathspecs, and call it everywhere.
| * tests::checkout: only examine test10 and test11.txtEdward Thomson2020-05-101-2/+2
| | | | | | | | | | | | | | The checkout::index::can_disable_pathspec_match test attempts to set a path filter of `test11.txt` and `test12.txt`, but then validates that `test10.txt` and `test11.txt` were left unmodified. Update the test's path filter to match the expectation.
| * Create test case demonstrating checkout bug w/ pathspec match disabledFelix Lapalme2020-05-101-0/+59
|/
* Merge pull request #5482 from pks-t/pks/coding-styleEdward Thomson2020-05-101-0/+364
|\ | | | | docs: add documentation for our coding style
| * docs: add documentation for our coding stylePatrick Steinhardt2020-04-051-0/+364
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For years, we've repeatedly had confusion about what our actual coding style is not only for newcomers, but also across the core contributors. This can mostly be attributed to the fact that we do not have any coding conventions written down. This is now a thing of the past with the introduction of a new document that gives an initial overview of our style and most important best practices for both our C codebase as well as for CMake. While the proposed coding style for our C codebase should be rather uncontroversial, the coding style for CMake might be. This can be attributed to multiple facts. First, the CMake code base doesn't really have any uniform coding style and is quite outdated in a lot of places. Second, the proposed coding style actually breaks with our existing one: we currently use all-uppercase function names and variables, but the documented coding style says we use all-lowercase function names but all-uppercase variables. It's common practice in CMake to write variables in all upper-case, and in fact all variables made available by CMake are exactly that. As variables are case-sensitive in CMake, we cannot and shouldn't break with this. In contrast, function calls are case insensitive, and modern CMake always uses all-lowercase ones. I argue we should do the same to get in line with other codebases and to reduce the likelihood of repetitive strain injuries. So especially for CMake, the proposed coding style says something we don't have yet. I'm fine with that, as the document explicitly says that it's what we want to have and not what we have right now.
* | Merge pull request #5500 from phkelley/enable-control-flow-guardEdward Thomson2020-05-101-0/+10
|\ \ | | | | | | MSVC: Enable Control Flow Guard (CFG)
| * | MSVC: Enable Control Flow Guard (CFG)Philip Kelley2020-04-251-0/+10
| | | | | | | | | | | | | | | | | | This feature requires Visual Studio 2015 (MSVC_VERSION = 1900) or later. As the minimum required CMake version is currently less than 3.7, GREATER_EQUAL is not available to us and we must invert the result of the LESS operator.
* | | Merge pull request #5431 from libgit2/ethomson/hexdumpEdward Thomson2020-05-101-9/+22
|\ \ \ | |/ / |/| | git__hexdump: better mimic `hexdump -C`
| * | git__hexdump: better mimic `hexdump -C`ethomson/hexdumpEdward Thomson2020-04-011-9/+22
| | |
* | | Merge pull request #5383 from ognarb/feature/blame-ignore-whitespacePatrick Steinhardt2020-04-1928-4/+31
|\ \ \ | | | | | | | | Feature: Allow blame to ignore whitespace change
| * | | blame: add option to ignore whitespace changesCarl Schwan2020-04-1428-4/+31
|/ / /
* | | Merge pull request #5487 from niacat/masterEdward Thomson2020-04-141-1/+1
|\ \ \ | | | | | | | | deps: ntlmclient: use htobe64 on NetBSD too
| * | | deps: ntlmclient: use htobe64 on NetBSD toonia2020-04-051-1/+1
|/ / /
* | | Merge pull request #5485 from libgit2/ethomson/sysdir_unusedPatrick Steinhardt2020-04-052-30/+0
|\ \ \ | | | | | | | | sysdir: remove unused git_sysdir_get_str
| * | | sysdir: remove unused git_sysdir_get_strethomson/sysdir_unusedEdward Thomson2020-04-052-30/+0
| | |/ | |/|
* | | Merge pull request #5483 from xSetech/masterPatrick Steinhardt2020-04-051-1/+1
|\ \ \ | |/ / |/| | Fix typo causing removal of symbol 'git_worktree_prune_init_options'
| * | Fix typo causing removal of symbol 'git_worktree_prune_init_options'Seth Junot2020-04-041-1/+1
|/ / | | | | | | | | | | Commit 0b5ba0d replaced this function with an "option_init" equivallent, but misspelled the replacement function. As a result, this symbol has been missing from libgit2.so ever since.
* | Merge pull request #5425 from lhchavez/fix-get-delta-basePatrick Steinhardt2020-04-043-26/+44
|\ \ | | | | | | pack: Improve error handling for get_delta_base()
| * | Re-adding the "delta offset is zero" error caselhchavez2020-04-021-0/+6
| | |
| * | Making get_delta_base() conform to the general error-handling patternlhchavez2020-04-013-25/+29
| | | | | | | | | | | | | | | This makes get_delta_base() return the error code as the return value and the delta base as an out-parameter.
| * | pack: Improve error handling for get_delta_base()lhchavez2020-04-011-7/+15
| |/ | | | | | | | | | | | | | | This change moves the responsibility of setting the error upon failures of get_delta_base() to get_delta_base() instead of its callers. That way, the caller chan always check if the return value is negative and mark the whole operation as an error instead of using garbage values, which can lead to crashes if the .pack files are malformed.
* | Merge pull request #5480 from libgit2/ethomson/coverityPatrick Steinhardt2020-04-041-2/+2
|\ \ | | | | | | repo::open: ensure we can open the repository
| * | repo::open: ensure we can open the repositoryethomson/coverityEdward Thomson2020-04-031-2/+2
| | | | | | | | | | | | Update the test cases to check the `git_repository_open` return code.
* | | Merge pull request #5421 from petersalomonsen/examples-fixes-and-additionsPatrick Steinhardt2020-04-045-1/+147
|\ \ \ | | | | | | | | examples: additions and fixes