Return None for sha of in-memory objects.
Change-Id: Ieb1f332184bf747f4f8b12f12fec9e3570f74b10
This commit is contained in:
parent
1236c64a94
commit
3fa91b901d
8
pygit2.c
8
pygit2.c
@ -278,8 +278,14 @@ Object_get_type(Object *self, void *closure) {
|
||||
|
||||
static PyObject *
|
||||
Object_get_sha(Object *self, void *closure) {
|
||||
const git_oid *id;
|
||||
char hex[GIT_OID_HEXSZ];
|
||||
git_oid_fmt(hex, git_object_id(self->obj));
|
||||
|
||||
id = git_object_id(self->obj);
|
||||
if (!id)
|
||||
return Py_None;
|
||||
|
||||
git_oid_fmt(hex, id);
|
||||
return PyString_FromStringAndSize(hex, GIT_OID_HEXSZ);
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,7 @@ class CommitTest(utils.TestRepoTestCase):
|
||||
commit.committer = committer
|
||||
commit.author = author
|
||||
|
||||
self.assertEqual(None, commit.sha)
|
||||
self.assertEqual(pygit2.GIT_OBJ_COMMIT, commit.type)
|
||||
self.assertEqual(message, commit.message)
|
||||
# TODO: Uncomment when git_commit_set_message updates message_short.
|
||||
|
Loading…
x
Reference in New Issue
Block a user