summaryrefslogtreecommitdiff
path: root/src/diff.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove trace / add git_diff_perfdata struct + apiRussell Belfer2014-05-021-0/+2
|
* Add GIT_STATUS_OPT_UPDATE_INDEX and use trace APIRussell Belfer2014-05-021-5/+0
| | | | | | This adds an option to refresh the stat cache while generating status. It also rips out the GIT_PERF stuff I had an makes use of the trace API to keep statistics about what happens during diff.
* Add diff option to update index stat cacheRussell Belfer2014-05-021-1/+1
| | | | | | | | | | When diff is scanning the working directory, if it finds a file where it is not sure if the index entry matches the working dir, it will recalculate the OID (which is pretty expensive). This adds a new flag to diff so that if the OID calculation finds that the file actually has not changed (i.e. just the modified time was altered or such), then it will refresh the stat cache in the index so that future calls to diff will not have to check the oid again.
* Lay groundwork for updating stat cache in diffRussell Belfer2014-05-021-1/+3
| | | | | | | | | | | This reorganized the diff OID calculation to make it easier to correctly update the stat cache during a diff once the flags to do so are enabled. This includes marking the path of a git_index_entry as const so we can make a "fake" git_index_entry with a "const char *" path and not get warnings. I was a little surprised at how unobtrusive this change was, but I think it's probably a good thing.
* Add build option for diff internal statisticsRussell Belfer2014-05-021-1/+6
|
* Introduce git_diff_format_email and git_diff_commit_as_emailJacques Germishuys2014-04-151-0/+3
|
* diff: rename the file's 'oid' to 'id'Carlos Martín Nieto2014-01-251-1/+1
| | | | In the same vein as the previous commits in this series.
* Fix --assume-unchanged supportRussell Belfer2013-11-011-1/+1
| | | | | | | 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.
* Rename diff objects and split patch.hRussell Belfer2013-10-111-5/+5
| | | | | | 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.
* Merge pull request #1738 from libgit2/diff-patch-content-sizeBen Straub2013-08-081-0/+7
|\ | | | | Add API for getting at git_diff_patch->content_size
| * Add hunk/file headers to git_diff_patch_sizeRussell Belfer2013-07-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | 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.
* | Make rename detection file size fix betterRussell Belfer2013-07-241-0/+29
|/ | | | | | | | The previous fix for checking file sizes with rename detection always loads the blob. In this version, if the odb backend can get the object header without loading the whole thing into memory, then we'll just use that, so that we can eliminate possible rename sources & targets without loading them.
* Add git_pathspec_match_diff APIRussell Belfer2013-07-101-0/+2
| | | | | | | | | | | | | | | | | | This adds an additional pathspec API that will match a pathspec against a diff object. This is convenient if you want to handle renames (so you need the whole diff and can't use the pathspec constraint built into the diff API) but still want to tell if the diff had any files that matched the pathspec. When the pathspec is matched against a diff, instead of keeping a list of filenames that matched, instead the API keeps the list of git_diff_deltas that matched and they can be retrieved via a new API git_pathspec_match_list_diff_entry. There are a couple of other minor API extensions here that were mostly for the sake of convenience and to reduce dependencies on knowing the internal data structure between files inside the library.
* More tests and bug fixes for status with renameRussell Belfer2013-06-171-5/+4
| | | | | | | | | | | | | | | | | | | | | This changes the behavior of the status RENAMED flags so that they will be combined with the MODIFIED flags if appropriate. If a file is modified in the index and also renamed, then the status code will have both the GIT_STATUS_INDEX_MODIFIED and INDEX_RENAMED bits set. If it is renamed but the OID has not changed, then just the GIT_STATUS_INDEX_RENAMED bit will be set. Similarly, the flags GIT_STATUS_WT_MODIFIED and GIT_STATUS_WT_RENAMED can both be set independently of one another. This fixes a serious bug where the check for unmodified files that was done at data load time could end up erasing the RENAMED state of a file that was renamed with no changes. Lastly, this contains a bunch of new tests for status with renames, including tests where the only rename changes are case changes. The expected results of these tests have to vary by whether the platform uses a case sensitive filesystem or not, so the expected data covers those platform differences separately.
* Improve case handling in git_diff__paired_foreachRussell Belfer2013-06-171-0/+1
| | | | | | | | This commit reinstates some changes to git_diff__paired_foreach that were discarded during the rebase (because the diff_output.c file had gone away), and also adjusts the case insensitively logic slightly to hopefully deal with either mismatched icase diffs and other case insensitivity scenarios.
* Reorganize diff and add basic diff driverRussell Belfer2013-06-101-0/+11
| | | | | | | | | | | | | | | | | | 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.
* More diff rename tests; better split swap handlingRussell Belfer2013-05-231-0/+2
| | | | | | | | | | | | | This adds a couple more tests of different rename scenarios. Also, this fixes a problem with the case where you have two "split" deltas and the left half of one matches the right half of the other. That case was already being handled, but in the wrong order in a way that could result in bad output. Also, if the swap also happened to put the other two halves into the correct place (i.e. two files exchanged places with each other), then the second delta was left with the SPLIT flag set when it really should be cleared.
* Significant rename detection rewriteRussell Belfer2013-05-221-2/+8
| | | | | | | | | | | | | | | | | | | | This flips rename detection around so instead of creating a forward mapping from deltas to possible rename targets, instead it creates a reverse mapping, looking at possible targets and trying to find a source that they could have been renamed or copied from. This is important because each output can only have a single source, but a given source could map to multiple outputs (in the form of COPIED records). Additionally, this makes a couple of tweaks to the public rename detection APIs, mostly renaming a couple of options that control the behavior to make more sense and to be more like core Git. I walked through the tests looking at the exact results and updated the expectations based on what I saw. The new code is different from the old because it cannot give some nonsense results (like A was renamed to both B and C) which were part of the outputs previously.
* Add GIT_DIFF_LINE_CONTEXT_EOFNLRussell Belfer2013-05-071-0/+1
| | | | | | | | | | | | | | | | | | 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.
* renames!Edward Thomson2013-04-301-0/+12
|
* Replace diff delta binary with flagsRussell Belfer2013-02-201-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | Previously the git_diff_delta recorded if the delta was binary. This replaces that (with no net change in structure size) with a full set of flags. The flag values that were already in use for individual git_diff_file objects are reused for the delta flags, too (along with renaming those flags to make it clear that they are used more generally). This (a) makes things somewhat more consistent (because I was using a -1 value in the "boolean" binary field to indicate unset, whereas now I can just use the flags that are easier to understand), and (b) will make it easier for me to add some additional flags to the delta object in the future, such as marking the results of a copy/rename detection or other deltas that might want a special indicator. While making this change, I officially moved some of the flags that were internal only into the private diff header. This also allowed me to remove a gross hack in rename/copy detect code where I was overwriting the status field with an internal value.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Clean up iterator APIsRussell Belfer2012-12-101-0/+6
| | | | | | | | This removes the need to explicitly pass the repo into iterators where the repo is implied by the other parameters. This moves the repo to be owned by the parent struct. Also, this has some iterator related updates to the internal diff API to lay the groundwork for checkout improvements.
* Deploy GITERR_CHECK_VERSIONBen Straub2012-11-301-13/+0
|
* Deploy GIT_DIFF_OPTIONS_INITBen Straub2012-11-301-0/+14
|
* Fix various cross-platform build issuesRussell Belfer2012-11-091-4/+4
| | | | | | This fixes a number of warnings and problems with cross-platform builds. Among other things, it's not safe to name a member of a structure "strcmp" because that may be #defined.
* Some diff refactorings to help code reuseRussell Belfer2012-11-091-0/+8
| | | | | | | | | | | | | | | | | There are some diff functions that are useful in a rewritten checkout and this lays some groundwork for that. This contains three main things: 1. Share the function diff uses to calculate the OID for a file in the working directory (now named `git_diff__oid_for_file` 2. Add a `git_diff__paired_foreach` function to iterator over two diff lists concurrently. Convert status to use it. 3. Move all the string/prefix/index entry comparisons into function pointers inside the `git_diff_list` object so they can be switched between case sensitive and insensitive versions. This makes them easier to reuse in various functions without replicating logic. As part of this, move a couple of index functions out of diff.c and into index.c.
* Move rename detection into new fileRussell Belfer2012-10-301-0/+2
| | | | | | | | | | | | | | | 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-231-0/+3
| | | | | | | | | | | | | | | | 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.
* Fix minor bugsRussell Belfer2012-10-171-6/+1
| | | | | | Fixed no-submodule speedup of new checkout code. Fixed missing final update to progress (which may go away, I realize). Fixed unused structure in header and incorrect comment.
* 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!
* Fix bugs in new diff patch codeRussell Belfer2012-09-251-0/+3
| | | | | | | | | 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-23/+9
| | | | | | | | 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.
* Replace git_diff_iterator_num_files with progressRussell Belfer2012-09-101-0/+22
| | | | | | | | | 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.
* Implement filters for status/diff blobsRussell Belfer2012-09-061-0/+2
| | | | | | | | | | | | | This adds support to diff and status for running filters (a la crlf) on blobs in the workdir before computing SHAs and before generating text diffs. This ended up being a bit more code change than I had thought since I had to reorganize some of the diff logic to minimize peak memory use when filtering blobs in a diff. This also adds a cap on the maximum size of data that will be loaded to diff. I set it at 512Mb which should match core git. Right now it is a #define in src/diff.h but it could be moved into the public API if desired.
* Diff iteratorsRussell Belfer2012-09-051-0/+1
| | | | | | | | | | | 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.
* Fix filemode comparison in diffsRussell Belfer2012-06-081-1/+4
| | | | | | | | | | | | | | | 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 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.
* diff: fix generation of the header of a removal patchnulltoken2012-04-251-0/+3
|
* Convert attrs and diffs to use string poolsRussell Belfer2012-04-251-0/+2
| | | | | | | This converts the git attr related code (including ignores) and the git diff related code (and implicitly the status code) to use `git_pools` for storing strings. This reduces the number of small blocks allocated dramatically.
* Add support for pathspec to diff and statusRussell Belfer2012-04-131-0/+1
| | | | | | | 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.
* Improve config handling for diff,submodules,attrsRussell Belfer2012-03-301-0/+9
| | | | | | | | This adds support for a bunch of core.* settings that affect diff and status, plus fixes up some incorrect implementations of those settings from before. Also, this cleans up the handling of config settings in the new submodules code and in the old attrs/ignore code.
* Eliminate hairy COITERATE macroRussell Belfer2012-03-251-14/+0
| | | | | | | I decided that the COITERATE macro was, in the end causing more confusion that it would save and decided just to write out the loops that I needed for parallel diff list iteration. It is not that much code and this just feels less obfuscated.
* Reimplment git_status_foreach using git diffRussell Belfer2012-03-211-0/+14
| | | | | This is an initial reimplementation of status using diff a la the way that core git does it.
* Update diff to use iteratorsRussell Belfer2012-03-021-5/+5
| | | | | | | | | | | | | 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.
* First pass of diff index to workdir implementationRussell Belfer2012-03-021-1/+1
| | | | | | | | | | This is an initial version of git_diff_workdir_to_index. It also includes renaming some structures and some refactoring of the existing code so that it could be shared better with the new function. This is not complete since it needs a rebase to get some new odb functions from the upstream branch.
* Continue implementation of git-diffRussell Belfer2012-03-021-1/+4
| | | | | | | | * 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
* Implement diff lists and formattersRussell Belfer2012-03-021-0/+22
This reworks the diff API to separate the steps of producing a diff descriptions from formatting the diff. This will allow us to share diff output code with the various diff creation scenarios and will allow us to implement rename detection as an optional pass that can be run on a diff list.