summaryrefslogtreecommitdiff
path: root/tests-clar/diff
Commit message (Collapse)AuthorAgeFilesLines
* 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 > 0x7fAdam 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.
* Fixing memory leaks indicated by valgrindRussell Belfer2012-03-021-0/+2
| | | | | This clears up the memory leaks that valgrind seems to find on my machine.
* Clean up GIT_UNUSED macros on all platformsRussell Belfer2012-03-025-68/+16
| | | | | | | | | | | | | | | | | | | It turns out that commit 31e9cfc4cbcaf1b38cdd3dbe3282a8f57e5366a5 did not fix the GIT_USUSED behavior on all platforms. This commit walks through and really cleans things up more thoroughly, getting rid of the unnecessary stuff. To remove the use of some GIT_UNUSED, I ended up adding a couple of new iterators for hashtables that allow you to iterator just over keys or just over values. In making this change, I found a bug in the clar tests (where we were doing *count++ but meant to do (*count)++ to increment the value). I fixed that but then found the test failing because it was not really using an empty repo. So, I took some of the code that I wrote for iterator testing and moved it to clar_helpers.c, then made use of that to make it easier to open fixtures on a per test basis even within a single test file.
* Update diff to use iteratorsRussell Belfer2012-03-025-30/+266
| | | | | | | | | | | | | 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-022-23/+3
| | | | | 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-022-0/+89
| | | | | | 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-025-27/+124
| | | | | | | | * 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-024-0/+300
| | | | | | | 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.
* Fix workdir iterator unit testsRussell Belfer2012-02-231-2/+2
| | | | | | This test is fragile if you leave extra files in the test data directory, such as a foo.c~ file from editing with Emacs. Who would do such a thing?
* Iterator improvements from diff implementationRussell Belfer2012-02-221-6/+8
| | | | | | | | | | | | | | | | | This makes two changes to iterator behavior: first, advance can optionally do the work of returning the new current value. This is such a common pattern that it really cleans up usage. Second, for workdir iterators, this removes automatically iterating into directories. That seemed like a good idea, but when an entirely new directory hierarchy is introduced into the workdir, there is no reason to iterate into it if there are no corresponding entries in the tree/index that it is being compared to. This second change actually wasn't a lot of code because not descending into directories was already the behavior for ignored directories. This just extends that to all directories.
* Uniform iterators for trees, index, and workdirRussell Belfer2012-02-213-0/+388
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.