fix a bug introduced in 8a23597b#5295
Merged
Merged
Conversation
romkatv
referenced
this pull request
Nov 5, 2019
While the `DIFF_FROM_ITERATORS` does make it shorter to implement the various `git_diff_foo_to_bar` functions, it is a complex and unreadable beast that implicitly assumes certain local variable names. This is not something desirable to have at all and obstructs understanding and more importantly debugging the code by quite a bit. The `DIFF_FROM_ITERATORS` macro basically removed the burden of having to derive the options for both iterators from a pair of iterator flags and the diff options. This patch introduces a new function that does the that exact and refactors all callers to manage the iterators by themselves. As we potentially need to allocate a shared prefix for the iterator, we need to tell the caller to allocate that prefix as soon as the options aren't required anymore. Thus, the function has a `char **prefix` out pointer that will get set to the allocated string and subsequently be free'd by the caller. While this patch increases the line count, I personally deem this to an acceptable tradeoff for increased readbiblity.
pks-t
approved these changes
Nov 5, 2019
pks-t
left a comment
Member
There was a problem hiding this comment.
Thanks for this PR. I'm merging as the CI error is unrelated (badssl once again)
| (error = git_iterator_for_tree(&a, old_tree, &a_opts)) < 0 || | ||
| (error = git_iterator_for_index(&b, repo, index, &b_opts)) < 0 || | ||
| (error = git_diff__from_iterators(&diff, repo, a, b, opts) < 0)) | ||
| (error = git_diff__from_iterators(&diff, repo, a, b, opts)) < 0) |
Member
There was a problem hiding this comment.
Oops, yeah, that's an embarassing typo. The fix looks obviously correct to me, thanks a lot!
Member
|
Thanks @romkatv! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.