summaryrefslogtreecommitdiff
path: root/tests-clar/diff
Commit message (Collapse)AuthorAgeFilesLines
...
* some simple case-sensitive index testsEdward Thomson2013-06-171-0/+32
|
* diff: fix warningyorah2013-06-141-0/+2
|
* Merge pull request #1643 from ethomson/rename_sourceVicent Martí2013-06-121-0/+93
|\ | | | | Keep data about source of similarity
| * failing unit test for similar renamesEdward Thomson2013-06-101-0/+93
| |
* | Add patch from blobs APIRussell Belfer2013-06-121-0/+238
| | | | | | | | | | | | | | | | This adds two new public APIs: git_diff_patch_from_blobs and git_diff_patch_from_blob_and_buffer, plus it refactors the code for git_diff_blobs and git_diff_blob_to_buffer so that they code is almost entirely shared between these APIs, and adds tests for the new APIs.
* | Fix some diff driver memory leaksRussell Belfer2013-06-121-9/+8
| |
* | Add diff drivers tests (and fix bugs)Russell Belfer2013-06-111-0/+126
| | | | | | | | | | This adds real tests for user-configured diff drivers and in the process found a bunch of bugs.
* | Implement regex pattern diff driverRussell Belfer2013-06-112-2/+2
| | | | | | | | | | | | | | This implements the loading of regular expression pattern lists for diff drivers that search for function context in that way. This also changes the way that diff drivers update options and interface with xdiff APIs to make them a little more flexible.
* | Reorganize diff and add basic diff driverRussell Belfer2013-06-103-2/+3
|/ | | | | | | | | | | | | | | | | | This is a significant reorganization of the diff code to break it into a set of more clearly distinct files and to document the new organization. Hopefully this will make the diff code easier to understand and to extend. This adds a new `git_diff_driver` object that looks of diff driver information from the attributes and the config so that things like function content in diff headers can be provided. The full driver spec is not implemented in the commit - this is focused on the reorganization of the code and putting the driver hooks in place. This also removes a few #includes from src/repository.h that were overbroad, but as a result required extra #includes in a variety of places since including src/repository.h no longer results in pulling in the whole world.
* Make iterators use GIT_ITEROVER & smart advanceRussell Belfer2013-05-311-52/+64
| | | | | | | | | | | | | | | 1. internal iterators now return GIT_ITEROVER when you go past the last item in the iteration. 2. git_iterator_advance will "advance" to the first item in the iteration if it is called immediately after creating the iterator, which allows a simpler idiom for basic iteration. 3. if git_iterator_advance encounters an error reading data (e.g. a missing tree or an unreadable file), it returns the error but also attempts to advance past the invalid data to prevent an infinite loop. Updated all tests and internal usage of iterators to account for these new behaviors.
* Fill out diff rename test coverageRussell Belfer2013-05-231-0/+105
| | | | | | | This extends the rename tests to make sure that every rename scenario in the inner loop of git_diff_find_similar is actually exercised. Also, fixes an incorrect assert that was in one of the clauses that was not previously being exercised.
* More diff rename tests; better split swap handlingRussell Belfer2013-05-233-14/+112
| | | | | | | | | | | | | This adds a couple more tests of different rename scenarios. Also, this fixes a problem with the case where you have two "split" deltas and the left half of one matches the right half of the other. That case was already being handled, but in the wrong order in a way that could result in bad output. Also, if the swap also happened to put the other two halves into the correct place (i.e. two files exchanged places with each other), then the second delta was left with the SPLIT flag set when it really should be cleared.
* Significant rename detection rewriteRussell Belfer2013-05-221-6/+28
| | | | | | | | | | | | | | | | | | | | This flips rename detection around so instead of creating a forward mapping from deltas to possible rename targets, instead it creates a reverse mapping, looking at possible targets and trying to find a source that they could have been renamed or copied from. This is important because each output can only have a single source, but a given source could map to multiple outputs (in the form of COPIED records). Additionally, this makes a couple of tweaks to the public rename detection APIs, mostly renaming a couple of options that control the behavior to make more sense and to be more like core Git. I walked through the tests looking at the exact results and updated the expectations based on what I saw. The new code is different from the old because it cannot give some nonsense results (like A was renamed to both B and C) which were part of the outputs previously.
* Add more diff rename detection testsRussell Belfer2013-05-201-2/+146
| | | | | | | | | | This adds a bunch more rename detection tests including checks vs the working directory, the new exact match options, some more whitespace variants, etc. This also adds a git_futils_writebuffer helper function and uses it in checkout. This is mainly added because I wanted an easy way to write out a git_buf to disk inside my test code.
* Fix issues with git_diff_find_similarRussell Belfer2013-05-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a number of bugs in the rename code that only were obvious when I started testing it against large old repos with more complex patterns. (The code to do that testing is not ready to merge with libgit2, but I do plan to add more thorough tests.) This contains a significant number of changes and also tweaks the public API slightly to make emulating core git easier. Most notably, this separates the GIT_DIFF_FIND_AND_BREAK_REWRITES flag into FIND_REWRITES (which adds a self-similarity score to every modified file) and BREAK_REWRITES (which splits the modified deltas into add/remove pairs in the diff list). When you do a raw output of core git, rewrites show up as M090 or such, not at A and D output, so I wanted to be able to emulate that. Publicly, this also changes the flags to be uint16_t since we don't need values out of that range. Internally, this contains significant changes from a number of small bug fixes (like using the wrong side of the diff to decide if the object could be found in the ODB vs the workdir) to larger issues about which files can and should be compared and how the various edge cases of similarity scores should be treated. Honestly, I don't think this is the last update that will have to be made to this code, but I think this moves us closer to correct behavior and I tried to document the code so it would be easier to follow..
* Fix diff crash when last item is untracked dirRussell Belfer2013-05-151-0/+25
| | | | | | | When the last item in a diff was an untracked directory that only contained ignored items, the loop to scan the contents would run off the end of the iterator and dereference a NULL pointer. This includes a test that reproduces the problem and a fix.
* Fix some memory leaksnulltoken2013-05-141-0/+2
|
* Fix diff output for renames and copiesRussell Belfer2013-05-101-1/+54
| | | | | | | | | | If you use rename detection, the renamed and copied files would not show any text diffs because the function that decides if data should be loaded didn't know which sides of the diff to load for those cases. This adds a test that looks at the patch generated for diff entries that are COPIED or RENAMED.
* Fix line numbering for patches with eofnlRussell Belfer2013-05-071-6/+122
| | | | | | | When a patch contained an eofnl change (i.e. the last line either gained or lost a newline), the oldno and newno line number values for the lines in the last hunk of the patch were not useful. This makes them behave in a more expected manner.
* More tests for files with no newline at endRussell Belfer2013-05-071-5/+30
|
* Add GIT_DIFF_LINE_CONTEXT_EOFNLRussell Belfer2013-05-072-15/+33
| | | | | | | | | | | | | | | | | | This adds a new line origin constant for the special line that is used when both files end without a newline. In the course of writing the tests for this, I was having problems with modifying a file but not having diff notice because it was the same size and modified less than one second from the start of the test, so I decided to start working on nanosecond timestamp support. This commit doesn't contain the nanosecond support, but it contains the reorganization of maybe_modified and the hooks so that if the nanosecond data were being read by stat() (or rather being copied by git_index_entry__init_from_stat), then the nsec would be taken into account. This new stuff could probably use some more tests, although there is some amount of it here.
* More tests for diff untracked directoriesRussell Belfer2013-04-303-1/+203
| | | | | | This includes more tests for various scenarios when diff includes an untracked directory in the workdir with contents either ignored or not.
* Improve diff config options handlingRussell Belfer2013-04-232-0/+152
| | | | | | | | | | | | | | This makes diff use the cvar cache for config options where possible, and also adds support for a number of other config options to diff including "diff.context", "diff.ignoreSubmodules", "diff.noprefix", "diff.mnemonicprefix", and "core.abbrev". To make this natural, this involved a rearrangement of the code that allocates the diff object vs. the code that initializes it based on the combination of options passed in by the user and read from the config. This commit includes tests for most of these new options as well.
* What has science done.Vicent Marti2013-04-221-1/+2
|
* Move some low-level repo fns to include/git2/sysRussell Belfer2013-04-211-0/+2
|
* Notify '*' pathspec correctly when diffingyorah2013-04-112-163/+228
| | | | I also moved all tests related to notifying in their own file.
* Tests and more fixes for submodule diffsRussell Belfer2013-04-091-0/+168
| | | | | | | | | | | | | This adds tests for diffs with submodules in them and (perhaps unsurprisingly) requires further fixes to be made. Specifically, this fixes: - when considering if a submodule is dirty in the workdir, it was being treated as dirty even if only the index was dirty. - git_diff_patch_to_str (and git_diff_patch_print) were "printing" the headers for files (and submodules) that were unmodified or had no meaningful content. - added comment to previous fix and removed unneeded parens.
* Fix some diff ignores and submodule dirty workdirRussell Belfer2013-03-253-5/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This started out trying to look at the problems from issue #1425 and gradually grew to a broader set of fixes. There are two core things fixed here: 1. When you had an ignore like "/bin" which is rooted at the top of your tree, instead of immediately adding the "bin/" entry as an ignored item in the diff, we were returning all of the direct descendants of the directory as ignored items. This changes things to immediately ignore the directory. Note that this effects the behavior in test_status_ignore__subdirectories so that we no longer exactly match core gits ignore behavior, but the new behavior probably makes more sense (i.e. we now will include an ignored directory inside an untracked directory that we previously would have left off). 2. When a submodule only contained working directory changes, the diff code was always considering it unmodified which was just an outright bug. The HEAD SHA of the submodule matches the SHA in the parent repo index, and since the SHAs matches, the diff code was overwriting the actual status with UNMODIFIED. These fixes broke existing tests test_diff_workdir__submodules and test_status_ignore__subdirectories but looking it over, I actually think the new results are correct and the old results were wrong. @nulltoken had actually commented on the subdirectory ignore issue previously. I also included in the tests some debugging versions of the shared iteration callback routines that print status or diff information. These aren't used actively in the tests, but can be quickly swapped in to test code to give a better picture of what is being scanned in some of the complex test scenarios.
* Test fixes and cleanupRussell Belfer2013-03-252-121/+36
| | | | | | | | This fixes some places where the new tests were leaving the test area in a bad state or were freeing data they should not free. It also removes code that is extraneous to the core issue and fixes an invalid SHA being looked up in one of the tests (which was failing, but for the wrong reason).
* Added some tests for issue #1397Sven Strickroth2013-03-252-0/+204
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Add cl_repo_set_bool and cleanup testsRussell Belfer2013-03-221-8/+2
| | | | | | This adds a helper function for the cases where you want to quickly set a single boolean config value for a repository. This allowed me to remove a lot of code.
* Three submodule status bug fixesRussell Belfer2013-03-182-10/+16
| | | | | | | | | | | | | | | | 1. Fix sort order problem with submodules where "mod" was sorting after "mod-plus" because they were being sorted as "mod/" and "mod-plus/". This involved pushing the "contains a .git entry" test significantly lower in the stack. 2. Reinstate behavior that a directory which contains a .git entry will be treated as a submodule during iteration even if it is not yet added to the .gitmodules. 3. Now that any directory containing .git is reported as submodule, we have to be more careful checking for GIT_EEXISTS when we do a submodule lookup, because that is the error code that is returned by git_submodule_lookup when you try to look up a directory containing .git that has no record in gitmodules or the index.
* Merge pull request #1408 from arrbee/refactor-iteratorsVicent Martí2013-03-121-40/+38
|\ | | | | Refactor iterators
| * Add INCLUDE_TREES, DONT_AUTOEXPAND iterator flagsRussell Belfer2013-03-061-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This standardizes iterator behavior across all three iterators (index, tree, and working directory). Previously the working directory iterator behaved differently from the other two. Each iterator can now operate in one of three modes: 1. *No tree results, auto expand trees* means that only non- tree items will be returned and when a tree/directory is encountered, we will automatically descend into it. 2. *Tree results, auto expand trees* means that results will be given for every item found, including trees, but you only need to call normal git_iterator_advance to yield every item (i.e. trees returned with pre-order iteration). 3. *Tree results, no auto expand* means that calling the normal git_iterator_advance when looking at a tree will not descend into the tree, but will skip over it to the next entry in the parent. Previously, behavior 1 was the only option for index and tree iterators, and behavior 3 was the only option for workdir. The main public API implications of this are that the `git_iterator_advance_into()` call is now valid for all iterators, not just working directory iterators, and all the existing uses of working directory iterators explicitly use the GIT_ITERATOR_DONT_AUTOEXPAND (for now). Interestingly, the majority of the implementation was in the index iterator, since there are no tree entries there and now have to fake them. The tree and working directory iterators only required small modifications.
| * Make iterator APIs consistent with standardsRussell Belfer2013-03-061-37/+37
| | | | | | | | | | | | | | | | | | | | | | | | The iterator APIs are not currently consistent with the parameter ordering of the rest of the codebase. This rearranges the order of parameters, simplifies the naming of a number of functions, and makes somewhat better use of macros internally to clean up the iterator code. This also expands the test coverage of iterator functionality, making sure that case sensitive range-limited iteration works correctly.
* | handle small files in similarity metricsEdward Thomson2013-03-111-0/+33
| |
* | diff: allow asking for diffs with no contextCarlos Martín Nieto2013-03-091-0/+2
|/ | | | | | | | | Previously, 0 meant default. This is problematic, as asking for 0 context lines is a valid thing to do. Change GIT_DIFF_OPTIONS_INIT to default to three and stop treating 0 as a magic value. In case no options are provided, make sure the options in the diff object default to 3.
* Fix a few leaksCarlos Martín Nieto2013-03-042-0/+3
| | | | | | | | | `git_diff_get_patch()` would unconditionally load the patch object and then simply leak it if the user hadn't requested it. Short-circuit loading the object if the user doesn't want it. The rest of the plugs are simply calling the free functions of objects allocated during the tests.
* Allow empty config object and use itRussell Belfer2013-03-011-6/+4
| | | | | | | This removes assertions that prevent us from having an empty git_config object and then updates some tests that were dependent on global config state to use an empty config before running anything.
* Control for core.autocrlf during testingRussell Belfer2013-03-011-2/+13
|
* Merge pull request #1233 from arrbee/file-similarity-metricVicent Martí2013-02-275-19/+244
|\ | | | | Add file similarity scoring to diff rename/copy detection
| * More rename detection testsRussell Belfer2013-02-221-15/+99
| | | | | | | | | | | | This includes tests for crlf changes, whitespace changes with the default comparison and with the ignore whitespace comparison, and more sensitivity checking for the comparison code.
| * Fix tests for find_similar and relatedRussell Belfer2013-02-222-14/+41
| | | | | | | | | | | | | | | | This fixes both a test that I broke in diff::patch where I was relying on the current state of the working directory for the renames test data and fixes an unstable test in diff::rename where the environment setting for the "diff.renames" config was being allowed to influence the test results.
| * Add diff rename tests with partial similarityRussell Belfer2013-02-211-2/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds some new tests that actually exercise the similarity metric between files to detect renames, copies, and split modified files that are too heavily modified. There is still more testing to do - these tests are just partially covering the cases. There is also one bug fix in this where a change set with only MODIFY being broken into ADD/DELETE (due to low self-similarity) without any additional RENAMED entries would end up not processing the split requests (because the num_rewrites counter got reset).
| * Initial integration of similarity metric to diffRussell Belfer2013-02-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the initial integration of the similarity metric into the `git_diff_find_similar()` code path. The existing tests all pass, but the new functionality isn't currently well tested. The integration does go through the pluggable metric interface, so it should be possible to drop in an alternative to the internal metric that libgit2 implements. This comes along with a behavior change for an existing interface; namely, passing two NULLs to git_diff_blobs (or passing NULLs to git_diff_blob_to_buffer) will now call the file_cb parameter zero times instead of one time. I know it's strange that that change is paired with this other change, but it emerged from some initialization changes that I ended up making.
| * Replace diff delta binary with flagsRussell Belfer2013-02-202-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the git_diff_delta recorded if the delta was binary. This replaces that (with no net change in structure size) with a full set of flags. The flag values that were already in use for individual git_diff_file objects are reused for the delta flags, too (along with renaming those flags to make it clear that they are used more generally). This (a) makes things somewhat more consistent (because I was using a -1 value in the "boolean" binary field to indicate unset, whereas now I can just use the flags that are easier to understand), and (b) will make it easier for me to add some additional flags to the delta object in the future, such as marking the results of a copy/rename detection or other deltas that might want a special indicator. While making this change, I officially moved some of the flags that were internal only into the private diff header. This also allowed me to remove a gross hack in rename/copy detect code where I was overwriting the status field with an internal value.
* | Rename 'exp' so it doesn't conflict with exp()Philip Kelley2013-02-221-59/+59
|/
* Merge pull request #1318 from nulltoken/topic/diff-tree-coverageVicent Martí2013-02-141-44/+126
|\ | | | | Topic/diff tree coverage
| * diff: Enhance tree-to-tree diff test coveragenulltoken2013-02-061-0/+109
| | | | | | | | These tests are related to issue libgit2/libgit2sharp#196
| * diff: refactor git_diff_tree_to_tree() testsnulltoken2013-02-061-45/+18
| |