summaryrefslogtreecommitdiff
path: root/src/commit.h
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2010-07-07 14:56:05 +0200
committerVicent Marti <tanoku@gmail.com>2010-07-15 23:40:52 +0200
commit52f2390b4308fe51ecceecbc35a87bf6e74e9aa8 (patch)
tree15595ebcc29767ee05eb33adb216fc2e92af85f4 /src/commit.h
parent225fe21522a98075bdc18dae90ce459f797ac366 (diff)
downloadlibgit2-52f2390b4308fe51ecceecbc35a87bf6e74e9aa8.tar.gz
Add external API to access detailed commit attributes
The following new external methods have been added: GIT_EXTERN(const char *) git_commit_message_short(git_commit *commit); GIT_EXTERN(const char *) git_commit_message(git_commit *commit); GIT_EXTERN(time_t) git_commit_time(git_commit *commit); GIT_EXTERN(const git_commit_person *) git_commit_committer(git_commit *commit); GIT_EXTERN(const git_commit_person *) git_commit_author(git_commit *commit); GIT_EXTERN(const git_tree *) git_commit_tree(git_commit *commit); A new structure, git_commit_person has been added to represent a commit's author or committer. The parsing of a commit has been split in two phases. When adding a commit to the revision pool: - the commit's ODB object is opened - its raw contents are parsed for commit TIME, PARENTS and TREE (the minimal amount of data required to traverse the pool) - the commit's ODB object is closed When querying for extended information on a commit: - the commit's ODB object is reopened - its raw contents are parsed for the requested information - the commit's ODB object remains open to handle additional queries New unit tests have been added for the new functionality: In t0401-parse: parse_person_test In t0402-details: query_details_test Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/commit.h')
-rw-r--r--src/commit.h27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/commit.h b/src/commit.h
index 524570f2c..36fd65cf2 100644
--- a/src/commit.h
+++ b/src/commit.h
@@ -23,31 +23,46 @@ struct git_commit_list {
typedef struct git_commit_list git_commit_list;
typedef struct git_commit_node git_commit_node;
+#define GIT_COMMIT_TREE (1 << 1)
+#define GIT_COMMIT_PARENTS (1 << 2)
+#define GIT_COMMIT_AUTHOR (1 << 3)
+#define GIT_COMMIT_COMMITTER (1 << 4)
+#define GIT_COMMIT_TIME (1 << 5)
+#define GIT_COMMIT_MESSAGE (1 << 6)
+#define GIT_COMMIT_MESSAGE_SHORT (1 << 7)
+#define GIT_COMMIT_FOOTERS (1 << 8)
struct git_commit {
git_revpool_object object;
+ git_obj odb_object;
time_t commit_time;
git_commit_list parents;
git_tree *tree;
+ git_commit_person *author;
+ git_commit_person *committer;
+
+ char *message;
+ char *message_short;
unsigned short in_degree;
- unsigned parsed:1,
+ unsigned basic_parse:1,
+ odb_open:1,
seen:1,
uninteresting:1,
topo_delay:1,
- flags:26;
+ flags:25;
};
void git_commit__free(git_commit *c);
+int git_commit__parse(git_commit *commit, unsigned int flags, int close_odb);
+int git_commit__parse_basic(git_commit *commit);
int git_commit__parse_oid(git_oid *oid, char **buffer_out, const char *buffer_end, const char *header);
-int git_commit__parse_buffer(git_commit *commit, void *data, size_t len);
-int git_commit__parse_time(time_t *commit_time, char *buffer, const char *buffer_end);
+int git_commit__parse_buffer(git_commit *commit, void *data, size_t len, unsigned int parse_flags);
+int git_commit__parse_person(git_commit_person *person, char **buffer_out, const char *buffer_end, const char *header);
void git_commit__mark_uninteresting(git_commit *commit);
-int git_commit_parse_existing(git_commit *commit);
-
int git_commit_list_push_back(git_commit_list *list, git_commit *commit);
int git_commit_list_push_front(git_commit_list *list, git_commit *commit);