summaryrefslogtreecommitdiff
path: root/src/diff.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Support diff.context configLinquize2013-04-231-1/+12
|
* Tests and more fixes for submodule diffsRussell Belfer2013-04-091-1/+5
| | | | | | | | | | | | | This adds tests for diffs with submodules in them and (perhaps unsurprisingly) requires further fixes to be made. Specifically, this fixes: - when considering if a submodule is dirty in the workdir, it was being treated as dirty even if only the index was dirty. - git_diff_patch_to_str (and git_diff_patch_print) were "printing" the headers for files (and submodules) that were unmodified or had no meaningful content. - added comment to previous fix and removed unneeded parens.
* Fix some diff ignores and submodule dirty workdirRussell Belfer2013-03-251-8/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This started out trying to look at the problems from issue #1425 and gradually grew to a broader set of fixes. There are two core things fixed here: 1. When you had an ignore like "/bin" which is rooted at the top of your tree, instead of immediately adding the "bin/" entry as an ignored item in the diff, we were returning all of the direct descendants of the directory as ignored items. This changes things to immediately ignore the directory. Note that this effects the behavior in test_status_ignore__subdirectories so that we no longer exactly match core gits ignore behavior, but the new behavior probably makes more sense (i.e. we now will include an ignored directory inside an untracked directory that we previously would have left off). 2. When a submodule only contained working directory changes, the diff code was always considering it unmodified which was just an outright bug. The HEAD SHA of the submodule matches the SHA in the parent repo index, and since the SHAs matches, the diff code was overwriting the actual status with UNMODIFIED. These fixes broke existing tests test_diff_workdir__submodules and test_status_ignore__subdirectories but looking it over, I actually think the new results are correct and the old results were wrong. @nulltoken had actually commented on the subdirectory ignore issue previously. I also included in the tests some debugging versions of the shared iteration callback routines that print status or diff information. These aren't used actively in the tests, but can be quickly swapped in to test code to give a better picture of what is being scanned in some of the complex test scenarios.
* Implement GIT_STATUS_OPT_EXCLUDE_SUBMODULESRussell Belfer2013-03-251-0/+14
| | | | | | | | | | | This option has been sitting unimplemented for a while, so I finally went through and implemented it along with some tests. As part of this, I improved the implementation of GIT_DIFF_IGNORE_SUBMODULES so it be more diligent about avoiding extra work and about leaving off delta records for submodules to the greatest extent possible (though it may include them still if you are request TYPECHANGE records).
* Recursing into ignored dirs for diff and statusRussell Belfer2013-03-251-24/+32
| | | | | | | | 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.
* Three submodule status bug fixesRussell Belfer2013-03-181-3/+7
| | | | | | | | | | | | | | | | 1. Fix sort order problem with submodules where "mod" was sorting after "mod-plus" because they were being sorted as "mod/" and "mod-plus/". This involved pushing the "contains a .git entry" test significantly lower in the stack. 2. Reinstate behavior that a directory which contains a .git entry will be treated as a submodule during iteration even if it is not yet added to the .gitmodules. 3. Now that any directory containing .git is reported as submodule, we have to be more careful checking for GIT_EEXISTS when we do a submodule lookup, because that is the error code that is returned by git_submodule_lookup when you try to look up a directory containing .git that has no record in gitmodules or the index.
* Merge pull request #1408 from arrbee/refactor-iteratorsVicent Martí2013-03-121-30/+36
|\ | | | | Refactor iterators
| * Add INCLUDE_TREES, DONT_AUTOEXPAND iterator flagsRussell Belfer2013-03-061-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This standardizes iterator behavior across all three iterators (index, tree, and working directory). Previously the working directory iterator behaved differently from the other two. Each iterator can now operate in one of three modes: 1. *No tree results, auto expand trees* means that only non- tree items will be returned and when a tree/directory is encountered, we will automatically descend into it. 2. *Tree results, auto expand trees* means that results will be given for every item found, including trees, but you only need to call normal git_iterator_advance to yield every item (i.e. trees returned with pre-order iteration). 3. *Tree results, no auto expand* means that calling the normal git_iterator_advance when looking at a tree will not descend into the tree, but will skip over it to the next entry in the parent. Previously, behavior 1 was the only option for index and tree iterators, and behavior 3 was the only option for workdir. The main public API implications of this are that the `git_iterator_advance_into()` call is now valid for all iterators, not just working directory iterators, and all the existing uses of working directory iterators explicitly use the GIT_ITERATOR_DONT_AUTOEXPAND (for now). Interestingly, the majority of the implementation was in the index iterator, since there are no tree entries there and now have to fake them. The tree and working directory iterators only required small modifications.
| * Retire spoolandsort iteratorRussell Belfer2013-03-061-7/+2
| | | | | | | | | | Since the case sensitivity is moved into the respective iterators, this removes the spoolandsort iterator code.
| * Make iterator APIs consistent with standardsRussell Belfer2013-03-061-21/+20
| | | | | | | | | | | | | | | | | | | | | | | | The iterator APIs are not currently consistent with the parameter ordering of the rest of the codebase. This rearranges the order of parameters, simplifies the naming of a number of functions, and makes somewhat better use of macros internally to clean up the iterator code. This also expands the test coverage of iterator functionality, making sure that case sensitive range-limited iteration works correctly.
* | diff: allow asking for diffs with no contextCarlos Martín Nieto2013-03-091-1/+4
|/ | | | | | | | | 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.
* 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.