summaryrefslogtreecommitdiff
path: root/src/diff.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Replace diff delta binary with flagsRussell Belfer2013-02-201-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* diff: add a notify callback to `git_diff__from_iterators`yorah2013-02-071-10/+34
| | | | | | | | | 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
* Return the matched pathspec pattern in `git_pathspec_match_path`yorah2013-02-071-2/+4
| | | | | | | Instead of returning directly the pattern as the return value, I used an out parameter, because the function also tests if the passed pathspecs vector is empty. If yes, it considers that the path "matches", but in that case there is no matched pattern per se.
* Update iterator API with flags for ignore_caseRussell Belfer2013-01-151-11/+13
| | | | | | | | | | | | This changes the iterator API so that flags can be passed in to the constructor functions to control the ignore_case behavior. At this point, the flags are not supported on tree iterators (i.e. there is no functional change over the old API), but the API changes are all made to accomodate this. By the way, I went with a flags parameter because in the future I have a couple of other ideas for iterator flags that will make it easier to fix some diff/status/checkout bugs.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Fix up spoolandsort iterator usageRussell Belfer2013-01-041-2/+1
| | | | | | | The spoolandsort iterator changes got sort-of cherry picked out of this branch and so I dropped the commit when rebasing; however, there were a few small changes that got dropped as well (since the version merged upstream wasn't quite the same as what I dropped).
* More checkout improvementsRussell Belfer2013-01-041-14/+29
| | | | | | | This flips checkout back to be driven off the changes between the baseline and the target trees. This reinstates the complex code for tracking the contents of the working directory, but overall, I think the resulting logic is easier to follow.
* Make spoolandsort a pushable iterator behaviorRussell Belfer2012-12-271-12/+7
| | | | | | | | | | | | | | | | | | | | | An earlier change to `git_diff_from_iterators` introduced a memory leak where the allocated spoolandsort iterator was not returned to the caller and thus not freed. One proposal changes all iterator APIs to use git_iterator** so we can reallocate the iterator at will, but that seems unexpected. This commit makes it so that an iterator can be changed in place. The callbacks are isolated in a separate structure and a pointer to that structure can be reassigned by the spoolandsort extension. This means that spoolandsort doesn't create a new iterator; it just allocates a new block of callbacks (along with space for its own extra data) and swaps that into the iterator. Additionally, since spoolandsort is only needed to switch the case sensitivity of an iterator, this simplifies the API to only take the ignore_case boolean and to be a no-op if the iterator already matches the requested case sensitivity.
* Fix diff constructor name order confusionRussell Belfer2012-12-171-3/+3
| | | | | | | | | | | | 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
* Clean up iterator APIsRussell Belfer2012-12-101-10/+11
| | | | | | | | 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.
* Fix diff header comments and missing constRussell Belfer2012-12-051-1/+1
| | | | | | 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.
* Deploy GITERR_CHECK_VERSIONBen Straub2012-11-301-3/+2
|
* Deploy GIT_DIFF_OPTIONS_INITBen Straub2012-11-301-3/+4
|
* API updates for submodule.hRussell Belfer2012-11-271-2/+2
|
* Merge pull request #1071 from arrbee/alternate-fix-strcmpScott J. Goldman2012-11-151-4/+4
|\ | | | | Win32 fixes for diff/checkout/reset
| * Create internal strcmp variants for function ptrsRussell Belfer2012-11-141-4/+4
| | | | | | | | | | | | Using the builtin strcmp and strcasecmp as function pointers is problematic on win32. This adds internal implementations and divorces us from the platform linkage.
* | Merge pull request #1074 from edubart/ignore_diff_filemodeVicent Martí2012-11-151-0/+3
|\ \ | | | | | | Add option to ignore file mode in diffs
| * | Add option to ignore file mode in diffsEduardo Bart2012-11-151-0/+3
| |/
* | Add explicit git_index ptr to diff and checkoutRussell Belfer2012-11-141-22/+35
| | | | | | | | | | | | | | | | 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.
* | Add iterator for git_index objectRussell Belfer2012-11-141-2/+15
| | | | | | | | | | | | The index iterator could previously only be created from a repo object, but this allows creating an iterator from a `git_index` object instead (while keeping, though renaming, the old function).
* | Fix diff API to better parameter orderRussell Belfer2012-11-141-78/+41
|/ | | | | The diff API is not in the parameter order one would expect from other libgit2 APIs. This fixes that.
* Fix various cross-platform build issuesRussell Belfer2012-11-091-15/+15
| | | | | | 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.
* fix regression in diff with submodule oidRussell Belfer2012-11-091-9/+8
|
* Some diff refactorings to help code reuseRussell Belfer2012-11-091-74/+92
| | | | | | | | | | | | | | | | | 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 pathspec code in separate filesRussell Belfer2012-11-091-135/+37
| | | | | | | Diff uses a `git_strarray` of path specs to represent a subset of all files to be processed. It is useful to be able to reuse this filtering in other places outside diff, so I've moved it into a standalone set of utilities.
* Move rename detection into new fileRussell Belfer2012-10-301-319/+23
| | | | | | | | | | | | | | | 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/+147
| | | | | | | | | | | | | | | | 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-6/+10
|
* Add complex checkout test and then fix checkoutRussell Belfer2012-10-091-8/+92
| | | | | | | | | | | | | | | | 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.
* Introduce status/diff TYPECHANGE flagsRussell Belfer2012-10-091-12/+14
| | | | | | | | 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.
* Add test for diffs with submodules and bug fixesRussell Belfer2012-10-081-7/+30
| | | | | | | | 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.
* Fix a few diff bugs with directory contentRussell Belfer2012-10-081-4/+18
| | | | | | | | | | | | | | | 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.
* Diff: Do not try to calculate an oid for a GITLINK.Sascha Cunz2012-10-051-1/+5
| | | | | | | | | | | | | | We don't have anything useful that we could do with that oid anyway (We need to query the submodule for the HEAD commit instead). Without this, the following code creates the error "Failed to read descriptor: Is a directory" when run against the submod2 test-case: const char* oidstr = "873585b94bdeabccea991ea5e3ec1a277895b698"; git_tree* tree = resolve_commit_oid_to_tree(g_repo, oidstr); git_diff_list* diff = NULL; cl_assert(tree); cl_git_pass(git_diff_workdir_to_tree(g_repo, NULL, tree, &diff));
* Diff: teach get_workdir_content to show a submodule as textSascha Cunz2012-10-051-2/+5
| | | | | | | | | | | | | | | | 1. teach diff.c:maybe_modified to query git_submodule_status for the modification state of a submodule. According to the git_submodule_status docs, it will filter for to-ignore states already. 2. teach diff_output.c:get_workdir_content to check the submodule status again and create a line like: Subproject commit <SHA-1>\n or Subproject comimt <SHA-1>-dirty\n like git.git does.
* Merge pull request #939 from pwkelley/ignorecaseRussell Belfer2012-10-021-6/+58
|\ | | | | Support for the core.ignorecase flag
| * Minor fixes for ignorecase supportPhilip Kelley2012-09-171-1/+1
| |
| * Support for core.ignorecasePhilip Kelley2012-09-171-6/+58
| |
* | 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/+30
| | | | | | | | | | | | | | | | | | 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-18/+28
|/ | | | | | | | 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.
* Implement filters for status/diff blobsRussell Belfer2012-09-061-11/+22
| | | | | | | | | | | | | 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-4/+10
| | | | | | | | | | | 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.
* Major submodule rewriteRussell Belfer2012-08-241-1/+1
| | | | | This replaces the old submodule API with a new extended API that supports most of the things that can be done with `git submodule`.
* Minor bug fixes in diff codeRussell Belfer2012-08-221-1/+2
| | | | | | | In looking at PR #878, I found a few small bugs in the diff code, mostly related to work that can be avoided when processing tree- to-tree diffs that was always being carried out. This commit has some small fixes in it.
* oid: Explicitly include `oid.h` for the inlined CMPVicent Marti2012-08-091-0/+1
|
* Add flag to turn off pathspec testing for diff and statusyorah2012-07-241-2/+3
|
* Fix getting status of files containing bracketsyorah2012-07-241-7/+16
|
* Fix bug with merging diffs with null optionsRussell Belfer2012-07-191-2/+2
| | | | | | | A diff that is created with a NULL options parameter could result in a NULL prefix string, but diff merge was unconditionally strdup'ing it. I added a test to replicate the issue and then a new method that does the right thing with NULL values.
* diff: make sure we free all allocated resourcesCarlos Martín Nieto2012-06-201-6/+21
| | | | | When the creation of one iterator fails, we need to free the prefix and possibly one of the iterators. Make sure we do so.
* Make index add/append support core.filemode flagRussell Belfer2012-06-191-2/+2
| | | | | | | | | | | This fixes git_index_add and git_index_append to behave more like core git, preserving old filemode data in the index when adding and/or appending with core.filemode = false. This also has placeholder support for core.symlinks and core.ignorecase, but those flags are not implemented (well, symlinks has partial support for preserving mode information in the same way that git does, but it isn't tested).