]>
Commit | Line | Data |
---|---|---|
d12299fe VM |
1 | #ifndef INCLUDE_git_object_h__ |
2 | #define INCLUDE_git_object_h__ | |
3 | ||
4 | #include "common.h" | |
5 | #include "types.h" | |
6 | #include "oid.h" | |
7 | ||
8 | /** | |
9 | * @file git/object.h | |
10 | * @brief Git revision object management routines | |
11 | * @defgroup git_object Git revision object management routines | |
12 | * @ingroup Git | |
13 | * @{ | |
14 | */ | |
15 | GIT_BEGIN_DECL | |
16 | ||
17 | /** | |
18 | * Write back an object to disk. | |
19 | * | |
20 | * The object will be written to its corresponding | |
21 | * repository. | |
22 | * | |
23 | * If the object has no changes since it was first | |
24 | * read from the repository, no actions will take place. | |
25 | * | |
26 | * If the object has been modified since it was read from | |
27 | * the repository, or it has been created from scratch | |
28 | * in memory, it will be written to the repository and | |
29 | * its SHA1 ID will be updated accordingly. | |
30 | * | |
31 | * @param object Git object to write back | |
32 | * @return 0 on success; otherwise an error code | |
33 | */ | |
34 | GIT_EXTERN(int) git_object_write(git_object *object); | |
35 | ||
36 | /** | |
37 | * Get the id (SHA1) of a repository object | |
38 | * | |
39 | * In-memory objects created by git_object_new() do not | |
40 | * have a SHA1 ID until they are written on a repository. | |
41 | * | |
42 | * @param obj the repository object | |
43 | * @return the SHA1 id | |
44 | */ | |
45 | GIT_EXTERN(const git_oid *) git_object_id(git_object *obj); | |
46 | ||
47 | /** | |
48 | * Get the object type of an object | |
49 | * | |
50 | * @param obj the repository object | |
51 | * @return the object's type | |
52 | */ | |
53 | GIT_EXTERN(git_otype) git_object_type(git_object *obj); | |
54 | ||
55 | /** | |
56 | * Get the repository that owns this object | |
57 | * | |
58 | * @param obj the object | |
59 | * @return the repository who owns this object | |
60 | */ | |
61 | GIT_EXTERN(git_repository *) git_object_owner(git_object *obj); | |
62 | ||
63 | /** | |
64 | * Free a reference to one of the objects in the repository. | |
65 | * | |
66 | * Repository objects are managed automatically by the library, | |
67 | * but this method can be used to force freeing one of the | |
68 | * objects. | |
69 | * | |
70 | * Careful: freeing objects in the middle of a repository | |
71 | * traversal will most likely cause errors. | |
72 | * | |
73 | * @param object the object to free | |
74 | */ | |
75 | GIT_EXTERN(void) git_object_free(git_object *object); | |
76 | ||
77 | /** | |
78 | * Convert an object type to it's string representation. | |
79 | * | |
80 | * The result is a pointer to a string in static memory and | |
81 | * should not be free()'ed. | |
82 | * | |
83 | * @param type object type to convert. | |
84 | * @return the corresponding string representation. | |
85 | */ | |
86 | GIT_EXTERN(const char *) git_object_type2string(git_otype type); | |
87 | ||
88 | /** | |
89 | * Convert a string object type representation to it's git_otype. | |
90 | * | |
91 | * @param str the string to convert. | |
92 | * @return the corresponding git_otype. | |
93 | */ | |
94 | GIT_EXTERN(git_otype) git_object_string2type(const char *str); | |
95 | ||
96 | /** | |
97 | * Determine if the given git_otype is a valid loose object type. | |
98 | * | |
99 | * @param type object type to test. | |
100 | * @return true if the type represents a valid loose object type, | |
101 | * false otherwise. | |
102 | */ | |
103 | GIT_EXTERN(int) git_object_typeisloose(git_otype type); | |
104 | ||
105 | /** @} */ | |
106 | GIT_END_DECL | |
107 | ||
108 | #endif |