summaryrefslogtreecommitdiff
path: root/src/diff.c
Commit message (Collapse)AuthorAgeFilesLines
* Horrible fix for #3173.Arthur Schreiber2016-02-111-4/+4
|
* diff: include commit message when formatting patchPatrick Steinhardt2015-12-011-1/+10
| | | | | | When formatting a patch as email we do not include the commit's message in the formatted patch output. Implement this and add a test that verifies behavior.
* checkout: only consider nsecs when built that wayEdward Thomson2015-11-231-46/+3
| | | | | | | | When examining the working directory and determining whether it's up-to-date, only consider the nanoseconds in the index entry when built with `GIT_USE_NSEC`. This prevents us from believing that the working directory is always dirty when the index was originally written with a git client that uinderstands nsecs (like git 2.x).
* Merge pull request #3170 from CmdrMoozy/nsec_fixCarlos Martín Nieto2015-11-121-3/+32
|\ | | | | git_index_entry__init_from_stat: set nsec fields in entry stats
| * diff: refactor complex timestamp check into its own functionAxel Rasmussen2015-10-011-5/+27
| |
| * diff/index: respect USE_NSEC for racily clean file detectionAxel Rasmussen2015-09-181-2/+5
| |
| * cmake: add USE_NSEC, and only check nanosec m/ctime if enabledAxel Rasmussen2015-09-181-0/+4
| |
* | Add diff progress callback.Jason Haslam2015-11-021-2/+13
| |
* | pool: Simplify implementationVicent Marti2015-10-281-2/+3
| |
* | diff: ignore nsecs when diffingEdward Thomson2015-10-221-1/+3
|/ | | | | | | | | Although our index contains the literal time present in the index, we do not read nanoseconds from disk, and thus we should not use them in any comparisons, lest we always think our working directory is dirty. Guard this behind a `GIT_USE_NSECS` for future improvement.
* diff: check pathspec on non-filesEdward Thomson2015-09-121-8/+17
| | | | | | | | | | | | When we're not doing pathspec matching, we let the iterator handle file matching for us. However, we can only trust the iterator to return *files* that match the pattern, because the iterator must return directories that are not strictly in the pathlist, but that are the parents of files that match the pattern, so that diff can later recurse into them. Thus, diff must examine non-files explicitly before including them in the delta list.
* diff: use new iterator pathlist handlingEdward Thomson2015-08-301-14/+14
| | | | | | | | When using literal pathspecs in diff with `GIT_DIFF_DISABLE_PATHSPEC_MATCH` turn on the faster iterator pathlist handling. Updates iterator pathspecs to include directory prefixes (eg, `foo/`) for compatibility with `GIT_DIFF_DISABLE_PATHSPEC_MATCH`.
* Move filelist into the iterator handling itself.Edward Thomson2015-08-281-12/+34
|
* iterator: use an options struct instead of argsEdward Thomson2015-08-281-19/+25
|
* Added git_diff_index_to_index()Pierre-Olivier Latour2015-06-301-0/+25
|
* Only write index if updated when passing GIT_DIFF_UPDATE_INDEXPierre-Olivier Latour2015-06-261-2/+4
| | | | | | When diffing the index with the workdir and GIT_DIFF_UPDATE_INDEX has been passed, the previous implementation was always writing the index to disk even if it wasn't modified.
* Merge pull request #3222 from git-up/conflictedEdward Thomson2015-06-231-2/+4
|\ | | | | Fixed GIT_DELTA_CONFLICTED not returned in some cases
| * Fixed GIT_DELTA_CONFLICTED not returned in some casesPierre-Olivier Latour2015-06-231-2/+4
| | | | | | | | | | | | | | | | If an index entry for a file that is not in HEAD is in conflicted state, when diffing HEAD with the index, the status field of the corresponding git_diff_delta was incorrectly reported as GIT_DELTA_ADDED instead of GIT_DELTA_CONFLICTED. This was due to handle_unmatched_new_item() initially setting the status to GIT_DELTA_CONFLICTED but then overriding it later with GIT_DELTA_ADDED.
* | diff: check files with the same or newer timestampsCarlos Martín Nieto2015-06-221-3/+4
|/ | | | | | | | | | When a file on the workdir has the same or a newer timestamp than the index, we need to perform a full check of the contents, as the update of the file may have happened just after we wrote the index. The iterator changes are such that we can reach inside the workdir iterator from the diff, though it may be better to have an accessor instead of moving these structs into the header.
* diff: preserve original mode in the indexEdward Thomson2015-06-201-10/+14
| | | | | | | When updating the index during a diff, preserve the original mode, which prevents us from dropping the mode to what we have interpreted as on our system (eg, what the working directory claims it to be, which may be a lie on some systems.)
* Introduce `GIT_DIFF_FLAG_EXISTS`Edward Thomson2015-05-281-1/+6
| | | | | | | | | | Mark the `old_file` and `new_file` sides of a delta with a new bit, `GIT_DIFF_FLAG_EXISTS`, that introduces that a particular side of the delta exists in the diff. This is useful for indicating whether a working directory item exists or not, in the presence of a conflict. Diff users may have previously used DELETED to determine this information.
* diff: prettify `maybe_modified` a littleEdward Thomson2015-05-281-12/+15
|
* introduce `git_index_entry_is_conflict`Edward Thomson2015-05-281-7/+8
| | | | | | | | | It's not always obvious the mapping between stage level and conflict-ness. More importantly, this can lead otherwise sane people to write constructs like `if (!git_index_entry_stage(entry))`, which (while technically correct) is unreadable. Provide a nice method to help avoid such messy thinking.
* diff conflicts: don't include incorrect IDEdward Thomson2015-05-281-16/+21
| | | | | | | | | Since a diff entry only concerns a single entry, zero the information for the index side of a conflict. (The index entry would otherwise erroneously include the lowest-stage index entry - generally the ancestor of a conflict.) Test that during status, the index side of the conflict is empty.
* diff: for conflicts w/o workdir, blank nitem sideEdward Thomson2015-05-281-13/+26
| | | | | Make sure that we provide a blanked nitem side when the item does not exist in the working directory.
* diff/status: introduce conflictsEdward Thomson2015-05-281-13/+64
| | | | | | | | | | | When diffing against an index, return a new `GIT_DELTA_CONFLICTED` delta type for items that are conflicted. For a single file path, only one delta will be produced (despite the fact that there are multiple entries in the index). Index iterators now have the (optional) ability to return conflicts in the index. Prior to this change, they would be omitted, and callers (like diff) would omit conflicted index entries entirely.
* diff: wrap the iterator functionsEdward Thomson2015-05-281-25/+73
| | | | | | Wrap the iterator current / advance functions so that we can extend them, but also handle GIT_ITEROVER cases in the iterator funcs instead of the callers.
* checkout: break case-changes into delete/addEdward Thomson2015-05-041-0/+13
| | | | | | | When checking out with a case-insensitive working directory, we want to change the case of items in the working directory to reflect changes that occured in the checkout target. Diff now has an option to break case-changing renames into delete/add.
* Fixed GIT_DIFF_UPDATE_INDEX not being aware of executable bit changesPierre-Olivier Latour2015-04-151-1/+1
| | | | | | | | | | | | In the prior implementation, enabling GIT_DIFF_UPDATE_INDEX would overwrite entries in the index with the ones generated from scanning the working if the OID was the same. Because this OID comparison ignores file modes, this means an file in the workdir with only an exec bit difference with the one in the index would end up being overwritten, resulting in the exec bit being loss. There might be other related bugs but the fix of comparing OIDs and file modes should address them all.
* Removed unnecessary conditionPierre-Olivier Latour2015-04-151-9/+6
| | | | The variable noid is guaranteed to be zero at this point of the code path.
* Use git_oid_cpy() instead of memcpy()Pierre-Olivier Latour2015-04-151-1/+1
|
* Avoid retaining / releasing the index more than necessary when ↵Pierre-Olivier Latour2015-03-111-2/+1
| | | | GIT_DIFF_UPDATE_INDEX is enabled
* config: borrow refcounted referencescmn/config-borrow-entryCarlos Martín Nieto2015-03-031-1/+2
| | | | | | | | | | | | | | | This changes the get_entry() method to return a refcounted version of the config entry, which you have to free when you're done. This allows us to avoid freeing the memory in which the entry is stored on a refresh, which may happen at any time for a live config. For this reason, get_string() has been forbidden on live configs and a new function get_string_buf() has been added, which stores the string in a git_buf which the user then owns. The functions which parse the string value takea advantage of the borrowing to parse safely and then release the entry.
* git_filter_opt_t -> git_filter_flag_tEdward Thomson2015-02-191-1/+1
| | | | | For consistency with the rest of the library, where an opt is an options *structure*.
* 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/+2
| | | | | Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
* Added missing error handling pathJacques Germishuys2014-12-301-0/+1
|
* Plug leaksCarlos Martín Nieto2014-11-231-2/+1
| | | | Valgrind is now clean except for libssl and libgcrypt.
* iterator: submodules are determined by an index or treecmn/submodule-and-dirCarlos Martín Nieto2014-11-071-2/+7
| | | | | | | | | | | | We cannot know from looking at .gitmodules whether a directory is a submodule or not. We need the index or tree we are comparing against to tell us. Otherwise we have to assume the entry in .gitmodules is stale or otherwise invalid. Thus we pass the index of the repository into the workdir iterator, even if we do not want to compare against it. This follows what git does, which even for `git diff <tree>`, it will consider staged submodules as such.
* Changed context_lines and interhunk_lines to uint32_t to match struct ↵Pierre-Olivier Latour2014-10-271-1/+1
| | | | s_xdemitconf
* Merge remote-tracking branch 'origin/development' into ↵Alan Rogers2014-06-041-44/+15
|\ | | | | | | | | | | | | fix-git-status-list-new-unreadable-folder Conflicts: include/git2/diff.h
| * Increase use of config snapshotsrb/coverity-fixesRussell Belfer2014-05-131-9/+10
| | | | | | | | And decrease extra reload checks of config data.
| * Merge pull request #2328 from libgit2/rb/how-broken-can-ignores-beVicent Marti2014-05-131-35/+5
| |\ | | | | | | Improve checks for ignore containment
| | * Improve checks for ignore containmentrb/how-broken-can-ignores-beRussell Belfer2014-05-061-35/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The diff code was using an "ignored_prefix" directory to track if a parent directory was ignored that contained untracked files alongside tracked files. Unfortunately, when negative ignore rules were used for directories inside ignored parents, the wrong rules were applied to untracked files inside the negatively ignored child directories. This commit moves the logic for ignore containment into the workdir iterator (which is a better place for it), so the ignored-ness of a directory is contained in the frame stack during traversal. This allows a child directory to override with a negative ignore and yet still restore the ignored state of the parent when we traverse out of the child. Along with this, there are some problems with "directory only" ignore rules on container directories. Given "a/*" and "!a/b/c/" (where the second rule is a directory rule but the first rule is just a generic prefix rule), then the directory only constraint was having "a/b/c/d/file" match the first rule and not the second. This was fixed by having ignore directory-only rules test a rule against the prefix of a file with LEADINGDIR enabled. Lastly, spot checks for ignores using `git_ignore_path_is_ignored` were tested from the top directory down to the bottom to deal with the containment problem, but this is wrong. We have to test bottom to top so that negative subdirectory rules will be checked before parent ignore rules. This does change the behavior of some existing tests, but it seems only to bring us more in line with core Git, so I think those changes are acceptable.
* | | Implement GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKEDAlan Rogers2014-06-041-1/+4
| | |
* | | Don't need to duplicate this code.Alan Rogers2014-05-231-5/+1
| | |
* | | Return GIT_DELTA_UNREADABLE for a file with a mode changeAlan Rogers2014-05-221-0/+5
| | |
* | | Remove errant whitespace.Alan Rogers2014-05-211-1/+1
| | |
* | | Return GIT_FILEMODE_UNREADABLE for files that fail to stat.Alan Rogers2014-05-211-16/+15
| | |
* | | Start adding GIT_DELTA_UNREADABLE and GIT_STATUS_WT_UNREADABLE.Alan Rogers2014-05-201-10/+28
| | |