vendor/libgit2/src/signature.c in rugged-0.21.4 vs vendor/libgit2/src/signature.c in rugged-0.22.0b1
- old
+ new
@@ -68,13 +68,13 @@
p->email = extract_trimmed(email, strlen(email));
if (p->name == NULL || p->email == NULL)
return -1; /* oom */
- if (p->name[0] == '\0') {
+ if (p->name[0] == '\0' || p->email[0] == '\0') {
git_signature_free(p);
- return signature_error("Signature cannot have an empty name");
+ return signature_error("Signature cannot have an empty name or email");
}
p->when.time = time;
p->when.offset = offset;
@@ -104,10 +104,34 @@
*dest = signature;
return 0;
}
+int git_signature__pdup(git_signature **dest, const git_signature *source, git_pool *pool)
+{
+ git_signature *signature;
+
+ if (source == NULL)
+ return 0;
+
+ signature = git_pool_mallocz(pool, sizeof(git_signature));
+ GITERR_CHECK_ALLOC(signature);
+
+ signature->name = git_pool_strdup(pool, source->name);
+ GITERR_CHECK_ALLOC(signature->name);
+
+ signature->email = git_pool_strdup(pool, source->email);
+ GITERR_CHECK_ALLOC(signature->email);
+
+ signature->when.time = source->when.time;
+ signature->when.offset = source->when.offset;
+
+ *dest = signature;
+
+ return 0;
+}
+
int git_signature_now(git_signature **sig_out, const char *name, const char *email)
{
time_t now;
time_t offset;
struct tm *utc_tm;
@@ -242,7 +266,18 @@
mins = offset % 60;
git_buf_printf(buf, "%s%s <%s> %u %c%02d%02d\n",
header ? header : "", sig->name, sig->email,
(unsigned)sig->when.time, sign, hours, mins);
+}
+
+bool git_signature__equal(const git_signature *one, const git_signature *two)
+{
+ assert(one && two);
+
+ return
+ git__strcmp(one->name, two->name) == 0 &&
+ git__strcmp(one->email, two->email) == 0 &&
+ one->when.time == two->when.time &&
+ one->when.offset == two->when.offset;
}