summaryrefslogtreecommitdiff
path: root/tests/merge
Commit message (Collapse)AuthorAgeFilesLines
* tests: don't generate false positives on empty path segmentsPeter Pettersson2021-08-081-2/+2
|
* 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: cache negative cache results for similarity metricsPatrick Steinhardt2020-04-011-0/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: update enum type name for consistencyEdward Thomson2020-01-181-1/+1
| | | | | libgit2 does not use `type_t` suffixes as it's redundant; thus, rename `git_merge_diff_type_t` to `git_merge_diff_t` for consistency.
* fileops: rename to "futils.h" to match function signaturesPatrick Steinhardt2019-07-2011-11/+11
| | | | | | | | | Our file utils functions all have a "futils" prefix, e.g. `git_futils_touch`. One would thus naturally guess that their definitions and implementation would live in files "futils.h" and "futils.c", respectively, but in fact they live in "fileops.h". Rename the files to match expectations.
* blob: add underscore to `from` functionsEdward Thomson2019-06-161-1/+1
| | | | | | The majority of functions are named `from_something` (with an underscore) instead of `fromsomething`. Update the blob functions for consistency with the rest of the library.
* tests: merge::analysis: use variants to deduplicate test suitesPatrick Steinhardt2019-06-134-202/+27
| | | | | | | | Since commit 394951ad4 (tests: allow for simple data-driven tests, 2019-06-07), we have the ability to run a given test suite with multiple variants. Use this new feature to deduplicate the test suites for merge::{trees,workdir}::analysis into a single test suite.
* Fix memleaks in analysis tests.Robert Coup2019-06-101-5/+9
| | | | Wrap some missed setup api calls in asserts.
* Review fixes:Robert Coup2019-06-103-118/+129
| | | | | | - whitespace -> tabs - comment style - improve repo naming in merge/trees/analysis tests.
* Refactor testing:Robert Coup2019-06-104-226/+224
| | | | | - move duplication between merge/trees/ and merge/workdir/ into merge/analysis{.c,.h} - remove merge-resolve.git resource, open the existing merge-resolve as a bare repo instead.
* merge: add doc header to analysis testsRobert Coup2019-06-102-0/+6
|
* merge: tests for bare repo merge analysisRobert Coup2019-06-101-0/+170
| | | | dupe of workdir/analysis.c against a bare repo.
* annotated_commit: add failing test for looking up from annotated tagCarlos Martín Nieto2018-12-141-0/+26
|
* object_type: use new enumeration namesethomson/index_fixesEdward Thomson2018-12-013-11/+11
| | | | Use the new object_type enumeration names within the codebase.
* Merge pull request #4770 from tiennou/feature/merge-analysis-any-branchPatrick Steinhardt2018-11-301-20/+49
|\ | | | | Allow merge analysis against any reference
| * merge: make analysis possible against a non-HEAD referenceEtienne Samson2018-10-191-20/+49
| | | | | | | | | | | | | | This moves the current merge analysis code into a more generic version that can work against any reference. Also change the tests to check returned analysis values exactly.
* | Merge branch 'issue-4203'Edward Thomson2018-10-201-0/+29
|\ \ | |/ |/|
| * tests: add test case for index reloads on mergeEtiene Dalcol2017-11-111-0/+29
| | | | | | | | | | Adds a test case for the issue #4203, when diverging indexes on memory and disk cause git merge to abort with GIT_ECONFLICT
* | Merge pull request #4702 from tiennou/fix/coverityPatrick Steinhardt2018-07-201-1/+1
|\ \ | | | | | | Assorted Coverity fixes
| * | tests: add missing cl_git_pass to testsEtienne Samson2018-07-061-1/+1
| | | | | | | | | Reported by Coverity, CID 1393678-1393697.
* | | treewide: remove use of C++ style commentsPatrick Steinhardt2018-07-1312-12/+12
|/ / | | | | | | | | | | | | | | | | C++ style comment ("//") are not specified by the ISO C90 standard and thus do not conform to it. While libgit2 aims to conform to C90, we did not enforce it until now, which is why quite a lot of these non-conforming comments have snuck into our codebase. Do a tree-wide conversion of all C++ style comments to the supported C style comments to allow us enforcing strict C90 compliance in a later commit.
* | Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-109-30/+30
| |
* | Add failing test case for virtual commit merge base issueEdward Thomson2018-02-041-0/+23
| |
* | merge::trees::recursive: test for virtual base buildingEdward Thomson2018-02-041-0/+25
| | | | | | | | | | Virtual base building: ensure that the virtual base is created and revwalked in the same way as git.
* | merge: reverse merge bases for recursive mergeEdward Thomson2018-02-043-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the commits being merged have multiple merge bases, reverse the order when creating the virtual merge base. This is for compatibility with git's merge-recursive algorithm, and ensures that we build identical trees. Git does this to try to use older merge bases first. Per 8918b0c: > It seems to be the only sane way to do it: when a two-head merge is > done, and the merge-base and one of the two branches agree, the > merge assumes that the other branch has something new. > > If we start creating virtual commits from newer merge-bases, and go > back to older merge-bases, and then merge with newer commits again, > chances are that a patch is lost, _because_ the merge-base and the > head agree on it. Unlikely, yes, but it happened to me.
* | Merge pull request #4489 from libgit2/ethomson/conflicts_crlfEdward Thomson2018-02-041-0/+48
|\ \ | | | | | | Conflict markers should match EOL style in conflicting files
| * | merge: test CR/LF conflicts for CR/LF filesethomson/conflicts_crlfEdward Thomson2018-01-211-0/+48
| | | | | | | | | | | | | | | | | | Ensure that when the files being merged have CR/LF line endings that the conflict markers produced in the conflict file also have CR/LF line endings.
* | | merge: recursive uses larger conflict markersEdward Thomson2018-01-213-8/+8
|/ / | | | | | | | | | | | | | | | | | | | | Git uses longer conflict markers in the recursive merge base - two more than the default (thus, 9 character long conflict markers). This allows users to tell the difference between the recursive merge conflicts and conflicts between the ours and theirs branches. This was introduced in git d694a17986a28bbc19e2a6c32404ca24572e400f. Update our tests to expect this as well.
* | Do not attempt to check out submodule as blob when merging a submodule ↵David Turner2017-12-041-0/+36
|/ | | | modify/deltete conflict
* merge_trees: introduce test for submodule renamesEdward Thomson2017-02-091-0/+22
| | | | | Test that shows that submodules are incorrectly considered in renames, and `git_merge_trees` will fail to lookup the submodule as a blob.
* merge: set default rename thresholdEdward Thomson2017-01-011-0/+2
| | | | | When `GIT_MERGE_FIND_RENAMES` is set, provide a default for `rename_threshold` when it is unset.
* git_diff_generated: abstract generated diffsEdward Thomson2016-05-261-0/+1
|
* merge drivers: handle configured but not found driverEdward Thomson2016-03-171-0/+18
|
* merge driver: remove `check` callbackEdward Thomson2016-03-171-124/+7
| | | | | | Since the `apply` callback can defer, the `check` callback is not necessary. Removing the `check` callback further makes the `payload` unnecessary along with the `cleanup` callback.
* merge driver: tests for set and unset merge attributeEdward Thomson2016-03-171-1/+36
| | | | | | | Ensure that setting the merge attribute forces the built-in default `text` driver and does *not* honor the `merge.default` configuration option. Further ensure that unsetting the merge attribute forces a conflict (the `binary` driver).
* merge driver: tests for custom default merge driversEdward Thomson2016-03-171-0/+59
|
* merge driver: test GIT_EMERGECONFLICTEdward Thomson2016-03-171-0/+90
| | | | | When a `check` or `apply` callback function returns `GIT_EMERGECONFLICT` stop and product a conflict.
* merge driver: test GIT_PASSTHROUGHEdward Thomson2016-03-171-0/+95
| | | | | When a `check` or `apply` callback function returns `GIT_PASSTHROUGH`, move on to the default merge driver.
* merge driver: introduce custom merge driversEdward Thomson2016-03-171-0/+208
| | | | | | | | Consumers can now register custom merged drivers with `git_merge_driver_register`. This allows consumers to support the merge drivers, as configured in `.gitattributes`. Consumers will be asked to perform the file-level merge when a custom driver is configured.
* Fix rebase bug and include test for merge=unionStan Hu2016-03-171-0/+36
|
* merge::workdir::dirty: update to use `st_ctime_nsec`Edward Thomson2016-03-071-2/+2
| | | | | Update unit test to use newfangled `st_ctime_nsec`, which provides indirection to the platform-correct name.
* win32: introduce p_timeval that isn't stupidEdward Thomson2016-02-121-1/+1
| | | | | Windows defines `timeval` with `long`, which we cannot sanely cope with. Instead, use a custom timeval struct.
* merge tests: correct castsEdward Thomson2016-02-111-3/+3
|
* recursive merge: add a recursion limitEdward Thomson2015-11-251-0/+31
|
* merge: handle conflicts in recursive base buildingEdward Thomson2015-11-253-1/+145
| | | | | | | | | | | | | | | | | When building a recursive merge base, allow conflicts to occur. Use the file (with conflict markers) as the common ancestor. The user has already seen and dealt with this conflict by virtue of having a criss-cross merge. If they resolved this conflict identically in both branches, then there will be no conflict in the result. This is the best case scenario. If they did not resolve the conflict identically in the two branches, then we will generate a new conflict. If the user is simply using standard conflict output then the results will be fairly sensible. But if the user is using a mergetool or using diff3 output, then the common ancestor will be a conflict file (itself with diff3 output, haha!). This is quite terrible, but it matches git's behavior.
* merge tests: add complex recursive exampleEdward Thomson2015-11-251-0/+28
|
* recursive: test conflict output during recursive mergeEdward Thomson2015-11-252-0/+81
|
* merge tests: move expected data into own fileEdward Thomson2015-11-256-44/+47
|
* merge: add recursive test with conflicting contentsEdward Thomson2015-11-251-0/+23
|
* merge: add recursive test with three merge basesEdward Thomson2015-11-251-0/+46
|