summaryrefslogtreecommitdiff
path: root/src/diff_tform.c
Commit message (Collapse)AuthorAgeFilesLines
* diff_tform: fix potential NULL pointer accessPatrick Steinhardt2016-03-111-3/+5
| | | | | | | | | | | When the user passes in a diff which has no repository associated we may call `git_config__get_int_force` with a NULL-pointer configuration. Even though `git_config__get_int_force` is designed to swallow errors, it is not intended to be called with a NULL pointer configuration. Fix the issue by only calling `git_config__get_int_force` only when configuration could be retrieved from the repository.
* diff_tform: fix potential NULL pointer accessPatrick Steinhardt2016-02-231-11/+16
| | | | | | | | | | | | | The `normalize_find_opts` function in theory allows for the incoming diff to have no repository. When the caller does not pass in diff find options or if the GIT_DIFF_FIND_BY_CONFIG value is set, though, we try to derive the configuration from the diff's repository configuration without first verifying that the repository is actually set to a non-NULL value. Fix this issue by explicitly checking if the repository is set and if it is not, fall back to a default value of GIT_DIFF_FIND_RENAMES.
* pool: Simplify implementationVicent Marti2015-10-281-3/+3
|
* stash: save the workdir file when deleted in indexEdward Thomson2015-06-231-11/+11
| | | | | | | | | | | | | | When stashing the workdir tree, examine the index as well. Using a mechanism similar to `git_diff_tree_to_workdir_with_index` allows us to determine that a file was added in the index and subsequently modified in the working directory. Without examining the index, we would erroneously believe that this file was untracked and fail to include it in the working directory tree. Use a slightly modified `git_diff_tree_to_workdir_with_index` in order to avoid some of the behavior custom to `git diff`. In particular, be sure to include the working directory side of a file when it was deleted in the index.
* git_diff__merge: allow pluggable diff mergesEdward Thomson2015-06-231-3/+9
|
* diff_tform: remove reversed copy of delta mergerEdward Thomson2015-06-231-46/+7
| | | | | Drop `git_diff__merge_like_cgit_reversed`, since it's a copy and paste mess of slightly incompatible changes.
* Explicitly handle GIT_DELTA_CONFLICTED in git_diff_merge()Pierre-Olivier Latour2015-06-221-0/+11
| | | | | This fixes a bug where if a file was in conflicted state in either diff, it would not always remain in conflicted state in the merged diff.
* Fixed handling of GIT_DELTA_CONFLICTED in git_diff_find_similar()Pierre-Olivier Latour2015-06-101-4/+4
| | | | | git_diff_find_similar() now ignores git_diff_delta records with a status of GIT_DELTA_CONFLICTED, which fixes a crash due to assert() being hit.
* Make sure to also update delta->nfiles when merging diffsPierre-Olivier Latour2015-03-301-2/+8
| | | | | | | When diffs are generated, the value for the 'nfiles' field of 'git_diff_delta' will be consistent with the value in the 'status' field. Merging diffs can modify the 'status' field of some deltas and the 'nfiles' field needs to be updated accordingly.
* Plug a few leaksCarlos Martín Nieto2015-03-041-1/+3
|
* Make our overflow check look more like gcc/clang'sEdward Thomson2015-02-131-2/+3
| | | | | | | | | Make our overflow checking look more like gcc and clang's, so that we can substitute it out with the compiler instrinsics on platforms that support it. This means dropping the ability to pass `NULL` as an out parameter. As a result, the macros also get updated to reflect this as well.
* allocations: test for overflow of requested sizeEdward Thomson2015-02-121-0/+1
| | | | | Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
* Added GIT_HASHSIG_ALLOW_SMALL_FILES to allow computing signatures for small ↵Pierre-Olivier Latour2015-01-141-22/+15
| | | | | | | | | | | | | files The implementation of the hashsig API disallows computing a signature on small files containing only a few lines. This new flag disables this behavior. git_diff_find_similar() sets this flag by default which means that rename / copy detection of small files will now work. This in turn affects the behavior of the git_status and git_blame APIs which will now detect rename of small files assuming the right options are passed.
* Removed some useless variable assignmentsPierre-Olivier Latour2014-10-271-2/+0
|
* hashsig: Export as a `sys` headervmg/hashsigVicent Marti2014-10-011-1/+1
|
* Start adding GIT_DELTA_UNREADABLE and GIT_STATUS_WT_UNREADABLE.Alan Rogers2014-05-201-1/+3
|
* Add build option for diff internal statisticsRussell Belfer2014-05-021-4/+4
|
* Use a portable castBen Straub2014-02-241-2/+2
|
* Avoid casting warningBen Straub2014-02-241-2/+2
|
* diff: rename the file's 'oid' to 'id'Carlos Martín Nieto2014-01-251-14/+14
| | | | In the same vein as the previous commits in this series.
* Sometimes a zero byte file is just a zero byte fileEdward Thomson2014-01-221-1/+1
| | | | Don't go to the ODB to resolve zero byte files in the workdir
* Cleanups, renames, and leak fixesRussell Belfer2013-12-121-2/+2
| | | | | | | | | This renames git_vector_free_all to the better git_vector_free_deep and also contains a couple of memory leak fixes based on valgrind checks. The fixes are specifically: failure to free global dir path variables when not compiled with threading on and failure to free filters from the filter registry that had not be initialized fully.
* Fix up some valgrind leaks and warningsRussell Belfer2013-12-111-15/+14
|
* Add git_vector_free_allRussell Belfer2013-12-111-6/+2
| | | | | | There are a lot of places that we call git__free on each item in a vector and then call git_vector_free on the vector itself. This just wraps that up into one convenient helper function.
* Add config read fns with controlled error behaviorRussell Belfer2013-12-111-20/+15
| | | | | | | | | | | | | | | | | | | | | | | | This adds `git_config__lookup_entry` which will look up a key in a config and return either the entry or NULL if the key was not present. Optionally, it can either suppress all errors or can return them (although not finding the key is not an error for this function). Unlike other accessors, this does not normalize the config key string, so it must only be used when the key is known to be in normalized form (i.e. all lower-case before the first dot and after the last dot, with no invalid characters). This also adds three high-level helper functions to look up config values with no errors and a fallback value. The three functions are for string, bool, and int values, and will resort to the fallback value for any error that arises. They are: * `git_config__get_string_force` * `git_config__get_bool_force` * `git_config__get_int_force` None of them normalize the config `key` either, so they can only be used for internal cases where the key is known to be in normal format.
* Check version earlierBen Straub2013-12-111-1/+2
|
* Don't clobber whitespace settingsBen Straub2013-12-061-5/+5
|
* Don't use weird return codesBen Straub2013-12-051-3/+8
|
* Implement GIT_DIFF_FIND_BY_CONFIGBen Straub2013-12-051-11/+17
|
* GIT_DIFF_FIND_REMOVE_UNMODIFIED sounds betterRussell Belfer2013-12-021-1/+1
|
* Add GIT_DIFF_FIND_DELETE_UNMODIFIED flagRussell Belfer2013-12-021-0/+2
| | | | | | | | | | When doing copy detection, it is often necessary to include UNMODIFIED records in the git_diff so they are available as source records for GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED. Yet in the final diff, often you will not want to have these UNMODIFIED records. This adds a flag which marks these UNMODIFIED records for deletion from the diff list so they will be removed after the rename detect phase is over.
* Fix bug making split deltas a COPIED targetsRussell Belfer2013-12-021-16/+30
| | | | | | | | When FIND_COPIES is used in combination with BREAK_REWRITES for rename detection, there was a bug where the split MODIFIED delta was only used as a target for RENAME records and not for COPIED records. This fixes that, converting the split into a pair of DELETED and COPIED deltas when that circumstance arises.
* More tests and fixed for merging reversed diffsRussell Belfer2013-11-011-14/+43
| | | | | | There were a lot more cases to deal with to make sure that our merged (i.e. workdir-to-tree-to-index) diffs were matching the output of core Git.
* Fix some of the glaring errors in GIT_DIFF_REVERSERussell Belfer2013-11-011-14/+24
| | | | | | | | | | | These changes fix the basic problem with GIT_DIFF_REVERSE being broken for text diffs. The reversed diff entries were getting added to the git_diff correctly, but some of the metadata was kept incorrectly in a way that prevented the text diffs from being generated correctly. Once I fixed that, it became clear that it was not possible to merge reversed diffs correctly. This has a first pass at fixing that problem. We probably need more tests to make sure that is really fixed thoroughly.
* Tweak to git_diff_delta structure for nfilesRussell Belfer2013-10-211-20/+27
| | | | | | While the base git_diff_delta structure always contains two files, when we introduce conflict data, it will be helpful to have an indicator when an additional file is involved.
* Diff API cleanupRussell Belfer2013-10-151-6/+6
| | | | | | | | This lays groundwork for separating formatting options from diff creation options. This groups the formatting flags separately from the diff list creation flags and reorders the options. This also tweaks some APIs to further separate code that uses patches from code that just looks at git_diffs.
* Rename diff objects and split patch.hRussell Belfer2013-10-111-11/+11
| | | | | | 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 #1804 from ethomson/rewritesVicent Martí2013-09-031-1/+5
|\ | | | | Minor changes for rewrites
| * Split rewrites, status doesn't return rewritesEdward Thomson2013-08-281-1/+5
| | | | | | | | | | | | | | | | Ensure that we apply splits to rewrites, even if we're not interested in examining it closely for rename/copy detection. In keeping with core git, status should not display rewrites, it should simply show files as "modified".
* | Trying to fix Win32 warningsRussell Belfer2013-08-221-3/+3
|/
* Update rename src map for any split srcRussell Belfer2013-08-041-1/+6
| | | | | | | | | When using a rename source that is actually a to-be-split record, we have to update the best-fit mapping data in both the case where the target is also a split record and the case where the target is a simple added record. Before this commit, we were only doing the update when the target was itself a split record (and even in that case, the test was slightly wrong).
* Major rename detection changesRussell Belfer2013-07-311-91/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After doing further profiling, I found that a lot of time was being spent attempting to insert hashes into the file hash signature when using the rolling hash because the rolling hash approach generates a hash per byte of the file instead of one per run/line of data. To optimize this, I decided to convert back to a run-based file signature algorithm which would be more like core Git. After changing this, a number of the existing tests started to fail. In some cases, this appears to have been because the test was coded to be too specific to the particular results of the file similarity metric and in some cases there appear to have been bugs in the core rename detection code where only by the coincidence of the file similarity scoring were the expected results being generated. This renames all the variables in the core rename detection code to be more consistent and hopefully easier to follow which made it a bit easier to reason about the behavior of that code and fix the problems that I was seeing. I think it's in better shape now. There are a couple of tests now that attempt to stress test the rename detection code and they are quite slow. Most of the time is spent setting up the test data on disk and in the index. When we roll out performance improvements for index insertion, it should also speed up these tests I hope.
* Fix rename detection to use actual blob sizeRussell Belfer2013-07-251-1/+7
| | | | | | | | | | | | | | | | | | The size data in the index may not reflect the actual size of the blob data from the ODB when content filtering comes into play. This commit fixes rename detection to use the actual blob size when calculating data signatures instead of the value from the index. Because of a misunderstanding on my part, I first converted the git_index_add_bypath API to use the post-filtered blob data size in creating the index entry. I backed that change out, but I kept the overall refactoring of that routine and the new internal git_blob__create_from_paths API because it eliminates an extra stat() call from the code that adds a file to the index. The existing tests actually cover this code path, at least when running on Windows, so at this point I'm not adding new tests to cover the changes.
* Make rename detection file size fix betterRussell Belfer2013-07-241-58/+58
| | | | | | | | 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.
* Fix rename detection for tree-to-tree diffsRussell Belfer2013-07-241-47/+98
| | | | | | | | | | | | The performance improvements I introduced for rename detection were not able to run successfully for tree-to-tree diffs because the blob size was not known early enough and so the file signature always had to be calculated nonetheless. This change separates loading blobs into memory from calculating the signature. I can't avoid having to load the large blobs into memory, but by moving it forward, I'm able to avoid the signature calculation if the blob won't come into play for renames.
* Fix incorrect commentRussell Belfer2013-07-241-1/+1
|
* Don't check rename if file size difference is hugeRussell Belfer2013-07-241-0/+9
|
* don't include ignored as rename candidatesEdward Thomson2013-07-171-1/+3
|
* Fix compilation warningsnulltoken2013-06-291-1/+1
|
* Fix rename looped reference issuesRussell Belfer2013-06-181-106/+145
| | | | | | | This makes the diff rename tracking code more careful about the order in which it processes renames and more thorough in updating the mapping of correct renames when an earlier rename update alters the index of a later matched pair.