diff options
Diffstat (limited to 'src/git2')
| -rw-r--r-- | src/git2/commit.h | 18 | ||||
| -rw-r--r-- | src/git2/common.h | 10 | ||||
| -rw-r--r-- | src/git2/signature.h | 70 | ||||
| -rw-r--r-- | src/git2/tag.h | 9 | ||||
| -rw-r--r-- | src/git2/types.h | 13 |
5 files changed, 92 insertions, 28 deletions
diff --git a/src/git2/commit.h b/src/git2/commit.h index 54b0ed872..ccffec45f 100644 --- a/src/git2/commit.h +++ b/src/git2/commit.h @@ -104,14 +104,14 @@ GIT_EXTERN(int) git_commit_timezone_offset(git_commit *commit); * @param commit a previously loaded commit. * @return the committer of a commit */ -GIT_EXTERN(const git_person *) git_commit_committer(git_commit *commit); +GIT_EXTERN(const git_signature *) git_commit_committer(git_commit *commit); /** * Get the author of a commit. * @param commit a previously loaded commit. * @return the author of a commit */ -GIT_EXTERN(const git_person *) git_commit_author(git_commit *commit); +GIT_EXTERN(const git_signature *) git_commit_author(git_commit *commit); /** * Get the tree pointed to by a commit. @@ -154,22 +154,16 @@ GIT_EXTERN(void) git_commit_set_message(git_commit *commit, const char *message) /** * Set the committer of a commit * @param commit the commit object - * @param name name of the new committer - * @param email email of the new committer - * @param time time when the committer committed the commit - * @param offset committer positive or negative timezone offset, in minutes from UTC + * @param author_sig signature of the committer */ -GIT_EXTERN(void) git_commit_set_committer(git_commit *commit, const char *name, const char *email, time_t time, int offset); +GIT_EXTERN(void) git_commit_set_committer(git_commit *commit, const git_signature *committer_sig); /** * Set the author of a commit * @param commit the commit object - * @param name name of the new author - * @param email email of the new author - * @param time time when the author created the commit - * @param offset author positive or negative timezone offset, in minutes from UTC + * @param author_sig signature of the author */ -GIT_EXTERN(void) git_commit_set_author(git_commit *commit, const char *name, const char *email, time_t time, int offset); +GIT_EXTERN(void) git_commit_set_author(git_commit *commit, const git_signature *author_sig); /** * Set the tree which is pointed to by a commit diff --git a/src/git2/common.h b/src/git2/common.h index 9734074ca..9d014c038 100644 --- a/src/git2/common.h +++ b/src/git2/common.h @@ -134,17 +134,7 @@ /** The index file is not backed up by an existing repository */ #define GIT_EBAREINDEX (GIT_ERROR -14) - GIT_BEGIN_DECL - -/** Parsed representation of a person */ -typedef struct git_person git_person; - -const char *git_person_name(git_person *person); -const char *git_person_email(git_person *person); -time_t git_person_time(git_person *person); -int git_person_timezone_offset(git_person *person); - /** @} */ GIT_END_DECL #endif diff --git a/src/git2/signature.h b/src/git2/signature.h new file mode 100644 index 000000000..96275aa07 --- /dev/null +++ b/src/git2/signature.h @@ -0,0 +1,70 @@ +/* + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, + * as published by the Free Software Foundation. + * + * In addition to the permissions in the GNU General Public License, + * the authors give you unlimited permission to link the compiled + * version of this file into combinations with other programs, + * and to distribute those combinations without any restriction + * coming from the use of this file. (The General Public License + * restrictions do apply in other respects; for example, they cover + * modification of the file, and distribution when not linked into + * a combined executable.) + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +#ifndef INCLUDE_git_signature_h__ +#define INCLUDE_git_signature_h__ + +#include "common.h" +#include "types.h" + +/** + * @file git2/signature.h + * @brief Git signature creation + * @defgroup git_signature Git signature creation + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Create a new action signature. The signature must be freed + * manually or using git_signature_free + * + * @name name of the person + * @email email of the person + * @time time when the action happened + * @offset timezone offset in minutes for the time + * @return the new sig, NULl on out of memory + */ +GIT_EXTERN(git_signature *) git_signature_new(const char *name, const char *email, time_t time, int offset); + +/** + * Create a copy of an existing signature. + * + * All internal strings are also duplicated. + * @sig signature to duplicated + * @return a copy of sig, NULL on out of memory + */ +GIT_EXTERN(git_signature *) git_signature_dup(const git_signature *sig); + +/** + * Free an existing signature + * + * @sig signature to free + */ +GIT_EXTERN(void) git_signature_free(git_signature *sig); + +/** @} */ +GIT_END_DECL +#endif diff --git a/src/git2/tag.h b/src/git2/tag.h index d78235e81..8e29bc14a 100644 --- a/src/git2/tag.h +++ b/src/git2/tag.h @@ -96,7 +96,7 @@ GIT_EXTERN(const char *) git_tag_name(git_tag *t); * @param tag a previously loaded tag. * @return reference to the tag's author */ -GIT_EXTERN(const git_person *) git_tag_tagger(git_tag *t); +GIT_EXTERN(const git_signature *) git_tag_tagger(git_tag *t); /** * Get the message of a tag @@ -122,12 +122,9 @@ GIT_EXTERN(void) git_tag_set_name(git_tag *tag, const char *name); /** * Set the tagger of a tag * @param tag The tag to modify - * @param name the name of the new tagger - * @param email the email of the new tagger - * @param time the time when the tag was created - * @param offset tagger positive or negative timezone offset, in minutes from UTC + * @param tagger_sig signature of the tagging action */ -GIT_EXTERN(void) git_tag_set_tagger(git_tag *tag, const char *name, const char *email, time_t time, int offset); +GIT_EXTERN(void) git_tag_set_tagger(git_tag *tag, const git_signature *tagger_sig); /** * Set the message of a tag diff --git a/src/git2/types.h b/src/git2/types.h index 22fecef3f..99de33218 100644 --- a/src/git2/types.h +++ b/src/git2/types.h @@ -82,6 +82,19 @@ typedef struct git_tree git_tree; /** Memory representation of an index file. */ typedef struct git_index git_index; +/** Time in a signature */ +typedef struct git_time { + time_t time; /** time in seconds from epoch */ + int offset; /** timezone offset, in minutes */ +} git_time; + +/** An action signature (e.g. for committers, taggers, etc) */ +typedef struct git_signature { + char *name; /** full name of the author */ + char *email; /** email of the author */ + git_time when; /** time when the action happened */ +} git_signature; + /** @} */ GIT_END_DECL |
