]> git.proxmox.com Git - libgit2.git/blame - src/git_commit.h
Take the first stab at defining revision traversal
[libgit2.git] / src / git_commit.h
CommitLineData
06160502
SP
1/*
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or
5 * without modification, are permitted provided that the following
6 * conditions are met:
7 *
8 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials provided
14 * with the distribution.
15 *
16 * - Neither the name of the Git Development Community nor the
17 * names of its contributors may be used to endorse or promote
18 * products derived from this software without specific prior
19 * written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
26 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef INCLUDE_git_commit_h__
37#define INCLUDE_git_commit_h__
38
39#include "git_common.h"
40#include "git_oid.h"
41#include <time.h>
42
43/**
44 * @file git_commit.h
45 * @brief Git commit parsing, formatting routines
46 * @defgroup git_commit Git commit parsing, formatting routines
47 * @ingroup Git
48 * @{
49 */
50GIT_BEGIN_DECL
51
52/** Parsed representation of a commit object. */
53typedef struct git_commit_t git_commit_t;
54#ifdef GIT__PRIVATE
55struct git_commit_t {
56 git_oid_t id;
57 time_t commit_time;
58 unsigned parsed:1,
59 flags:26;
60};
61#endif
62
63/**
64 * Parse (or lookup) a commit from a revision pool.
65 * @param pool the pool to use when parsing/caching the commit.
66 * @param id identity of the commit to locate. If the object is
67 * an annotated tag it will be peeled back to the commit.
68 * @return the commit; NULL if the commit does not exist in the
69 * pool's git_odb_t, or if the commit is present but is
70 * too malformed to be parsed successfully.
71 */
72GIT_EXTERN(git_commit_t*) git_commit_parse(git_revp_t *pool, const git_oid_t *id);
73
74/**
75 * Get the id of a commit.
76 * @param commit a previously parsed commit.
77 * @return object identity for the commit.
78 */
79GIT_EXTERN(const git_oid_t*) git_commit_id(git_commit_t *commit);
80
81/**
82 * Get the application data address.
83 * @param commit a previously parsed commit.
84 * @return address of the application's data buffer.
85 * Applications should cast to something like
86 * 'struct mydata*' in order to access fields.
87 */
88GIT_EXTERN(void*) git_commit_appdata(git_commit_t *commit);
89
90/** @} */
91GIT_END_DECL
92#endif