summaryrefslogtreecommitdiff
path: root/tests-clar/diff/workdir.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix leaksnulltoken2013-11-051-0/+2
|
* Merge pull request #1929 from libgit2/rb/misc-diff-fixesVicent Martí2013-11-041-0/+156
|\ | | | | Fix some observed problems with incorrect diffs
| * Fix --assume-unchanged supportRussell Belfer2013-11-011-0/+54
| | | | | | | | | | | | | | This was never really working right because we were checking the wrong flag and not checking it in all the places that we need to be checking it. I finally got around to writing a test and adding actual support for it.
| * More tests and fixed for merging reversed diffsRussell Belfer2013-11-011-0/+32
| | | | | | | | | | | | There were a lot more cases to deal with to make sure that our merged (i.e. workdir-to-tree-to-index) diffs were matching the output of core Git.
| * Make diff and status perform soft index reloadRussell Belfer2013-11-011-0/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes `git_index_read` to have two modes - a hard index reload that always resets the index to match the on-disk data (which was the old behavior) and a soft index reload that uses the timestamp / file size information and only replaces the index data if the file on disk has been modified. This then updates the git_status code to do a soft reload unless the new GIT_STATUS_OPT_NO_REFRESH flag is passed in. This also changes the behavior of the git_diff functions that use the index so that when an index is not explicitly passed in (i.e. when the functions call git_repository_index for you), they will also do a soft reload for you. This intentionally breaks the file signature of git_index_read because there has been some confusion about the behavior previously and it seems like all existing uses of the API should probably be examined to select the desired behavior.
* | Fix a leak in the diff testsCarlos Martín Nieto2013-11-021-0/+1
|/
* Implement patience and minimal diff flagsRussell Belfer2013-10-211-0/+47
| | | | | | It seems that to implement these options, we just have to pass the appropriate flags through to the libxdiff code taken from core git. So let's do it (and add a test).
* Create git_diff_line and extend git_diff_hunkRussell Belfer2013-10-211-12/+9
| | | | | | | | | | | | | Instead of having functions with so very many parameters to pass hunk and line data, this takes the existing git_diff_hunk struct and extends it with more hunk data, plus adds a git_diff_line. Those structs are used to pass back hunk and line data instead of the old APIs that took tons of parameters. Some work that was previously only being done for git_diff_patch creation (scanning the diff content for exact line counts) is now done for all callbacks, but the performance difference should not be noticable.
* Diff API cleanupRussell Belfer2013-10-151-9/+12
| | | | | | | | This lays groundwork for separating formatting options from diff creation options. This groups the formatting flags separately from the diff list creation flags and reorders the options. This also tweaks some APIs to further separate code that uses patches from code that just looks at git_diffs.
* Rename diff objects and split patch.hRussell Belfer2013-10-111-75/+75
| | | | | | This makes no functional change to diff but renames a couple of the objects and splits the new git_patch (formerly git_diff_patch) into a new header file.
* More filemode cleanups for FAT on MacOSRussell Belfer2013-10-081-10/+1
| | | | | | | | | | | | | | | | | | | | | | This cleans up some additional issues. The main change is that on a filesystem that doesn't support mode bits, libgit2 will now create new blobs with GIT_FILEMODE_BLOB always instead of being at the mercy to the filesystem driver to report executable or not. This means that if "core.filemode" lies and claims that filemode is not supported, then we will ignore the executable bit from the filesystem. Previously we would have allowed it. This adds an option to the new git_repository_reset_filesystem to recurse through submodules if desired. There may be other types of APIs that would like a "recurse submodules" option, but this one is particularly useful. This also has a number of cleanups, etc., for related things including trying to give better error messages when problems come up from the filesystem. For example, the FAT filesystem driver on MacOS appears to return errno EINVAL if you attempt to write a filename with invalid UTF-8 in it. We try to capture that with a better error message now.
* Fix incorrect return code in crlf filterRussell Belfer2013-09-241-0/+25
| | | | | | The git_buf_text_gather_stats call returns a boolean indicating if the file looks like binary data. That shouldn't be an error; it should be used to skip CRLF processing though.
* Untracked directories with .git should be ignoredRussell Belfer2013-07-101-3/+4
| | | | | | | | | | | | | | | | | This restores a behavior that was accidentally lost during some diff refactoring where an untracked directory that contains a .git item should be treated as IGNORED, not as UNTRACKED. The submodule code already detects this, but the diff code was not handling the scenario right. This also updates a number of existing tests that were actually exercising the behavior but did not have the right expectations in place. It actually makes the new `test_diff_submodules__diff_ignore_options` test feel much better because the "not-a-submodule" entries are now ignored instead of showing up as untracked items. Fixes #1697
* Add test for fixed diff bugRussell Belfer2013-06-201-0/+20
| | | | | | | Add test for bug fixed in 852ded96982ae70acb63c3940fae08ea29e40fee Sorry, I wrote that bug fix and forgot to check in a test at the same time. Here is one that fails on the old version of the code and now works.
* 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.
* More tests for diff untracked directoriesRussell Belfer2013-04-301-0/+187
| | | | | | This includes more tests for various scenarios when diff includes an untracked directory in the workdir with contents either ignored or not.
* What has science done.Vicent Marti2013-04-221-1/+2
|
* Notify '*' pathspec correctly when diffingyorah2013-04-111-163/+0
| | | | I also moved all tests related to notifying in their own file.
* Fix some diff ignores and submodule dirty workdirRussell Belfer2013-03-251-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-251-116/+33
| | | | | | | | 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-251-0/+179
| | | | 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-181-6/+8
| | | | | | | | | | | | | | | | 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.
* diff: add a notify callback to `git_diff__from_iterators`yorah2013-02-071-0/+163
| | | | | | | | | The callback will be called for each file, just before the `git_delta_t` gets inserted into the diff list. When the callback: - returns < 0, the diff process will be aborted - returns > 0, the delta will not be inserted into the diff list, but the diff process continues - returns 0, the delta is inserted into the diff list, and the diff process continues
* tests: plug a couple of leaksCarlos Martín Nieto2013-01-111-0/+1
|
* Resolve crash with diff against empty fileRussell Belfer2013-01-081-0/+43
| | | | | | | | | | | It is not legal inside our `p_mmap` function to mmap a zero length file. This adds a test that exercises that case inside diff and fixes the code path where we would try to do that. The fix turns out not to be a lot of code since our default file content is already initialized to "" which works in this case. Fixes #1210
* Fix diff constructor name order confusionRussell Belfer2012-12-171-31/+31
| | | | | | | | | | | | The diff constructor functions had some confusing names, where the "old" side of the diff was coming after the "new" side. This reverses the order in the function name to make it less confusing. Specifically... * git_diff_index_to_tree becomes git_diff_tree_to_index * git_diff_workdir_to_index becomes git_diff_index_to_workdir * git_diff_workdir_to_tree becomes git_diff_tree_to_workdir
* Deploy GIT_DIFF_OPTIONS_INITBen Straub2012-11-301-9/+29
|
* diff: enhance test coverage against the workdirnulltoken2012-11-281-0/+23
|
* Update diff callback param orderRussell Belfer2012-11-271-35/+35
| | | | | | | | This makes the diff functions that take callbacks both take the payload parameter after the callback function pointers and pass the payload as the last argument to the callback function instead of the first. This should make them consistent with other callbacks across the API.
* More external API cleanupVicent Marti2012-11-271-35/+35
| | | | | | Conflicts: src/branch.c tests-clar/refs/branches/create.c
* Add explicit git_index ptr to diff and checkoutRussell Belfer2012-11-141-20/+20
| | | | | | | | A number of diff APIs and the `git_checkout_index` API take a `git_repository` object an operate on the index. This updates them to take a `git_index` pointer explicitly and only fall back on the `git_repository` index if the index input is NULL. This makes it easier to operate on a temporary index.
* Fix diff API to better parameter orderRussell Belfer2012-11-141-25/+28
| | | | | The diff API is not in the parameter order one would expect from other libgit2 APIs. This fixes that.
* Initial implementation of diff rename detectionRussell Belfer2012-10-231-67/+67
| | | | | | | | | | | | | | | | 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.
* diff: workdir diffing in a bare repo returns EBAREREPOnulltoken2012-10-181-0/+17
|
* 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.
* Add const to all shared pointers in diff APIRussell Belfer2012-09-251-1/+1
| | | | | | | | | | 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!
* Initial implementation of new diff patch APIRussell Belfer2012-09-251-43/+26
| | | | | | | | 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-131-0/+91
| | | | | | | 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.
* Diff iteratorsRussell Belfer2012-09-051-179/+306
| | | | | | | | | | | 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.
* Plug a few leaksCarlos Martín Nieto2012-06-201-0/+2
|
* Minor fixes, cleanups, and clarificationsRussell Belfer2012-06-081-28/+167
| | | | | | | | | | | | | | | | | | | | | | | 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-071-10/+10
| | | | | | | | | | | | | | | | 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.
* Update clar and remove old helpersRussell Belfer2012-04-171-13/+13
| | | | | | 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.
* 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-021-6/+2
| | | | | | | | | | | | | | | | | | | 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-021-0/+230
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.