Commit d483a911b89eaecb3af603efe2dceeb402cbf3ae

Vicent Marti 2011-07-08T18:31:05

signature: Fix optional header

diff --git a/src/commit.c b/src/commit.c
index c94ea76..f7c26a6 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -125,8 +125,8 @@ int git_commit_create(
 	git_odb_stream *stream;
 
 	message_length = strlen(message);
-	author_length = git_signature__write(&author_str, "author", author);
-	committer_length = git_signature__write(&committer_str, "committer", committer);
+	author_length = git_signature__write(&author_str, "author ", author);
+	committer_length = git_signature__write(&committer_str, "committer ", committer);
 
 	if (author_length < 0 || committer_length < 0)
 		return git__throw(GIT_EINVALIDARGS, "Cannot create commit. Failed to parse signature");
diff --git a/src/signature.c b/src/signature.c
index 964fa70..6d9569d 100644
--- a/src/signature.c
+++ b/src/signature.c
@@ -330,16 +330,10 @@ int git_signature__write(char **signature, const char *header, const git_signatu
 	hours = offset / 60;
 	mins = offset % 60;
 
-	if (header)
-		sig_buffer_len = snprintf(sig_buffer, sizeof(sig_buffer),
-				"%s %s <%s> %u %c%02d%02d\n",
-				header, sig->name, sig->email,
-				(unsigned)sig->when.time, sign, hours, mins);
-	else
-		sig_buffer_len = snprintf(sig_buffer, sizeof(sig_buffer),
-				"%s <%s> %u %c%02d%02d\n",
-				sig->name, sig->email,
-				(unsigned)sig->when.time, sign, hours, mins);
+	sig_buffer_len = snprintf(sig_buffer, sizeof(sig_buffer),
+			"%s%s <%s> %u %c%02d%02d\n",
+			header ? header : "", sig->name, sig->email,
+			(unsigned)sig->when.time, sign, hours, mins);
 
 	if (sig_buffer_len < 0 || (size_t)sig_buffer_len > sizeof(sig_buffer))
 		return GIT_ENOMEM;
diff --git a/src/tag.c b/src/tag.c
index f508fb7..39254a9 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -227,7 +227,7 @@ int git_tag_create(
 	}
 
 	type_str = git_object_type2string(git_object_type(target));
-	tagger_str_len = git_signature__write(&tagger_str, "tagger", tagger);
+	tagger_str_len = git_signature__write(&tagger_str, "tagger ", tagger);
 
 	type_str_len = strlen(type_str);
 	tag_name_len = strlen(tag_name);
@@ -413,4 +413,4 @@ int git_tag_list_match(git_strarray *tag_names, const char *pattern, git_reposit
 int git_tag_list(git_strarray *tag_names, git_repository *repo)
 {
 	return git_tag_list_match(tag_names, "", repo);
-}
\ No newline at end of file
+}