summaryrefslogtreecommitdiff
path: root/tests-clar/diff/diff_helpers.c
Commit message (Collapse)AuthorAgeFilesLines
* Initial implementation of diff rename detectionRussell Belfer2012-10-231-12/+5
| | | | | | | | | | | | | | | | This implements the basis for diff rename and copy detection, although it is based on simple SHA comparison right now instead of using a matching algortihm. Just as `git_diff_merge` can be used as a post-pass on diffs to emulate certain command line behaviors, there is a new API `git_diff_detect` which will update a diff list in-place, adjusting some deltas to RENAMED or COPIED state (and also, eventually, splitting MODIFIED deltas where the change is too large into DELETED/ADDED pairs). This also adds a new test repo that will hold rename/copy/split scenarios. Right now, it just has exact-match rename and copy, but the tests are written to use tree diffs, so we should be able to add new test scenarios easily without breaking tests.
* Extend diff helpers for tests a littleRussell Belfer2012-10-081-2/+27
|
* Add const to all shared pointers in diff APIRussell Belfer2012-09-251-7/+7
| | | | | | | | | | There are a lot of places where the diff API gives the user access to internal data structures and many of these were being exposed through non-const pointers. This replaces them all with const pointers for any object that the user can access but is still owned internally to the git_diff_list or git_diff_patch objects. This will probably break some bindings... Sorry!
* Fix bugs in new diff patch codeRussell Belfer2012-09-251-1/+7
| | | | | | | | | This fixes all the bugs in the new diff patch code. The only really interesting one is that when we merge two diffs, we now have to actually exclude diff delta records that are not supposed to be tracked, as opposed to before where they could be included because they would be skipped silently by `git_diff_foreach()`. Other than that, there are just minor errors.
* Initial implementation of new diff patch APIRussell Belfer2012-09-251-37/+38
| | | | | | | | Replacing the `git_iterator` object, this creates a simple API for accessing the "patch" for any file pair in a diff list and then gives indexed access to the hunks in the patch and the lines in the hunk. This is the initial implementation of this revised API - it is still broken, but at least builds cleanly.
* Fix diff binary file detectionRussell Belfer2012-09-111-1/+2
| | | | | | | | | | | In the process of adding tests for the max file size threshold (which treats files over a certain size as binary) there seem to be a number of problems in the new code with detecting binaries. This should fix those up, as well as add a test for the file size threshold stuff. Also, this un-deprecates `GIT_DIFF_LINE_ADD_EOFNL`, since I finally found a legitimate situation where it would be returned.
* Replace git_diff_iterator_num_files with progressRussell Belfer2012-09-101-5/+3
| | | | | | | | | The `git_diff_iterator_num_files` API was problematic, since we don't actually know the exact number of files to be iterated over until we load those files into memory. This replaces it with a new `git_diff_iterator_progress` API that goes from 0 to 1, and moves and renamed the old API for the internal places that can tolerate a max value instead of an exact value.
* Diff iteratorsRussell Belfer2012-09-051-0/+71
| | | | | | | | | | | This refactors the diff output code so that an iterator object can be used to traverse and generate the diffs, instead of just the `foreach()` style with callbacks. The code has been rearranged so that the two styles can still share most functions. This also replaces `GIT_REVWALKOVER` with `GIT_ITEROVER` and uses that as a common error code for marking the end of iteration when using a iterator style of object.
* Minor bug fixes in diff codeRussell Belfer2012-08-221-1/+2
| | | | | | | In looking at PR #878, I found a few small bugs in the diff code, mostly related to work that can be avoided when processing tree- to-tree diffs that was always being carried out. This commit has some small fixes in it.
* portability: Improve x86/amd64 compatibilitynulltoken2012-07-241-1/+1
|
* Minor fixes, cleanups, and clarificationsRussell Belfer2012-06-081-1/+6
| | | | | | | | | | | | | | | | | | | | | | | There are three actual changes in this commit: 1. When the trailing newline of a file is removed in a diff, the change will now be reported with `GIT_DIFF_LINE_DEL_EOFNL` passed to the callback. Previously, the `ADD_EOFNL` constant was given which was just an error in my understanding of when the various circumstances arose. `GIT_DIFF_LINE_ADD_EOFNL` is deprecated and should never be generated. A new newline is simply an `ADD`. 2. Rewrote the `diff_delta__merge_like_cgit` function that contains the core logic of the `git_diff_merge` implementation. The new version doesn't actually have significantly different behavior, but the logic should be much more obvious, I think. 3. Fixed a bug in `git_diff_merge` where it freed a string pool while some of the string data was still in use. This led to `git_diff_print_patch` accessing memory that had been freed. The rest of this commit contains improved documentation in `diff.h` to make the behavior and the equivalencies with core git clearer, and a bunch of new tests to cover the various cases, oh and a minor simplification of `examples/diff.c`.
* diff: fix the diffing of two identical blobsnulltoken2012-05-071-0/+1
|
* diff: make git_diff_blobs() able to detect binary blobsnulltoken2012-05-071-0/+2
|
* Leverage GIT_UNUSED macro to explicitly mark a function parameter as ↵nulltoken2012-04-301-8/+14
| | | | purposely unused
* diff: provide more context to the consumer of the callbacksnulltoken2012-04-301-0/+2
| | | | Update the callback to provide some information related to the file change being processed and the range of the hunk, when applicable.
* Fix warnings on 64-bit windows buildsRussell Belfer2012-04-171-1/+1
| | | | | This fixes all the warnings on win64 except those in deps, which come from the regex code.
* diff: Fix rebase breackageVicent Martí2012-03-061-2/+2
|
* Revert GIT_STATUS constants to avoid issuesRussell Belfer2012-03-021-5/+5
| | | | | | | | | This reverts the changes to the GIT_STATUS constants and adds a new enumeration to describe the type of change in a git_diff_delta. I don't love this solution, but it should prevent strange errors from occurring for now. Eventually, I would like to unify the various status constants, but it needs a larger plan and I just wanted to eliminate this breakage quickly.
* Update diff to use iteratorsRussell Belfer2012-03-021-6/+8
| | | | | | | | | | | | | This is a major reorganization of the diff code. This changes the diff functions to use the iterators for traversing the content. This allowed a lot of code to be simplified. Also, this moved the functions relating to outputting a diff into a new file (diff_output.c). This includes a number of other changes - adding utility functions, extending iterators, etc. plus more tests for the diff code. This also takes the example diff.c program much further in terms of emulating git-diff command line options.
* Fixing unit tests post rebaseRussell Belfer2012-03-021-20/+0
| | | | | Some changes that merged cleanly actually broke the unit tests, so this fixes them.
* Add tests and fix bugs for diff whitespace optionsRussell Belfer2012-03-021-0/+2
| | | | | | Once I added tests for the whitespace handling options of diff, I realized that there were some bugs. This fixes those and adds the new tests into the test suite.
* Continue implementation of git-diffRussell Belfer2012-03-021-0/+20
| | | | | | | | * Implemented git_diff_index_to_tree * Reworked git_diff_options structure to handle more options * Made most of the options in git_diff_options actually work * Reorganized code a bit to remove some redundancy * Added option parsing to examples/diff.c to test most options
* Clean up diff implementation for reviewRussell Belfer2012-03-021-0/+62
| | | | | | | This fixes several bugs, updates tests and docs, eliminates the FILE* assumption in favor of printing callbacks for the diff patch formatter helpers, and adds a "diff" example function that can perform a diff from the command line.
* Uniform iterators for trees, index, and workdirRussell Belfer2012-02-211-0/+22
This create a new git_iterator type of object that provides a uniform interface for iterating over the index, an arbitrary tree, or the working directory of a repository. As part of this, git ignore support was extended to support push and pop of directory-based ignore files as the working directory is being traversed (so the array of ignores does not have to be recreated at each directory during traveral). There are a number of other small utility functions in buffer, path, vector, and fileops that are included in this patch that made the iterator implementation cleaner.