]>
Commit | Line | Data |
---|---|---|
f5918330 VM |
1 | /* |
2 | * This file is free software; you can redistribute it and/or modify | |
3 | * it under the terms of the GNU General Public License, version 2, | |
4 | * as published by the Free Software Foundation. | |
5 | * | |
6 | * In addition to the permissions in the GNU General Public License, | |
7 | * the authors give you unlimited permission to link the compiled | |
8 | * version of this file into combinations with other programs, | |
9 | * and to distribute those combinations without any restriction | |
10 | * coming from the use of this file. (The General Public License | |
11 | * restrictions do apply in other respects; for example, they cover | |
12 | * modification of the file, and distribution when not linked into | |
13 | * a combined executable.) | |
14 | * | |
15 | * This file is distributed in the hope that it will be useful, but | |
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | * General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License | |
21 | * along with this program; see the file COPYING. If not, write to | |
22 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, | |
23 | * Boston, MA 02110-1301, USA. | |
24 | */ | |
225fe215 VM |
25 | #ifndef INCLUDE_git_tree_h__ |
26 | #define INCLUDE_git_tree_h__ | |
27 | ||
28 | #include "common.h" | |
d12299fe | 29 | #include "types.h" |
225fe215 | 30 | #include "oid.h" |
5de079b8 | 31 | #include "object.h" |
225fe215 VM |
32 | |
33 | /** | |
f5918330 | 34 | * @file git2/tree.h |
225fe215 VM |
35 | * @brief Git tree parsing, loading routines |
36 | * @defgroup git_tree Git tree parsing, loading routines | |
37 | * @ingroup Git | |
38 | * @{ | |
39 | */ | |
40 | GIT_BEGIN_DECL | |
41 | ||
225fe215 | 42 | /** |
3315782c | 43 | * Lookup a tree object from the repository. |
225fe215 | 44 | * |
1795f879 | 45 | * @param tree pointer to the looked up tree |
3315782c | 46 | * @param repo the repo to use when locating the tree. |
225fe215 | 47 | * @param id identity of the tree to locate. |
1795f879 | 48 | * @return 0 on success; error code otherwise |
225fe215 | 49 | */ |
e52ed7a5 VM |
50 | GIT_INLINE(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git_oid *id) |
51 | { | |
5de079b8 | 52 | return git_object_lookup((git_object **)tree, repo, id, GIT_OBJ_TREE); |
e52ed7a5 | 53 | } |
d8603ed9 | 54 | |
225fe215 VM |
55 | /** |
56 | * Get the id of a tree. | |
72a3fe42 | 57 | * |
225fe215 VM |
58 | * @param tree a previously loaded tree. |
59 | * @return object identity for the tree. | |
60 | */ | |
61 | GIT_EXTERN(const git_oid *) git_tree_id(git_tree *tree); | |
62 | ||
003c2690 VM |
63 | /** |
64 | * Get the number of entries listed in a tree | |
72a3fe42 | 65 | * |
003c2690 VM |
66 | * @param tree a previously loaded tree. |
67 | * @return the number of entries in the tree | |
68 | */ | |
69 | GIT_EXTERN(size_t) git_tree_entrycount(git_tree *tree); | |
70 | ||
71 | /** | |
72 | * Lookup a tree entry by its filename | |
72a3fe42 | 73 | * |
003c2690 VM |
74 | * @param tree a previously loaded tree. |
75 | * @param filename the filename of the desired entry | |
76 | * @return the tree entry; NULL if not found | |
77 | */ | |
2a884588 | 78 | GIT_EXTERN(git_tree_entry *) git_tree_entry_byname(git_tree *tree, const char *filename); |
003c2690 VM |
79 | |
80 | /** | |
81 | * Lookup a tree entry by its position in the tree | |
72a3fe42 | 82 | * |
003c2690 VM |
83 | * @param tree a previously loaded tree. |
84 | * @param idx the position in the entry list | |
85 | * @return the tree entry; NULL if not found | |
86 | */ | |
2a884588 | 87 | GIT_EXTERN(git_tree_entry *) git_tree_entry_byindex(git_tree *tree, int idx); |
003c2690 VM |
88 | |
89 | /** | |
90 | * Get the UNIX file attributes of a tree entry | |
72a3fe42 | 91 | * |
003c2690 VM |
92 | * @param entry a tree entry |
93 | * @return attributes as an integer | |
94 | */ | |
2a884588 | 95 | GIT_EXTERN(unsigned int) git_tree_entry_attributes(git_tree_entry *entry); |
003c2690 VM |
96 | |
97 | /** | |
98 | * Get the filename of a tree entry | |
72a3fe42 | 99 | * |
003c2690 VM |
100 | * @param entry a tree entry |
101 | * @return the name of the file | |
102 | */ | |
2a884588 | 103 | GIT_EXTERN(const char *) git_tree_entry_name(git_tree_entry *entry); |
003c2690 VM |
104 | |
105 | /** | |
106 | * Get the id of the object pointed by the entry | |
72a3fe42 | 107 | * |
003c2690 VM |
108 | * @param entry a tree entry |
109 | * @return the oid of the object | |
110 | */ | |
2a884588 | 111 | GIT_EXTERN(const git_oid *) git_tree_entry_id(git_tree_entry *entry); |
003c2690 VM |
112 | |
113 | /** | |
f49a2e49 | 114 | * Convert a tree entry to the git_object it points too. |
1795f879 VM |
115 | * |
116 | * @param object pointer to the converted object | |
72a3fe42 | 117 | * @param repo repository where to lookup the pointed object |
003c2690 VM |
118 | * @param entry a tree entry |
119 | * @return a reference to the pointed object in the repository | |
120 | */ | |
72a3fe42 | 121 | GIT_EXTERN(int) git_tree_entry_2object(git_object **object_out, git_repository *repo, git_tree_entry *entry); |
003c2690 | 122 | |
225fe215 VM |
123 | /** @} */ |
124 | GIT_END_DECL | |
125 | #endif |