summaryrefslogtreecommitdiff
path: root/src/diff_tform.c
Commit message (Collapse)AuthorAgeFilesLines
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-10/+10
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* diff: assert that we're passed a valid git_diff objectEtienne Samson2019-01-041-0/+2
| | | CID 1386176, 1386177, 1388219
* object_type: use new enumeration namesethomson/index_fixesEdward Thomson2018-12-011-1/+1
| | | | Use the new object_type enumeration names within the codebase.
* diff: fix OOM on AIX when finding similar deltas in empty diffPatrick Steinhardt2018-08-091-1/+1
| | | | | | | | | | | | | | The function `git_diff_find_similar` keeps a function of cache similarity metrics signatures, whose size depends on the number of deltas passed in via the `diff` parameter. In case where the diff is empty and thus doesn't have any deltas at all, we may end up allocating this cache via a call to `git__calloc(0, sizeof(void *))`. At least on AIX, allocating 0 bytes will result in a `NULL` pointer being returned, which causes us to erroneously return an OOM error. Fix this situation by simply returning early in case where we are being passed an empty diff, as we cannot find any similarities in that case anyway.
* Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-101-1/+1
|
* diff_tform: fix rename detection with rewrite/delete pairPatrick Steinhardt2018-02-201-1/+3
| | | | | | | | | | | | | | | | | | | | | A rewritten file can either be classified as a modification of its contents or of a delete of the complete file followed by an addition of the new content. This distinction becomes important when we want to detect renames for rewrites. Given a scenario where a file "a" has been deleted and another file "b" has been renamed to "a", this should be detected as a deletion of "a" followed by a rename of "a" -> "b". Thus, splitting of the original rewrite into a delete/add pair is important here. This splitting is represented by a flag we can set at the current delta. While the flag is already being set in case we want to break rewrites, we do not do so in case where the `GIT_DIFF_FIND_RENAMES_FROM_REWRITES` flag is set. This can trigger an assert when we try to match the source and target deltas. Fix the issue by setting the `GIT_DIFF_FLAG__TO_SPLIT` flag at the delta when it is a rename target and `GIT_DIFF_FIND_RENAMES_FROM_REWRITES` is set.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* diff: don't do rename detection on submodulesethomson/submodule_renamesEdward Thomson2017-02-091-2/+2
|
* giterr_set: consistent error messagesEdward Thomson2016-12-291-1/+1
| | | | | | | | Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
* git_diff_generated: abstract generated diffsEdward Thomson2016-05-261-0/+1
|
* 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
|/