summaryrefslogtreecommitdiff
path: root/src/diff_print.c
Commit message (Collapse)AuthorAgeFilesLines
* patch: correctly handle mode changes for renamesPatrick Steinhardt2020-03-261-7/+7
| | | | | | | | | | | When generating a patch for a renamed file whose mode bits have changed in addition to the rename, then we currently fail to parse the generated patch. Furthermore, when generating a diff we output mode bits after the similarity metric, which is different to how upstream git handles it. Fix both issues by adding another state transition that allows similarity indices after mode changes and by printing mode changes before the similarity index.
* diff_print: add support for GIT_DIFF_FORMAT_PATCH_ID.Gregory Herrero2019-11-191-1/+6
| | | | | | | Git is generating patch-id using a stripped down version of a patch where hunk header and index information are not present. Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com>
* diff_print: add a new 'print_index' flag when printing diff.Gregory Herrero2019-11-191-7/+14
| | | | | | | | | Add a new 'print_index' flag to let the caller decide whether or not 'index <oid>..<oid>' should be printed. Since patch id needs not to have index when hashing a patch, it will be useful soon. Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com>
* fileops: rename to "futils.h" to match function signaturesPatrick Steinhardt2019-07-201-1/+1
| | | | | | | | | Our file utils functions all have a "futils" prefix, e.g. `git_futils_touch`. One would thus naturally guess that their definitions and implementation would live in files "futils.h" and "futils.c", respectively, but in fact they live in "fileops.h". Rename the files to match expectations.
* configuration: cvar -> configmapPatrick Steinhardt2019-07-181-1/+1
| | | | | `cvar` is an unhelpful name. Refactor its usage to `configmap` for more clarity.
* oid: `is_zero` instead of `iszero`Edward Thomson2019-06-161-4/+4
| | | | | | The only function that is named `issomething` (without underscore) was `git_oid_iszero`. Rename it to `git_oid_is_zero` for consistency with the rest of the library.
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-9/+9
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-101-8/+8
|
* diff: Add missing GIT_DELTA_TYPECHANGE -> 'T' mapping.Erik van Zijst2018-04-051-0/+1
| | | | | This adds the 'T' status character to git_diff_status_char() for diff entries that change type.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-0/+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.
* giterr_set: consistent error messagesEdward Thomson2016-12-291-5/+5
| | | | | | | | 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
* diff: treat binary patches with no data specialethomson/diff-read-empty-binaryEdward Thomson2016-09-051-4/+6
| | | | | | When creating and printing diffs, deal with binary deltas that have binary data specially, versus diffs that have a binary file but lack the actual binary data.
* diff_print: change test for skipping binary printingEdward Thomson2016-09-021-3/+3
| | | | | | | | | | | | Instead of skipping printing a binary diff when there is no data, skip printing when we have a status of `UNMODIFIED`. This is more in-line with our internal data model and allows us to expand the notion of binary data. In the future, there may have no data because the files were unmodified (there was no data to produce) or it may have no data because there was no data given to us in a patch. We want to treat these cases separately.
* patch: show copy information for identical copiesEdward Thomson2016-06-251-11/+33
| | | | | | | When showing copy information because we are duplicating contents, for example, when performing a `diff --find-copies-harder -M100 -B100`, then show copy from/to lines in a patch, and do not show context. Ensure that we can also parse such patches.
* Introduce `git_diff_to_buf`Edward Thomson2016-05-261-0/+9
| | | | | Like `git_patch_to_buf`, provide a simple helper method that can print an entire diff directory to a `git_buf`.
* patch: `patch_diff` -> `patch_generated`Edward Thomson2016-05-261-1/+1
|
* patch: drop some warningsEdward Thomson2016-05-261-4/+3
|
* patch: use strlen to mean string lengthEdward Thomson2016-05-261-29/+27
| | | | | | | `oid_strlen` has meant one more than the length of the string. This is mighty confusing. Make it mean only the string length! Whomsoever needs to allocate a buffer to hold a string can null terminate it like normal.
* patch: show modes when only the mode has changedEdward Thomson2016-05-261-13/+21
|
* patch: quote filenames when necessaryEdward Thomson2016-05-261-33/+96
|
* patch: don't print some headers on pure renamesEdward Thomson2016-05-261-4/+13
|
* patch printing: include rename informationEdward Thomson2016-05-261-0/+23
|
* patch_parse: use names from `diff --git` headerEdward Thomson2016-05-261-1/+0
| | | | | | When a text file is added or deleted, use the file names from the `diff --git` header instead of the `---` or `+++` lines. This is for compatibility with git.
* diff: include oid length in deltasEdward Thomson2016-05-261-0/+27
| | | | | | Now that `git_diff_delta` data can be produced by reading patch file data, which may have an abbreviated oid, allow consumers to know that the id is abbreviated.
* patch: abstract patches into diff'ed and parsedEdward Thomson2016-05-261-96/+53
| | | | | | Patches can now come from a variety of sources - either internally generated (from diffing two commits) or as the results of parsing some external data.
* patch application: apply binary patchesEdward Thomson2016-05-261-0/+3
| | | | | | Handle the application of binary patches. Include tests that produce a binary patch (an in-memory `git_patch` object), then enusre that the patch applies correctly.
* diff_print: assert patch is non-NULLPatrick Steinhardt2016-02-231-1/+5
| | | | | | | | | | When invoking `diff_print_info_init_frompatch` it is obvious that the patch should be non-NULL. We explicitly check if the variable is set and continue afterwards, happily dereferencing the potential NULL-pointer. Fix this by instead asserting that patch is set. This also silences Coverity.
* Fix binary diffsGuille -bisho-2015-09-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git expects an empty line after the binary data: literal X ...binary data... <empty_line> The last literal block of the generated patches were not containing the required empty line. Example: diff --git a/binary_file b/binary_file index 3f1b3f9098131cfecea4a50ff8afab349ea66d22..86e5c1008b5ce635d3e3fffa4434c5eccd8f00b6 100644 GIT binary patch literal 8 Pc${NM&PdElPvrst3ey5{ literal 6 Nc${NM%g@i}0ssZ|0lokL diff --git a/binary_file2 b/binary_file2 index 31be99be19470da4af5b28b21e27896a2f2f9ee2..86e5c1008b5ce635d3e3fffa4434c5eccd8f00b6 100644 GIT binary patch literal 8 Pc${NM&PdElPvrst3ey5{ literal 13 Sc${NMEKbZyOexL+Qd|HZV+4u- git apply of that diff results in: error: corrupt binary patch at line 9: diff --git a/binary_file2 b/binary_file2 fatal: patch with only garbage at line 10 The proper formating is: diff --git a/binary_file b/binary_file index 3f1b3f9098131cfecea4a50ff8afab349ea66d22..86e5c1008b5ce635d3e3fffa4434c5eccd8f00b6 100644 GIT binary patch literal 8 Pc${NM&PdElPvrst3ey5{ literal 6 Nc${NM%g@i}0ssZ|0lokL diff --git a/binary_file2 b/binary_file2 index 31be99be19470da4af5b28b21e27896a2f2f9ee2..86e5c1008b5ce635d3e3fffa4434c5eccd8f00b6 100644 GIT binary patch literal 8 Pc${NM&PdElPvrst3ey5{ literal 13 Sc${NMEKbZyOexL+Qd|HZV+4u-
* diff: use size_t formatEdward Thomson2015-06-301-1/+1
|
* diff: fix leaks in diff printingCarlos Martín Nieto2015-06-261-0/+3
|
* Fixed Xcode 6.1 build warningsPierre-Olivier Latour2015-06-151-1/+0
|
* diff: introduce binary diff callbacksEdward Thomson2015-06-121-126/+154
| | | | | | | Introduce a new binary diff callback to provide the actual binary delta contents to callers. Create this data from the diff contents (instead of directly from the ODB) to support binary diffs including the workdir, not just things coming out of the ODB.
* Introduce git_buf_decode_base64Edward Thomson2014-08-151-1/+1
| | | | Decode base64-encoded text into a git_buf
* undo indentation change in diff_print.cfix-git-status-list-new-unreadable-folderAlan Rogers2014-07-231-9/+9
|
* Merge remote-tracking branch 'origin/development' into ↵Alan Rogers2014-06-041-30/+57
|\ | | | | | | | | | | | | fix-git-status-list-new-unreadable-folder Conflicts: include/git2/diff.h
| * minor cleanupsRussell Belfer2014-05-311-5/+5
| |
| * Clean up the handling of large binary diffsRussell Belfer2014-05-311-38/+48
| |
| * Fix printf format string from previous commitPhilip Kelley2014-05-171-1/+1
| |
| * print_binary_hunk: Treat types with respectPhilip Kelley2014-05-171-7/+24
| |
* | Start adding GIT_DELTA_UNREADABLE and GIT_STATUS_WT_UNREADABLE.Alan Rogers2014-05-201-8/+10
|/
* Be more careful with user-supplied buffersrb/fix-2333Russell Belfer2014-05-081-3/+3
| | | | | | | | | | | This adds in missing calls to `git_buf_sanitize` and fixes a number of places where `git_buf` APIs could inadvertently write NUL terminator bytes into invalid buffers. This also changes the behavior of `git_buf_sanitize` to NUL terminate a buffer if it can and of `git_buf_shorten` to do nothing if it can. Adds tests of filtering code with zeroed (i.e. unsanitized) buffer which was previously triggering a segfault.
* Merge pull request #2291 from ethomson/patch_binaryVicent Marti2014-04-231-6/+125
|\ | | | | patch: emit deflated binary patches (optionally)
| * patch: emit binary patches (optionally)Edward Thomson2014-04-221-6/+125
| |
* | Some doc and examples/diff.c changesRussell Belfer2014-04-221-1/+2
|/ | | | | | | | | | | | | | I was playing with "git diff-index" and wanted to be able to emulate that behavior a little more closely with the diff example. Also, I wanted to play with running `git_diff_tree_to_workdir` directly even though core Git doesn't exactly have the equivalent, so I added a command line option for that and tweaked some other things in the example code. This changes a minor output thing in that the "raw" print helper function will no longer add ellipses (...) if the OID is not actually abbreviated.
* Add public diff print helpersRussell Belfer2014-04-171-2/+26
| | | | | | | The usefulness of these helpers came up for me while debugging some of the iterator changes that I was making, so since they have also been requested (albeit indirectly) I thought I'd include them.
* diff: change id abbrev option's name to id_abbrevCarlos Martín Nieto2014-01-251-2/+2
| | | | | Same as the other commits in the series, we use 'id' when talking about thing rather than the datatype.
* diff: rename the file's 'oid' to 'id'Carlos Martín Nieto2014-01-251-6/+6
| | | | In the same vein as the previous commits in this series.
* Drop git_patch_to_strNicolas Hake2014-01-221-18/+0
| | | | | | | It's hard or even impossible to correctly free the string buffer allocated by git_patch_to_str in some circumstances. Drop the function so people have to use git_patch_to_buf instead - git_buf has a dedicated destructor.
* Expose patch serialization to git_bufNicolas Hake2014-01-221-2/+10
| | | | | | | | | | | Returning library-allocated strings from libgit2 works fine on Linux, but may cause problems on Windows because there is no one C Runtime that everything links against. With libgit2 not exposing its own allocator, freeing the string is a gamble. git_patch_to_str already serializes to a buffer, then returns the underlying memory. Expose the functionality directly, so callers can use the git_buf_free function to free the memory later.
* One more rename/cleanup for callback err functionsRussell Belfer2013-12-111-2/+2
|