summaryrefslogtreecommitdiff
path: root/tests-clar/diff
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #1014 from arrbee/diff-rename-detectionVicent Martí2012-11-027-157/+246
|\ | | | | Initial implementation of diff rename detection
| * Move rename detection into new fileRussell Belfer2012-10-301-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This improves the naming for the rename related functionality moving it to be called `git_diff_find_similar()` and renaming all the associated constants, etc. to make more sense. I also moved the new code (plus the existing `git_diff_merge`) into a new file `diff_tform.c` where I can put new functions related to manipulating git diff lists. This also updates the implementation significantly from the last revision fixing some ordering issues (where break-rewrite needs to be handled prior to copy and rename detection) and improving config option handling.
| * Initial implementation of diff rename detectionRussell Belfer2012-10-237-157/+246
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Add git_diff_patch_to_str APIRussell Belfer2012-10-242-0/+129
|/ | | | | This adds an API to generate a complete single-file patch text from a git_diff_patch object.
* diff: workdir diffing in a bare repo returns EBAREREPOnulltoken2012-10-181-0/+17
|
* Merge pull request #968 from arrbee/diff-support-typechangeRussell Belfer2012-10-171-0/+98
|\ | | | | Support TYPECHANGE records in status and adjust checkout accordingly
| * Add complex checkout test and then fix checkoutRussell Belfer2012-10-091-0/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This started as a complex new test for checkout going through the "typechanges" test repository, but that revealed numerous issues with checkout, including: * complete failure with submodules * failure to create blobs with exec bits * problems when replacing a tree with a blob because the tree "example/" sorts after the blob "example" so the delete was being processed after the single file blob was created This fixes most of those problems and includes a number of other minor changes that made it easier to do that, including improving the TYPECHANGE support in diff/status, etc.
* | Fix single-file ignore checksRussell Belfer2012-10-151-3/+3
|/ | | | | | | | To answer if a single given file should be ignored, the path to that file has to be processed progressively checking that there are no intermediate ignored directories in getting to the file in question. This enables that, fixing the broken old behavior, and adds tests to exercise various ignore situations.
* Add test for diffs with submodules and bug fixesRussell Belfer2012-10-081-0/+74
| | | | | | | | The adds a test for the submodule diff capabilities and then fixes a few bugs with how the output is generated. It improves the accuracy of OIDs in the diff delta object and makes the submodule output more closely mirror the OIDs that will be used by core git.
* Extend diff helpers for tests a littleRussell Belfer2012-10-083-11/+40
|
* Clean up Win64 warningsRussell Belfer2012-09-282-7/+7
|
* Add const to all shared pointers in diff APIRussell Belfer2012-09-257-27/+27
| | | | | | | | | | 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-252-6/+14
| | | | | | | | | 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-254-195/+299
| | | | | | | | 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 problems in diff iterator record chainingRussell Belfer2012-09-132-0/+173
| | | | | | | There is a bug in building the linked list of line records in the diff iterator and also an off by one element error in the hunk counts. This fixes both of these, adds some test data with more complex sets of hunk and line diffs to exercise this code better.
* Fix diff binary file detectionRussell Belfer2012-09-112-1/+87
| | | | | | | | | | | 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-057-293/+613
| | | | | | | | | | | 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.
* Merge remote-tracking branch 'arrbee/tree-walk-fixes' into developmentVicent Marti2012-08-061-0/+50
|\ | | | | | | | | | | | | | | | | Conflicts: src/notes.c src/transports/git.c src/transports/http.c src/transports/local.c tests-clar/odb/foreach.c
| * Update iterators for consistency across libraryRussell Belfer2012-08-031-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This updates all the `foreach()` type functions across the library that take callbacks from the user to have a consistent behavior. The rules are: * A callback terminates the loop by returning any non-zero value * Once the callback returns non-zero, it will not be called again (i.e. the loop stops all iteration regardless of state) * If the callback returns non-zero, the parent fn returns GIT_EUSER * Although the parent returns GIT_EUSER, no error will be set in the library and `giterr_last()` will return NULL if called. This commit makes those changes across the library and adds tests for most of the iteration APIs to make sure that they follow the above rules.
* | portability: Improve x86/amd64 compatibilitynulltoken2012-07-241-1/+1
|/
* Fix bug with merging diffs with null optionsRussell Belfer2012-07-191-0/+48
| | | | | | | A diff that is created with a NULL options parameter could result in a NULL prefix string, but diff merge was unconditionally strdup'ing it. I added a test to replicate the issue and then a new method that does the right thing with NULL values.
* diff: make inter-hunk-context default value git-compliantyorah2012-07-022-7/+67
| | | | Default in git core is 0, not 3
* Plug a few leaksCarlos Martín Nieto2012-06-201-0/+2
|
* Minor fixes, cleanups, and clarificationsRussell Belfer2012-06-083-30/+174
| | | | | | | | | | | | | | | | | | | | | | | 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`.
* Fix filemode comparison in diffsRussell Belfer2012-06-081-3/+106
| | | | | | | | | | | | | | | File modes were both not being ignored properly on platforms where they should be ignored, nor be diffed consistently on platforms where they are supported. This change adds a number of diff and status filemode change tests. This also makes sure that filemode-only changes are included in the diff output when they occur and that filemode changes are ignored successfully when core.filemode is false. There is no code that automatically toggles core.filemode based on the capabilities of the current platform, so the user still needs to be careful in their .git/config file.
* Fix git_status_file for files that start with a character > 0x7f8bit-filename-statusAdam Roben2012-06-072-13/+15
| | | | | | | | | | | | | | | | git_status_file would always return GIT_ENOTFOUND for these files. The underlying bug was that git__strcmp_cb, which is used by git_path_with_stat_cmp to sort entries in the working directory, compares strings based on unsigned chars (this is confirmed by the strcmp(3) manpage), while git__prefixcmp, which is used by workdir_iterator__entry_cmp to search for a path in the working directory, compares strings based on char. So the sort puts this path at the end of the list, while the search expects it to be at the beginning. The fix was simply to make git__prefixcmp compare using unsigned chars, just like strcmp(3). The rest of the change is just adding/updating tests.
* Ranged iterators and rewritten git_status_fileRussell Belfer2012-05-151-14/+208
| | | | | | | | | | | | | | | | | | | | | The goal of this work is to rewrite git_status_file to use the same underlying code as git_status_foreach. This is done in 3 phases: 1. Extend iterators to allow ranged iteration with start and end prefixes for the range of file names to be covered. 2. Improve diff so that when there is a pathspec and there is a common non-wildcard prefix of the pathspec, it will use ranged iterators to minimize excess iteration. 3. Rewrite git_status_file to call git_status_foreach_ext with a pathspec that covers just the one file being checked. Since ranged iterators underlie the status & diff implementation, this is actually fairly efficient. The workdir iterator does end up loading the contents of all the directories down to the single file, which should ideally be avoided, but it is pretty good.
* Fix MSVC compilation issuenulltoken2012-05-091-104/+104
| | | | | | | | exp() is already defined in math.h. This leads to LMSVC complaining ..\..\libgit2\tests-clar\diff\blob.c(5): error C2365: 'exp' : redefinition; previous definition was 'function' Renaming the variable fixes this issue.
* tests-clar/diff: fix missing-prototype warningMichael Schubert2012-05-091-2/+2
|
* diff: fix the diffing of two identical blobsnulltoken2012-05-074-9/+42
|
* diff: make git_diff_blobs() able to detect binary blobsnulltoken2012-05-073-10/+117
|
* diff: fix the diffing of a concrete blob against a null onenulltoken2012-05-071-13/+42
|
* diff: When diffing two blobs, ensure the delta callback parameter is filled ↵nulltoken2012-05-071-1/+1
| | | | with relevant information
* Fix memory leaks and use after freeRussell Belfer2012-05-041-0/+2
|
* Support reading attributes from indexRussell Belfer2012-05-031-14/+52
| | | | | | | | | | | | | | Depending on the operation, we need to consider gitattributes in both the work dir and the index. This adds a parameter to all of the gitattributes related functions that allows user control of attribute reading behavior (i.e. prefer workdir, prefer index, only use index). This fix also covers allowing us to check attributes (and hence do diff and status) on bare repositories. This was a somewhat larger change that I hoped because it had to change the cache key used for gitattributes files.
* Merge branch 'new-error-handling' into developmentVicent Martí2012-05-026-34/+261
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .travis.yml include/git2/diff.h src/config_file.c src/diff.c src/diff_output.c src/mwindow.c src/path.c tests-clar/clar_helpers.c tests-clar/object/tree/frompath.c tests/t00-core.c tests/t03-objwrite.c tests/t08-tag.c tests/t10-refs.c tests/t12-repo.c tests/t18-status.c tests/test_helpers.c tests/test_main.c
| * Fix usage of "new" for fieldname in public headerRussell Belfer2012-05-021-2/+2
| | | | | | | | | | | | | | | | This should restore the ability to include libgit2 headers in C++ projects. Cherry picked 2de60205dfea2c4a422b2108a5e8605f97c2e895 from development into new-error-handling.
| * tests-clar/diff: mark output_len unusedMichael Schubert2012-05-011-0/+1
| |
| * 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-303-7/+40
| | | | | | | | Update the callback to provide some information related to the file change being processed and the range of the hunk, when applicable.
| * diff: fix generation of the header of a removal patchnulltoken2012-04-251-0/+68
| |
| * 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.
| * Update clar and remove old helpersRussell Belfer2012-04-173-25/+25
| | | | | | | | | | | | This updates to the latest clar which includes the helpers `cl_assert_equal_s` and `cl_assert_equal_i`. Convert the code over to use those and remove the old libgit2-only helpers.
| * Add support for pathspec to diff and statusRussell Belfer2012-04-131-0/+73
| | | | | | | | | | | | | | This adds preliminary support for pathspecs to diff and status. The implementation is not very optimized (it still looks at every single file and evaluated the the pathspec match against them), but it works.
| * Fix error in tree iterator when popping up treesRussell Belfer2012-03-251-1/+47
| | | | | | | | | | | | | | | | | | | | There was an error in the tree iterator where it would delete two tree levels instead of just one when popping up a tree level. Unfortunately the test data for the tree iterator did not have any deep trees with subtrees in the middle of the tree items, so this problem went unnoticed. This contains the 1-line fix plus new test data and tests that reveal the issue.
| * diff: Fix rebase breackageVicent Martí2012-03-061-2/+2
| |
* | diff_output: remove unused parameterschu2012-03-211-4/+4
|/ | | | Signed-off-by: schu <schu-github@schulog.org>
* 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.