summaryrefslogtreecommitdiff
path: root/src/commit.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2010-12-18 02:10:25 +0200
committerVicent Marti <tanoku@gmail.com>2010-12-18 02:35:33 +0200
commit638c2ca4281589b73f2d402bb80775242045144a (patch)
tree8ad909bbf2612ddebe2078ed623f3fb4c9421cf1 /src/commit.c
parent5cccfa899926a93c12af8232c0c0d16c0c9c7ff2 (diff)
downloadlibgit2-638c2ca4281589b73f2d402bb80775242045144a.tar.gz
Rename 'git_person' to 'git_signature'
The new signature struct is public, and contains information about the timezone offset. Must be free'd manually by the user. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/commit.c')
-rw-r--r--src/commit.c71
1 files changed, 27 insertions, 44 deletions
diff --git a/src/commit.c b/src/commit.c
index d8a72a98a..019cefecf 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -26,11 +26,12 @@
#include "git2/common.h"
#include "git2/object.h"
#include "git2/repository.h"
+#include "git2/signature.h"
#include "common.h"
#include "commit.h"
#include "revwalk.h"
-#include "person.h"
+#include "signature.h"
#define COMMIT_BASIC_PARSE 0x0
#define COMMIT_FULL_PARSE 0x1
@@ -50,8 +51,8 @@ void git_commit__free(git_commit *commit)
{
clear_parents(commit);
- git_person__free(commit->author);
- git_person__free(commit->committer);
+ git_signature_free(commit->author);
+ git_signature_free(commit->committer);
free(commit->message);
free(commit->message_short);
@@ -82,12 +83,12 @@ int git_commit__writeback(git_commit *commit, git_odb_source *src)
if (commit->author == NULL)
return GIT_EMISSINGOBJDATA;
- git_person__write(src, "author", commit->author);
+ git_signature__write(src, "author", commit->author);
if (commit->committer == NULL)
return GIT_EMISSINGOBJDATA;
- git_person__write(src, "committer", commit->committer);
+ git_signature__write(src, "committer", commit->committer);
if (commit->message != NULL)
git__source_printf(src, "\n%s", commit->message);
@@ -137,10 +138,10 @@ int commit_parse_buffer(git_commit *commit, void *data, size_t len, unsigned int
if (parse_flags & COMMIT_FULL_PARSE) {
if (commit->author)
- git_person__free(commit->author);
+ git_signature_free(commit->author);
- commit->author = git__malloc(sizeof(git_person));
- if ((error = git_person__parse(commit->author, &buffer, buffer_end, "author ")) < GIT_SUCCESS)
+ commit->author = git__malloc(sizeof(git_signature));
+ if ((error = git_signature__parse(commit->author, &buffer, buffer_end, "author ")) < GIT_SUCCESS)
return error;
} else {
@@ -152,15 +153,12 @@ int commit_parse_buffer(git_commit *commit, void *data, size_t len, unsigned int
/* Always parse the committer; we need the commit time */
if (commit->committer)
- git_person__free(commit->committer);
+ git_signature_free(commit->committer);
- commit->committer = git__malloc(sizeof(git_person));
- if ((error = git_person__parse(commit->committer, &buffer, buffer_end, "committer ")) < GIT_SUCCESS)
+ commit->committer = git__malloc(sizeof(git_signature));
+ if ((error = git_signature__parse(commit->committer, &buffer, buffer_end, "committer ")) < GIT_SUCCESS)
return error;
- commit->commit_time = commit->committer->time;
- commit->commit_timezone_offset = commit->committer->timezone_offset;
-
/* parse commit message */
while (buffer <= buffer_end && *buffer == '\n')
buffer++;
@@ -232,35 +230,21 @@ int git_commit__parse_full(git_commit *commit)
git_commit__parse_full(commit);
GIT_COMMIT_GETTER(git_tree *, tree)
-GIT_COMMIT_GETTER(git_person *, author)
-GIT_COMMIT_GETTER(git_person *, committer)
+GIT_COMMIT_GETTER(git_signature *, author)
+GIT_COMMIT_GETTER(git_signature *, committer)
GIT_COMMIT_GETTER(char *, message)
GIT_COMMIT_GETTER(char *, message_short)
time_t git_commit_time(git_commit *commit)
{
- assert(commit);
-
- if (commit->commit_time)
- return commit->commit_time;
-
- if (!commit->object.in_memory)
- git_commit__parse_full(commit);
-
- return commit->commit_time;
+ assert(commit && commit->committer);
+ return commit->committer->when.time;
}
-int git_commit_timezone_offset(git_commit *commit)
+int git_commit_time_offset(git_commit *commit)
{
- assert(commit);
-
- if (commit->commit_timezone_offset)
- return commit->commit_timezone_offset;
-
- if (!commit->object.in_memory)
- git_commit__parse_full(commit);
-
- return commit->commit_timezone_offset;
+ assert(commit && commit->committer);
+ return commit->committer->when.offset;
}
unsigned int git_commit_parentcount(git_commit *commit)
@@ -283,25 +267,24 @@ void git_commit_set_tree(git_commit *commit, git_tree *tree)
commit->tree = tree;
}
-void git_commit_set_author(git_commit *commit, const char *name, const char *email, time_t time, int offset)
+void git_commit_set_author(git_commit *commit, const git_signature *author_sig)
{
- assert(commit && name && email);
+ assert(commit && author_sig);
commit->object.modified = 1;
CHECK_FULL_PARSE();
- git_person__free(commit->author);
- commit->author = git_person__new(name, email, time, offset);
+ git_signature_free(commit->author);
+ commit->author = git_signature_dup(author_sig);
}
-void git_commit_set_committer(git_commit *commit, const char *name, const char *email, time_t time, int offset)
+void git_commit_set_committer(git_commit *commit, const git_signature *committer_sig)
{
- assert(commit && name && email);
+ assert(commit && committer_sig);
commit->object.modified = 1;
CHECK_FULL_PARSE();
- git_person__free(commit->committer);
- commit->committer = git_person__new(name, email, time, offset);
- commit->commit_time = time;
+ git_signature_free(commit->committer);
+ commit->committer = git_signature_dup(committer_sig);
}
void git_commit_set_message(git_commit *commit, const char *message)