summaryrefslogtreecommitdiff
path: root/src/diff_output.c
Commit message (Collapse)AuthorAgeFilesLines
* diff: Cleanup documentation and printf compatVicent Marti2012-09-061-4/+4
|
* Fix comments and a minor bugRussell Belfer2012-09-051-4/+3
| | | | | This adds better header comments and also fixes a bug in one of simple APIs that tells the number of lines in the current hunk.
* Diff iteratorsRussell Belfer2012-09-051-256/+760
| | | | | | | | | | | 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.
* Fix MSVC compilation warningsnulltoken2012-09-041-1/+1
|
* Working implementation of git_submodule_statusRussell Belfer2012-08-241-0/+19
| | | | | | | | | | | | | This is a big redesign of the git_submodule_status API and the implementation of the redesigned API. It also fixes a number of bugs that I found in other parts of the submodule API while writing the tests for the status part. This also fixes a couple of bugs in the iterators that had not been noticed before - one with iterating when there is a gitlink (i.e. separate-work-dir) and one where I was treating anything even vaguely submodule-like as a submodule, more aggressively than core git does.
* 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
|
* Update iterators for consistency across libraryRussell Belfer2012-08-031-44/+59
| | | | | | | | | | | | | | | | | This updates all the `foreach()` type functions across the library that take callbacks from the user to have a consistent behavior. The rules are: * A callback terminates the loop by returning any non-zero value * Once the callback returns non-zero, it will not be called again (i.e. the loop stops all iteration regardless of state) * If the callback returns non-zero, the parent fn returns GIT_EUSER * Although the parent returns GIT_EUSER, no error will be set in the library and `giterr_last()` will return NULL if called. This commit makes those changes across the library and adds tests for most of the iteration APIs to make sure that they follow the above rules.
* diff: make inter-hunk-context default value git-compliantyorah2012-07-021-1/+1
| | | | Default in git core is 0, not 3
* Minor fixes, cleanups, and clarificationsRussell Belfer2012-06-081-5/+6
| | | | | | | | | | | | | | | | | | | | | | | There are three actual changes in this commit: 1. When the trailing newline of a file is removed in a diff, the change will now be reported with `GIT_DIFF_LINE_DEL_EOFNL` passed to the callback. Previously, the `ADD_EOFNL` constant was given which was just an error in my understanding of when the various circumstances arose. `GIT_DIFF_LINE_ADD_EOFNL` is deprecated and should never be generated. A new newline is simply an `ADD`. 2. Rewrote the `diff_delta__merge_like_cgit` function that contains the core logic of the `git_diff_merge` implementation. The new version doesn't actually have significantly different behavior, but the logic should be much more obvious, I think. 3. Fixed a bug in `git_diff_merge` where it freed a string pool while some of the string data was still in use. This led to `git_diff_print_patch` accessing memory that had been freed. The rest of this commit contains improved documentation in `diff.h` to make the behavior and the equivalencies with core git clearer, and a bunch of new tests to cover the various cases, oh and a minor simplification of `examples/diff.c`.
* Fix filemode comparison in diffsRussell Belfer2012-06-081-3/+10
| | | | | | | | | | | | | | | File modes were both not being ignored properly on platforms where they should be ignored, nor be diffed consistently on platforms where they are supported. This change adds a number of diff and status filemode change tests. This also makes sure that filemode-only changes are included in the diff output when they occur and that filemode changes are ignored successfully when core.filemode is false. There is no code that automatically toggles core.filemode based on the capabilities of the current platform, so the user still needs to be careful in their .git/config file.
* misc: Fix warnings from PVS Studio trialVicent Martí2012-06-071-1/+1
|
* Fix checking for the presence of a flagGarrett Regier2012-05-271-1/+1
|
* global: Change parameter ordering in APIVicent Martí2012-05-181-1/+1
| | | | Consistency is good.
* Optimize away git_text_gather_stats in diffRussell Belfer2012-05-171-7/+2
| | | | | | | | GProf shows `git_text_gather_stats` as the most expensive call in large diffs. The function calculates a lot of information that is not actually used and does not do so in a optimal order. This introduces a tuned `git_buf_is_binary` function that executes the same algorithm in a fraction of the time.
* diff: fix the diffing of two identical blobsnulltoken2012-05-071-0/+8
|
* diff: make git_diff_blobs() able to detect binary blobsnulltoken2012-05-071-0/+28
|
* diff: fix the diffing of a concrete blob against a null onenulltoken2012-05-071-22/+20
|
* diff: When diffing two blobs, ensure the delta callback parameter is filled ↵nulltoken2012-05-071-2/+6
| | | | with relevant information
* diff: remove unused parameternulltoken2012-05-071-4/+1
|
* Support reading attributes from indexRussell Belfer2012-05-031-1/+1
| | | | | | | | | | | | | | Depending on the operation, we need to consider gitattributes in both the work dir and the index. This adds a parameter to all of the gitattributes related functions that allows user control of attribute reading behavior (i.e. prefer workdir, prefer index, only use index). This fix also covers allowing us to check attributes (and hence do diff and status) on bare repositories. This was a somewhat larger change that I hoped because it had to change the cache key used for gitattributes files.
* Merge branch 'new-error-handling' into developmentVicent Martí2012-05-021-111/+131
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .travis.yml include/git2/diff.h src/config_file.c src/diff.c src/diff_output.c src/mwindow.c src/path.c tests-clar/clar_helpers.c tests-clar/object/tree/frompath.c tests/t00-core.c tests/t03-objwrite.c tests/t08-tag.c tests/t10-refs.c tests/t12-repo.c tests/t18-status.c tests/test_helpers.c tests/test_main.c
| * Convert from strnlen to git_text_is_binaryRussell Belfer2012-05-021-4/+16
| | | | | | | | | | | | Since strnlen is not supported on all platforms and since we now have the shiny new git_text_is_binary in the filtering code, let's convert diff binary detection to use the new stuff.
| * Copy values to avoid strict aliasing warningRussell Belfer2012-05-021-1/+6
| | | | | | | | | | | | To make this code more resilient to future changes, we'll explicitly translate the libgit2 structure to the libxdiff structure.
| * Fix usage of "new" for fieldname in public headerRussell Belfer2012-05-021-79/+79
| | | | | | | | | | | | | | | | This should restore the ability to include libgit2 headers in C++ projects. Cherry picked 2de60205dfea2c4a422b2108a5e8605f97c2e895 from development into new-error-handling.
| * diff: provide more context to the consumer of the callbacksnulltoken2012-04-301-18/+17
| | | | | | | | Update the callback to provide some information related to the file change being processed and the range of the hunk, when applicable.
| * diff: fix generation of the header of a removal patchnulltoken2012-04-251-5/+15
| |
| * New status fixesRussell Belfer2012-03-221-2/+4
| | | | | | | | | | | | | | This adds support for roughly-right tracking of submodules (although it does not recurse into submodules to detect internal modifications a la core git), and it adds support for including unmodified files in diff iteration if requested.
| * Migrating diff to new error handlingRussell Belfer2012-03-061-89/+92
| | | | | | | | | | | | Ended up migrating a bunch of upstream functions as well including vector, attr_file, and odb in order to get this to work right.
| * error-handling: RepositoryVicent Martí2012-03-071-10/+13
| | | | | | | | | | | | | | | | This also includes droping `git_buf_lasterror` because it makes no sense in the new system. Note that in most of the places were it has been dropped, the code needs cleanup. I.e. GIT_ENOMEM is going away, so instead it should return a generic `-1` and obviously not throw anything.
* | diff_output: remove unused parameterschu2012-03-211-3/+0
| | | | | | | | Signed-off-by: schu <schu-github@schulog.org>
* | Rename git_oid_to_string to git_oid_tostrAuthmillenon2012-03-061-2/+2
| | | | | | | | | | To conform the naming scheme of git_oid_fromstr we should change the name of git_oid_to_string to git_oid_tostr.
* | Convert from strnlen to git_text_is_binaryRussell Belfer2012-03-051-4/+16
| | | | | | | | | | | | Since strnlen is not supported on all platforms and since we now have the shiny new git_text_is_binary in the filtering code, let's convert diff binary detection to use the new stuff.
* | Copy values to avoid strict aliasing warningRussell Belfer2012-03-051-1/+6
| | | | | | | | | | | | To make this code more resilient to future changes, we'll explicitly translate the libgit2 structure to the libxdiff structure.
* | Fix usage of "new" for fieldname in public headerRussell Belfer2012-03-041-77/+77
|/ | | | | This should restore the ability to include libgit2 headers in C++ projects.
* Fixes for merge of filters branchRussell Belfer2012-03-021-2/+2
|
* Revert GIT_STATUS constants to avoid issuesRussell Belfer2012-03-021-17/+17
| | | | | | | | | This reverts the changes to the GIT_STATUS constants and adds a new enumeration to describe the type of change in a git_diff_delta. I don't love this solution, but it should prevent strange errors from occurring for now. Eventually, I would like to unify the various status constants, but it needs a larger plan and I just wanted to eliminate this breakage quickly.
* Clean up GIT_UNUSED macros on all platformsRussell Belfer2012-03-021-6/+6
| | | | | | | | | | | | | | | | | | | It turns out that commit 31e9cfc4cbcaf1b38cdd3dbe3282a8f57e5366a5 did not fix the GIT_USUSED behavior on all platforms. This commit walks through and really cleans things up more thoroughly, getting rid of the unnecessary stuff. To remove the use of some GIT_UNUSED, I ended up adding a couple of new iterators for hashtables that allow you to iterator just over keys or just over values. In making this change, I found a bug in the clar tests (where we were doing *count++ but meant to do (*count)++ to increment the value). I fixed that but then found the test failing because it was not really using an empty repo. So, I took some of the code that I wrote for iterator testing and moved it to clar_helpers.c, then made use of that to make it easier to open fixtures on a per test basis even within a single test file.
* Update diff to use iteratorsRussell Belfer2012-03-021-0/+722
This is a major reorganization of the diff code. This changes the diff functions to use the iterators for traversing the content. This allowed a lot of code to be simplified. Also, this moved the functions relating to outputting a diff into a new file (diff_output.c). This includes a number of other changes - adding utility functions, extending iterators, etc. plus more tests for the diff code. This also takes the example diff.c program much further in terms of emulating git-diff command line options.