summaryrefslogtreecommitdiff
path: root/include/git2/diff.h
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* Move diff max_size to public APIRussell Belfer2012-09-101-1/+8
| | | | | | | | | | | This commit adds a max_size value in the public `git_diff_options` structure so that the user can automatically flag blobs over a certain size as binary regardless of other properties. Also, and perhaps more importantly, this moves binary detection to be as early as possible in the diff traversal inner loop and makes sure that we stop loading objects as soon as we decide that they are binary.
* Replace git_diff_iterator_num_files with progressRussell Belfer2012-09-101-17/+7
| | | | | | | | | 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.
* Better header commentsRussell Belfer2012-09-061-24/+34
|
* diff: Cleanup documentation and printf compatVicent Marti2012-09-061-1/+12
|
* Fix comments and a minor bugRussell Belfer2012-09-051-34/+100
| | | | | This adds better header comments and also fixes a bug in one of simple APIs that tells the number of lines in the current hunk.
* Diff iteratorsRussell Belfer2012-09-051-1/+60
| | | | | | | | | | | 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.
* Working implementation of git_submodule_statusRussell Belfer2012-08-241-0/+15
| | | | | | | | | | | | | This is a big redesign of the git_submodule_status API and the implementation of the redesigned API. It also fixes a number of bugs that I found in other parts of the submodule API while writing the tests for the status part. This also fixes a couple of bugs in the iterators that had not been noticed before - one with iterating when there is a gitlink (i.e. separate-work-dir) and one where I was treating anything even vaguely submodule-like as a submodule, more aggressively than core git does.
* Update iterators for consistency across libraryRussell Belfer2012-08-031-0/+18
| | | | | | | | | | | | | | | | | 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.