Skip to content

GPG signature support on commit object. #57

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

Closed
wants to merge 1 commit into from

Conversation

sugi
Copy link
Contributor

@sugi sugi commented May 6, 2012

Current version fails if any commit object has GPG signeture.

It works by just deleting lines from 433 to 440 of git/objects/commit.py.

I can't find documentation of git object format. But I tried to write support
GPG signature on commit object.

Please consider to merge.

Here is the way to reproduce problem:

sugi@vaj-k-334-sugi:~% mkdir signed-test
sugi@vaj-k-334-sugi:~% cd  signed-test
sugi@vaj-k-334-sugi:~/signed-tes/% git init
Initialized empty Git repository in /home/sugi/signed-test/.git/
git@vaj-k-334-sugi:~/signed-test% date > date.txt
sugi@vaj-k-334-sugi:~/signed-test% git add .
sugi@vaj-k-334-sugi:~/signed-test% git commit -S -m 'Test commit with GPG sig.'

You need a passphrase to unlock the secret key for
user: "Tatsuki Sugiura <sugi@nemui.org>"
1024-bit DSA key, ID 4502FDC2, created 2000-09-30

gpg: gpg-agent is not available in this session
[master (root-commit) afad9ad] Test commit with GPG sig.
 1 file changed, 1 insertion(+)
 create mode 100644 date.txt
sugi@vaj-k-334-sugi:~/signed-test% git cat-file commit HEAD
tree 9165a13698f6b211db3d9631958ef11e8d06d477
author Tatsuki Sugiura <sugi@nemui.org> 1336266773 +0900
committer Tatsuki Sugiura <sugi@nemui.org> 1336266773 +0900
gpgsig -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)

 iEYEABECAAYFAk+l0BUACgkQbK2FzkUC/cLR9wCeKUkjeA39+vy0T/TwJuqPhca3
 eNMAnRw0tDNAqIcM4HJnHvzCsu86dLGV
 =ZlAu
 -----END PGP SIGNATURE-----

Test commit with GPG sig.
sugi@vaj-k-334-sugi:~/signed-test% python    
Python 2.7.3rc2 (default, Apr 22 2012, 22:35:38) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import git
>>> git = git.Repo("/home/sugi/signed-test")
>>> git.commit()
<git.Commit "afad9ad7986c98784288ae71deb696d505cdfe5c">
>>> git.commit().author
afad9ad7986c98784288ae71deb696d505cdfe5c
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sugi/lib/python2.7/site-packages/gitdb-0.5.4-py2.7-linux-x86_64.egg/gitdb/util.py", line 238, in __getattr__
    self._set_cache_(attr)
  File "/home/sugi/lib/python2.7/site-packages/GitPython-0.3.2.RC1-py2.7.egg/git/objects/commit.py", line 133, in _set_cache_
    self._deserialize(StringIO(stream.read()))
  File "/home/sugi/lib/python2.7/site-packages/GitPython-0.3.2.RC1-py2.7.egg/git/objects/commit.py", line 444, in _deserialize
    self.author.name = self.author.name.decode(self.encoding) 
LookupError: unknown encoding: -----BEGIN PGP SIGNATURE-----
@Byron
Copy link
Member

Byron commented May 7, 2012

Hi Sugi,

Thanks for discovering and fixing the issue. It would be great if you could add a test to verify it truly works.

Thanks,
Sebastian

@sugi
Copy link
Contributor Author

sugi commented May 8, 2012

Thank you for your reply!

OK. I'd like to write test. But I need time.

@kisoku
Copy link

kisoku commented May 12, 2012

We've encountered the exact same issue where I work. Our fix is also identical, we're still in the process of testing the patch. +1 on this pull request.

@sugi
Copy link
Contributor Author

sugi commented Oct 7, 2013

I rewrite this patch and sent new pull request against current master as #124.
Please continue to review new one.

@sugi sugi closed this Oct 7, 2013
gak added a commit to gak/GitPython that referenced this pull request Dec 31, 2013
… applied to 0.3.

Without it, the following error happens:

LookupError: unknown encoding: -----BEGIN PGP SIGNATURE-----

I Couldn't cherry pick. Git went spaz. The original author is @sugi
and the commit is from sugi/GitPython:

8065d2a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants