Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commit: Add support for getting GPG signature data #766

Merged
merged 1 commit into from
Feb 6, 2018

Conversation

mark-adams
Copy link
Contributor

@mark-adams mark-adams commented Feb 1, 2018

This change adds a new Commit.gpg_signature property which returns a
tuple containing the GPG signature for a given commit and the bytes that
the signature was computed over. This is accomplished by calling
libgit2's git_commit_extract_signature() function.

@mark-adams mark-adams changed the title commit: Add support for getting gpg_signature data commit: Add support for getting GPG signature data Feb 1, 2018
@mark-adams mark-adams force-pushed the commit-gpg-signature branch 6 times, most recently from a37b3ca to 6e2bca5 Compare February 2, 2018 01:18
@mark-adams
Copy link
Contributor Author

Hi @jdavid! I believe this is ready for your review! Thanks! 😄

@mark-adams mark-adams force-pushed the commit-gpg-signature branch 4 times, most recently from d8d6c3a to f0a1cf7 Compare February 2, 2018 15:35
src/commit.c Outdated

if (err == GIT_ENOTFOUND){
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_BuildValue("OO", Py_None, Py_None);
Copy link
Member

Choose a reason for hiding this comment

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

Don't inc refcount of None, because the O already does that.
See https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue for the difference between O and N

Copy link
Contributor Author

@mark-adams mark-adams Feb 5, 2018

Choose a reason for hiding this comment

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

Good catch. I haven't developed too many C extensions for Python. Thanks for explaining O vs N!

Fixed!

src/commit.c Outdated
git_buf_free(&gpg_signature);
git_buf_free(&signed_data);

return Py_BuildValue("OO", py_gpg_signature, py_signed_data);
Copy link
Member

Choose a reason for hiding this comment

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

Here use NN instead of OO, because PyBytes_FromString returns a new reference, otherwise there will be a leak.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, didn't realize that OO did that (same as O vs N above.

Fixed!

This change adds a new Commit.gpg_signature property which returns a
tuple containing the GPG signature for a given commit and the bytes that
the signature was computed over. This is accomplished by calling
libgit2's git_commit_extract_signature() function.
@mark-adams
Copy link
Contributor Author

@jdavid Thanks for all the feedback. I think I've taken care of all of it if you want to take another look.

@jdavid jdavid merged commit 64f5259 into libgit2:master Feb 6, 2018
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.

2 participants