Skip to content

diff: complete support for git patchid#5306

Merged
pks-t merged 4 commits into
libgit2:masterfrom
herrerog:patchid
Nov 28, 2019
Merged

diff: complete support for git patchid#5306
pks-t merged 4 commits into
libgit2:masterfrom
herrerog:patchid

Conversation

@herrerog
Copy link
Copy Markdown
Contributor

Hi,
I noticed that git_diff_patchid wasn't returning a correct hash in some cases.
So I fixed those and added some tests for it.
Please let me know what you think.
Thanks!

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>
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>
When not shown binary data is added or removed in a patch, patch parser
is currently returning 'error -1 - corrupt git binary header at line 4'.
Fix it by correctly handling case where binary data is added/removed.

Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com>
@ethomson
Copy link
Copy Markdown
Member

Overall, this looks very nice to me. Thanks for the PR!

/cc @pks-t to look at some of the factoring, especially since patchid was his work originally and he has more familiarity.

Note that the build failures appear to be due to #5308.

Copy link
Copy Markdown
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your pull request! I like the changes quite a lot, they make the code simpler while still extending our support for patch IDs. I hate to say that my only issue is a stylistic one, so please forgive me, but please remove the braces around function invocations as they do not match our style. Other than that there was a needless call to git_buf_sanitize that I'd ask you to remove.

All in all, very well done and I'm happy to merge as soon as these two small issues are fixed!

Comment thread src/diff_print.c
Comment thread src/diff.c Outdated
Comment thread src/diff.c
Comment thread src/diff.c Outdated
Comment thread src/diff.c Outdated
Current implementation of patchid is not computing a correct patchid
when given a patch where, for example, a new file is added or removed.
Some more corner cases need to be handled to have same behavior as git
patch-id command.
Add some more tests to cover those corner cases.

Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com>
@herrerog
Copy link
Copy Markdown
Contributor Author

Thanks for your nice feedback, happy to help :)
I updated the branch.

@pks-t pks-t merged commit fb439c9 into libgit2:master Nov 28, 2019
@pks-t
Copy link
Copy Markdown
Member

pks-t commented Nov 28, 2019

Thanks a lot for this well-crafted pull request, @herrerog!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants