mirror of
https://git.proxmox.com/git/libgit2
synced 2025-12-26 06:05:54 +00:00
signature: Lenient when dupping, strict when creating
This commit is contained in:
parent
86c6f74a79
commit
f0ab73720a
@ -66,10 +66,12 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
|
||||
p->name = extract_trimmed(name, strlen(name));
|
||||
p->email = extract_trimmed(email, strlen(email));
|
||||
|
||||
if (p->name == NULL || p->email == NULL ||
|
||||
p->name[0] == '\0' || p->email[0] == '\0') {
|
||||
if (p->name == NULL || p->email == NULL)
|
||||
return -1; /* oom */
|
||||
|
||||
if (p->name[0] == '\0') {
|
||||
git_signature_free(p);
|
||||
return signature_error("Empty name or email");
|
||||
return signature_error("Signature cannot have an empty name");
|
||||
}
|
||||
|
||||
p->when.time = time;
|
||||
@ -81,9 +83,16 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
|
||||
|
||||
git_signature *git_signature_dup(const git_signature *sig)
|
||||
{
|
||||
git_signature *new;
|
||||
if (git_signature_new(&new, sig->name, sig->email, sig->when.time, sig->when.offset) < 0)
|
||||
git_signature *new = git__calloc(1, sizeof(git_signature));
|
||||
|
||||
if (new == NULL)
|
||||
return NULL;
|
||||
|
||||
new->name = git__strdup(sig->name);
|
||||
new->email = git__strdup(sig->email);
|
||||
new->when.time = sig->when.time;
|
||||
new->when.offset = sig->when.offset;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
@ -54,8 +54,8 @@ void test_commit_signature__create_empties(void)
|
||||
|
||||
cl_git_fail(try_build_signature("", "emeric.fermas@gmail.com", 1234567890, 60));
|
||||
cl_git_fail(try_build_signature(" ", "emeric.fermas@gmail.com", 1234567890, 60));
|
||||
cl_git_fail(try_build_signature("nulltoken", "", 1234567890, 60));
|
||||
cl_git_fail(try_build_signature("nulltoken", " ", 1234567890, 60));
|
||||
cl_git_pass(try_build_signature("nulltoken", "", 1234567890, 60));
|
||||
cl_git_pass(try_build_signature("nulltoken", " ", 1234567890, 60));
|
||||
}
|
||||
|
||||
void test_commit_signature__create_one_char(void)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user