MCPcopy Create free account
hub / github.com/libgit2/pygit2 / Signature_init

Function Signature_init

src/signature.c:38–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36extern PyTypeObject SignatureType;
37
38int
39Signature_init(Signature *self, PyObject *args, PyObject *kwds)
40{
41 char *keywords[] = {"name", "email", "time", "offset", "encoding", NULL};
42 PyObject *py_name;
43 char *email, *encoding = NULL;
44 long long time = -1;
45 int offset = 0;
46
47 if (!PyArg_ParseTupleAndKeywords(
48 args, kwds, "Os|Liz", keywords,
49 &py_name, &email, &time, &offset, &encoding))
50 return -1;
51
52 PyObject *tname;
53 const char *name = pgit_borrow_encoding(
54 py_name, value_or_default(encoding, "utf-8"), NULL, &tname);
55 if (name == NULL)
56 return -1;
57
58 git_signature *signature;
59 int err = (time == -1) ? git_signature_now(&signature, name, email)
60 : git_signature_new(&signature, name, email, time, offset);
61 Py_DECREF(tname);
62 if (err < 0) {
63 Error_set(err);
64 return -1;
65 }
66
67 self->obj = NULL;
68 self->signature = signature;
69
70 if (encoding) {
71 self->encoding = strdup(encoding);
72 if (self->encoding == NULL) {
73 PyErr_NoMemory();
74 return -1;
75 }
76 }
77
78 return 0;
79}
80
81void
82Signature_dealloc(Signature *self)

Callers

nothing calls this directly

Calls 2

pgit_borrow_encodingFunction · 0.85
Error_setFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…