summaryrefslogtreecommitdiff
path: root/tests-clar/diff/patch.c
Commit message (Collapse)AuthorAgeFilesLines
* Rename tests-clar to testsBen Straub2013-11-141-571/+0
|
* Create git_diff_line and extend git_diff_hunkRussell Belfer2013-10-211-119/+104
| | | | | | | | | | | | | 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/+13
| | | | | | | | 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-73/+73
| | | | | | 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.
* Rename new fn to git_repository_reinit_filesystemRussell Belfer2013-10-081-2/+2
|
* More filemode cleanups for FAT on MacOSRussell Belfer2013-10-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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.
* Add git_repository_reset_filesystem and fix testsRussell Belfer2013-10-041-2/+6
| | | | | | | | | | | | | | | | | When a repository is transferred from one file system to another, many of the config settings that represent the properties of the file system may be wrong. This adds a new public API that will refresh the config settings of the repository to account for the change of file system. This doesn't do a full "reinitialize" and operates on a existing git_repository object refreshing the config when done. This commit then makes use of the new API in clar as each test repository is set up. This commit also has a number of other clar test fixes where we were making assumptions about the type of filesystem, either based on outdated config data or based on the OS instead of the FS.
* Add hunk/file headers to git_diff_patch_sizeRussell Belfer2013-07-231-29/+37
| | | | | | | | | | | This allows git_diff_patch_size to account for hunk headers and file headers in the returned size. This required some refactoring of the code that is used to print file headers so that it could be invoked by the git_diff_patch_size API. Also this increases the test coverage and fixes an off-by-one bug in the size calculation when newline changes happen at the end of the file.
* Add git_diff_patch_size() APIRussell Belfer2013-07-221-4/+15
| | | | | This adds a new API to get the size in bytes of the diffs in a git_diff_patch object.
* Implement regex pattern diff driverRussell Belfer2013-06-111-1/+1
| | | | | | | 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-101-1/+1
| | | | | | | | | | | | | | | | | | 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.
* 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-071-7/+30
| | | | | | | | | | | | | | | | | | 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.
* Improve diff config options handlingRussell Belfer2013-04-231-0/+78
| | | | | | | | | | | | | | 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.
* Move some low-level repo fns to include/git2/sysRussell Belfer2013-04-211-0/+2
|
* Fix a few leaksCarlos Martín Nieto2013-03-041-0/+2
| | | | | | | | | `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
|
* Fix tests for find_similar and relatedRussell Belfer2013-02-221-9/+9
| | | | | | | | 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.
* Fix MSVC compilation warningsnulltoken2013-02-051-3/+3
| | | | Fix #1308
* Free buffer at end of testRussell Belfer2013-01-301-0/+2
|
* Add helper for diff line statsRussell Belfer2013-01-301-0/+65
| | | | | | | | | | | | This adds a `git_diff_patch_line_stats()` API that gets the total number of adds, deletes, and context lines in a patch. This will make it a little easier to emulate `git diff --stat` and the like. Right now, this relies on generating the `git_diff_patch` object, which is a pretty heavyweight way to get stat information. At some future point, it would probably be nice to be able to get this information without allocating the entire `git_diff_patch`, but that's a much larger project.
* Fix diff patch line number calculationRussell Belfer2013-01-111-1/+109
| | | | | | | | This was just wrong. Added a test that verifying patch line numbers even for hunks further into a file and then fixed the algorithm. I needed to add a little extra state into the patch so that I could track old and new file numbers independently, but it should be okay.
* Fix warnings on Win64 buildRussell Belfer2012-11-271-1/+1
|
* Update diff callback param orderRussell Belfer2012-11-271-4/+4
| | | | | | | | 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.
* Fix diff API to better parameter orderRussell Belfer2012-11-141-2/+2
| | | | | The diff API is not in the parameter order one would expect from other libgit2 APIs. This fixes that.
* Add git_diff_patch_to_str APIRussell Belfer2012-10-241-0/+30
| | | | | This adds an API to generate a complete single-file patch text from a git_diff_patch object.
* Add const to all shared pointers in diff APIRussell Belfer2012-09-251-2/+2
| | | | | | | | | | 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 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
|
* diff: provide more context to the consumer of the callbacksnulltoken2012-04-301-7/+37
| | | | 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