Commit 3a495c19bd280f5455047a9ac0e936f2c2f2f9a9

Vicent Marti 2014-09-10T18:32:51

Merge pull request #2558 from libgit2/cmn/signature-empty-email signature: don't allow empty emails

diff --git a/src/signature.c b/src/signature.c
index 2545b75..2a16b48 100644
--- a/src/signature.c
+++ b/src/signature.c
@@ -70,9 +70,9 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
 	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;
diff --git a/tests/commit/signature.c b/tests/commit/signature.c
index e9dcfab..41a74b9 100644
--- a/tests/commit/signature.c
+++ b/tests/commit/signature.c
@@ -56,8 +56,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_pass(try_build_signature("nulltoken", "", 1234567890, 60));
-	cl_git_pass(try_build_signature("nulltoken", "  ", 1234567890, 60));
+	cl_git_fail(try_build_signature("nulltoken", "", 1234567890, 60));
+	cl_git_fail(try_build_signature("nulltoken", "  ", 1234567890, 60));
 }
 
 void test_commit_signature__create_one_char(void)