summaryrefslogtreecommitdiff
path: root/include/git2/diff.h
Commit message (Collapse)AuthorAgeFilesLines
...
* More git_diff_find_similar improvementsRussell Belfer2013-05-201-0/+2
| | | | | | | | | | | | | | - Add new GIT_DIFF_FIND_EXACT_MATCH_ONLY flag to do similarity matching without using the similarity metric (i.e. only compare the SHA). - Clean up the similarity measurement code to more rigorously distinguish between files that are not similar and files that are not comparable (previously, a 0 could either mean that the files could not be compared or that they were totally different) - When splitting a MODIFIED file into a DELETE/ADD pair, actually make a DELETED/UNTRACKED pair if the right side of the diff is from the working directory. This prevents an odd mix of ADDED and UNTRACKED files on workdir diffs.
* Fix issues with git_diff_find_similarRussell Belfer2013-05-171-11/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a number of bugs in the rename code that only were obvious when I started testing it against large old repos with more complex patterns. (The code to do that testing is not ready to merge with libgit2, but I do plan to add more thorough tests.) This contains a significant number of changes and also tweaks the public API slightly to make emulating core git easier. Most notably, this separates the GIT_DIFF_FIND_AND_BREAK_REWRITES flag into FIND_REWRITES (which adds a self-similarity score to every modified file) and BREAK_REWRITES (which splits the modified deltas into add/remove pairs in the diff list). When you do a raw output of core git, rewrites show up as M090 or such, not at A and D output, so I wanted to be able to emulate that. Publicly, this also changes the flags to be uint16_t since we don't need values out of that range. Internally, this contains significant changes from a number of small bug fixes (like using the wrong side of the diff to decide if the object could be found in the ODB vs the workdir) to larger issues about which files can and should be compared and how the various edge cases of similarity scores should be treated. Honestly, I don't think this is the last update that will have to be made to this code, but I think this moves us closer to correct behavior and I tried to document the code so it would be easier to follow..
* Add git_diff_print_raw printing helperRussell Belfer2013-05-171-0/+16
| | | | Makes it easier to emulate the --raw option
* Improve diff function docsRussell Belfer2013-05-071-7/+26
|
* Add GIT_DIFF_LINE_CONTEXT_EOFNLRussell Belfer2013-05-071-2/+4
| | | | | | | | | | | | | | | | | | 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.
* Update comment for clarityRussell Belfer2013-04-301-5/+17
|
* Update diff handling of untracked directoriesRussell Belfer2013-04-301-0/+7
| | | | | | | | | | When diff encounters an untracked directory, there was a shortcut that it took which is not compatible with core git. This makes the default behavior no longer take that shortcut and instead look inside the untracked directory to see if there are any untracked files within it. If there are not, then the directory is treated as an ignore directory instead of an untracked directory. This has implications for the git_status APIs.
* Recursing into ignored dirs for diff and statusRussell Belfer2013-03-251-1/+1
| | | | | | | | This implements working versions of GIT_DIFF_RECURSE_IGNORED_DIRS and GIT_STATUS_OPT_RECURSE_IGNORED_DIRS along with some tests for the newly available behaviors. This is not turned on by default for status, but can be accessed via the options to the extended version of the command.
* diff: allow asking for diffs with no contextCarlos Martín Nieto2013-03-091-1/+1
| | | | | | | | | Previously, 0 meant default. This is problematic, as asking for 0 context lines is a valid thing to do. Change GIT_DIFF_OPTIONS_INIT to default to three and stop treating 0 as a magic value. In case no options are provided, make sure the options in the diff object default to 3.
* Add diff rename tests with partial similarityRussell Belfer2013-02-211-0/+3
| | | | | | | | | | | | | | This adds some new tests that actually exercise the similarity metric between files to detect renames, copies, and split modified files that are too heavily modified. There is still more testing to do - these tests are just partially covering the cases. There is also one bug fix in this where a change set with only MODIFY being broken into ADD/DELETE (due to low self-similarity) without any additional RENAMED entries would end up not processing the split requests (because the num_rewrites counter got reset).
* Initial integration of similarity metric to diffRussell Belfer2013-02-211-5/+11
| | | | | | | | | | | | | | | | This is the initial integration of the similarity metric into the `git_diff_find_similar()` code path. The existing tests all pass, but the new functionality isn't currently well tested. The integration does go through the pluggable metric interface, so it should be possible to drop in an alternative to the internal metric that libgit2 implements. This comes along with a behavior change for an existing interface; namely, passing two NULLs to git_diff_blobs (or passing NULLs to git_diff_blob_to_buffer) will now call the file_cb parameter zero times instead of one time. I know it's strange that that change is paired with this other change, but it emerged from some initialization changes that I ended up making.
* Replace diff delta binary with flagsRussell Belfer2013-02-201-26/+28
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Refine pluggable similarity APIRussell Belfer2013-02-201-2/+28
| | | | | | | | | | | | This plugs in the three basic similarity strategies for handling whitespace via internal use of the pluggable API. In so doing, I realized that the use of git_buf in the hashsig API was not needed and actually just made it harder to use, so I tweaked that API as well. Note that the similarity metric is still not hooked up in the find_similarity code - this is just setting out the function that will be used.
* Pluggable similarity metric APIRussell Belfer2013-02-201-0/+13
|
* diff: add a notify callback to `git_diff__from_iterators`yorah2013-02-071-34/+58
| | | | | | | | | 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
* Add helper for diff line statsRussell Belfer2013-01-301-0/+22
| | | | | | | | | | | | 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.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Share git_diff_blobs/git_diff_blob_to_buffer codeRussell Belfer2013-01-071-20/+18
| | | | | | | This moves the implementation of these two APIs into common code that will be shared between the two. Also, this adds tests for the `git_diff_blob_to_buffer` API. Lastly, this adds some extra `const` to a few places that can use it.
* Introduce git_diff_blob_to_bufferIgnacio Casal Quinteiro2013-01-071-0/+24
|
* Correct typos in documentationKevin Sawicki2013-01-061-2/+2
|
* More diff.h comment fixesRussell Belfer2012-12-171-34/+52
| | | | | Based on feedback from the ObjectiveGit folks, these are some further updates to diff.h areas that are poorly documented.
* Fix diff constructor name order confusionRussell Belfer2012-12-171-25/+42
| | | | | | | | | | | | 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
* Allow compilation as C++Ben Straub2012-12-061-2/+2
|
* Fix diff header comments and missing constRussell Belfer2012-12-051-9/+67
| | | | | | Based on the recent work to wrap diff in objective-git, this includes a fix for a missing const and a number of clarifications of the documentation.
* Make constant name all-capsBen Straub2012-11-301-1/+1
|
* Deploy GIT_DIFF_OPTIONS_INITBen Straub2012-11-301-1/+1
|
* Add version fields and init macros for public input structs.Ben Straub2012-11-301-8/+13
|
* Update diff callback param orderRussell Belfer2012-11-271-24/+26
| | | | | | | | 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-15/+16
| | | | | | Conflicts: src/branch.c tests-clar/refs/branches/create.c
* Merge pull request #1074 from edubart/ignore_diff_filemodeVicent Martí2012-11-151-0/+2
|\ | | | | Add option to ignore file mode in diffs
| * Add option to ignore file mode in diffsEduardo Bart2012-11-151-0/+2
| |
* | Add explicit git_index ptr to diff and checkoutRussell Belfer2012-11-141-0/+4
| | | | | | | | | | | | | | | | 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-17/+17
|/ | | | | The diff API is not in the parameter order one would expect from other libgit2 APIs. This fixes that.
* Merge pull request #1014 from arrbee/diff-rename-detectionVicent Martí2012-11-021-7/+63
|\ | | | | Initial implementation of diff rename detection
| * Move rename detection into new fileRussell Belfer2012-10-301-18/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-7/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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_printRussell Belfer2012-10-251-1/+18
| | | | | | | | | | | | | | | | | | This adds a `git_diff_patch_print()` API which is more like the existing API to "print" a patch from an entire `git_diff_list` but operates on a single `git_diff_patch` object. Also, it rewrites the `git_diff_patch_to_str()` API to use that function (making it very small).
* | Add git_diff_patch_to_str APIRussell Belfer2012-10-241-0/+11
|/ | | | | This adds an API to generate a complete single-file patch text from a git_diff_patch object.
* Move enum comments next to actual valuesRussell Belfer2012-10-091-44/+43
|
* Add complex checkout test and then fix checkoutRussell Belfer2012-10-091-1/+6
| | | | | | | | | | | | | | | | 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.
* Cleanup TYPECHANGE supportRussell Belfer2012-10-091-0/+24
| | | | | | This is just some cleanup code, rearranging some of the checkout code where TYPECHANGE support was added and adding some comments to the diff header regarding the constants.
* Introduce status/diff TYPECHANGE flagsRussell Belfer2012-10-091-1/+3
| | | | | | | | When I wrote the diff code, I based it on core git's diff output which tends to split a type change into an add and a delete. But core git's status has the notion of a T (typechange) flag for a file. This introduces that into our status APIs and modifies the diff code so it can be forced to not split type changes.
* Fix a few diff bugs with directory contentRussell Belfer2012-10-081-1/+2
| | | | | | | | | | | | | | | There are a few cases where diff should leave directories in the diff list if we want to match core git, such as when the directory contains a .git dir. That feature was lost when I introduced some of the new submodule handling. This restores that and then fixes a couple of related to diff output that are triggered by having diffs with directories in them. Also, this adds a new flag that can be passed to diff if you want diff output to actually include the file content of any untracked files.
* Merge pull request #939 from pwkelley/ignorecaseRussell Belfer2012-10-021-0/+1
|\ | | | | Support for the core.ignorecase flag
| * Support for core.ignorecasePhilip Kelley2012-09-171-0/+1
| |
* | Add const to all shared pointers in diff APIRussell Belfer2012-09-251-9/+9
| | | | | | | | | | | | | | | | | | | | 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-3/+17
| | | | | | | | | | | | | | | | | | 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-13/+49
| | | | | | | | | | | | | | | | 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.
* | New take on iterating over diff contentRussell Belfer2012-09-251-143/+100
|/ | | | | Allow diff deltas to be accessed by index and make patch generation explicit with hunk and line access by index as well.
* Fix diff binary file detectionRussell Belfer2012-09-111-2/+17
| | | | | | | | | | | 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.