src/patch_generate.c


Log

Author Commit Date CI Message
Patrick Steinhardt 62a2fc06 2017-03-14T13:06:25 patch_generate: move `git_diff_foreach` to diff.c Now that the `git_diff_foreach` function does not depend on internals of the `git_patch_generated` structure anymore, we can easily move it to the actual diff code.
Patrick Steinhardt ace3508f 2017-03-14T10:37:47 patch_generate: fix `git_diff_foreach` only working with generated diffs The current logic of `git_diff_foreach` makes the assumption that all diffs passed in are actually derived from generated diffs. With these assumptions we try to derive the actual diff by inspecting either the working directory files or blobs of a repository. This obviously cannot work for diffs parsed from a file, where we do not necessarily have a repository at hand. Since the introduced split of parsed and generated patches, there are multiple functions which help us to handle patches generically, being indifferent from where they stem from. Use these functions and remove the old logic specific to generated patches. This allows re-using the same code for invoking the callbacks on the deltas.
Patrick Steinhardt 41019152 2017-03-14T10:01:56 patch_generate: remove duplicated logic Under the existing logic, we try to load patch contents differently, depending on whether the patch files stem from the working directory or not. But actually, the executed code paths are completely equal to each other -- so we were always the code despite the condition. Remove the condition altogether and conflate both code paths.
Etienne Samson b0014063 2016-12-26T22:13:35 patch: memory leak of patch.base.diff_opts.new|old_prefix
Edward Thomson 909d5494 2016-12-29T12:25:15 giterr_set: consistent error messages 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
Patrick Steinhardt 34b32053 2016-11-25T15:02:34 Fix potential use of uninitialized values
Edward Thomson adedac5a 2016-09-02T02:03:45 diff: treat binary patches with no data special 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.
Patrick Steinhardt 4b34f687 2016-09-01T15:14:25 patch_generate: only calculate binary diffs if requested When generating diffs for binary files, we load and decompress the blobs in order to generate the actual diff, which can be very costly. While we cannot avoid this for the case when we are called with the `GIT_DIFF_SHOW_BINARY` flag, we do not have to load the blobs in the case where this flag is not set, as the caller is expected to have no interest in the actual content of binary files. Fix the issue by only generating a binary diff when the caller is actually interested in the diff. As libgit2 uses heuristics to determine that a blob contains binary data by inspecting its size without loading from the ODB, this saves us quite some time when diffing in a repository with binary files.
Edward Thomson b859faa6 2016-08-23T23:38:39 Teach `git_patch_from_diff` about parsed diffs Ensure that `git_patch_from_diff` can return the patch for parsed diffs, not just generate a patch for a generated diff.
Edward Thomson 60e15ecd 2016-07-15T17:18:39 packbuilder: `size_t` all the things After 1cd65991, we were passing a pointer to an `unsigned long` to a function that now expected a pointer to a `size_t`. These types differ on 64-bit Windows, which means that we trash the stack. Use `size_t`s in the packbuilder to avoid this.
Edward Thomson 9be638ec 2016-04-19T15:12:18 git_diff_generated: abstract generated diffs
Edward Thomson 8d44f8b7 2015-11-24T15:19:59 patch: `patch_diff` -> `patch_generated`