summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* 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 #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
| * | | examples: additions and fixesPeter Salomonsen2020-04-025-1/+147
| | | | | | | | | | | | | | | | | | | | | | | | add example for git commit fix example for git add add example for git push
* | | | Merge pull request #5477 from pks-t/pks/rename-detection-negative-cachesPatrick Steinhardt2020-04-042-7/+97
|\ \ \ \ | |_|/ / |/| | | merge: cache negative cache results for similarity metrics
| * | | merge: cache negative cache results for similarity metricsPatrick Steinhardt2020-04-012-7/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When computing renames, we cache the hash signatures for each of the potentially conflicting entries so that we do not need to repeatedly read the file and can at least halfway efficiently determine whether two files are similar enough to be deemed a rename. In order to make the hash signatures meaningful, we require at least four lines of data to be present, resulting in at least four different hashes that can be compared. Files that are deemed too small are not cached at all and will thus be repeatedly re-hashed, which is usually not a huge issue. The issue with above heuristic is in case a file does _not_ have at least four lines, where a line is anything separated by a consecutive run of "\n" or "\0" characters. For example "a\nb" is two lines, but "a\0\0b" is also just two lines. Taken to the extreme, a file that has megabytes of consecutive space- or NUL-only may also be deemed as too small and thus not get cached. As a result, we will repeatedly load its blob, calculate its hash signature just to finally throw it away as we notice it's not of any value. When you've got a comparitively big file that you compare against a big set of potentially renamed files, then the cost simply expodes. The issue can be trivially fixed by introducing negative cache entries. Whenever we determine that a given blob does not have a meaningful representation via a hash signature, we store this negative cache marker and will from then on not hash it again, but also ignore it as a potential rename target. This should help the "normal" case already where you have a lot of small files as rename candidates, but in the above scenario it's savings are extraordinarily high. To verify we do not hit the issue anymore with described solution, this commit adds a test that uses the exact same setup described above with one 50 megabyte blob of '\0' characters and 1000 other files that get renamed. Without the negative cache: $ time ./libgit2_clar -smerge::trees::renames::cache_recomputation >/dev/null real 11m48.377s user 11m11.576s sys 0m35.187s And with the negative cache: $ time ./libgit2_clar -smerge::trees::renames::cache_recomputation >/dev/null real 0m1.972s user 0m1.851s sys 0m0.118s So this represents a ~350-fold performance improvement, but it obviously depends on how many files you have and how big the blob is. The test number were chosen in a way that one will immediately notice as soon as the bug resurfaces.
* | | | Merge pull request #5388 from bk2204/repo-format-v1Patrick Steinhardt2020-04-022-9/+84
|\ \ \ \ | | | | | | | | | | Handle repository format v1
| * | | | repository: handle format v1brian m. carlson2020-02-112-9/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Git has supported repository format version 1 for some time. This format is just like version 0, but it supports extensions. Implementations must reject extensions that they don't support. Add support for this format version and reject any extensions but extensions.noop, which is the only extension we currently support. While we're at it, also clean up an error message.
* | | | | Merge pull request #5440 from pks-t/pks/cmake-streamliningPatrick Steinhardt2020-04-024-91/+66
|\ \ \ \ \ | | | | | | | | | | | | CMake: backend selection streamlining
| * | | | | cmake: streamline backend detectionPatrick Steinhardt2020-04-014-91/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We're currently doing unnecessary work to auto-detect backends even if the functionality is disabled altogether. Let's fix this by removing the extraneous FOO_BACKEND variables, instead letting auto-detection modify the variable itself.
* | | | | | Merge pull request #5461 from pks-t/pks/refdb-fs-unused-headerEdward Thomson2020-04-012-21/+0
|\ \ \ \ \ \ | |_|_|_|_|/ |/| | | | | refdb_fs: remove unused header file
| * | | | | refdb_fs: remove unused header filePatrick Steinhardt2020-03-252-21/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "refdb_fs.h" header contains a single struct `git_refcache` that is not used anywhere. As a result, we can just delete the header altogether as it doesn't have any purpose and may confuse readers.
* | | | | | Merge pull request #5466 from pks-t/pks/patch-modechange-with-renameEdward Thomson2020-04-014-7/+22
|\ \ \ \ \ \ | | | | | | | | | | | | | | patch: correctly handle mode changes for renames
| * | | | | | patch: correctly handle mode changes for renamesPatrick Steinhardt2020-03-264-7/+22
| | |_|_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When generating a patch for a renamed file whose mode bits have changed in addition to the rename, then we currently fail to parse the generated patch. Furthermore, when generating a diff we output mode bits after the similarity metric, which is different to how upstream git handles it. Fix both issues by adding another state transition that allows similarity indices after mode changes and by printing mode changes before the similarity index.
* | | | | | Merge pull request #5474 from pks-t/pks/gitignore-cleanupEdward Thomson2020-04-011-30/+0
|\ \ \ \ \ \ | | | | | | | | | | | | | | gitignore: clean up patterns from old times
| * | | | | | gitignore: clean up patterns from old timesPatrick Steinhardt2020-03-301-30/+0
| | |/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | The gitignore file currently has a lot of patterns for files that we shouldn't write anymore since we have migrated to CMake, as everybody is expected to do out-of-source builds anyway. Let's remove them.
* | | | | | Merge pull request #5478 from pks-t/pks/readme-ci-updateEdward Thomson2020-04-011-1/+1
|\ \ \ \ \ \ | |_|_|/ / / |/| | | | | README.md: update build matrix to reflect our latest releases
| * | | | | README.md: update build matrix to reflect our latest releasesPatrick Steinhardt2020-04-011-1/+1
|/ / / / /
* | | | | Merge pull request #5471 from pks-t/pks/v1.0v1.0.0Patrick Steinhardt2020-04-012-4/+55
|\ \ \ \ \ | |_|/ / / |/| | | | Release v1.0
| * | | | version.h: bump version to v1.0.0Patrick Steinhardt2020-03-281-4/+4
| | | | |
| * | | | docs: update changelog for v1.0Patrick Steinhardt2020-03-281-0/+51
|/ / / /
* | | | Merge pull request #5464 from pks-t/pks/refdb-backend-docsPatrick Steinhardt2020-03-261-2/+109
|\ \ \ \ | | | | | | | | | | refdb_backend: improve callback documentation