]> git.proxmox.com Git - libgit2.git/blob - src/tree.h
Merge pull request #3704 from ethomson/tree-reuse
[libgit2.git] / src / tree.h
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7 #ifndef INCLUDE_tree_h__
8 #define INCLUDE_tree_h__
9
10 #include "git2/tree.h"
11 #include "repository.h"
12 #include "odb.h"
13 #include "vector.h"
14 #include "strmap.h"
15 #include "pool.h"
16
17 struct git_tree_entry {
18 uint16_t attr;
19 uint16_t filename_len;
20 const git_oid *oid;
21 const char *filename;
22 };
23
24 struct git_tree {
25 git_object object;
26 git_odb_object *odb_obj;
27 git_array_t(git_tree_entry) entries;
28 };
29
30 struct git_treebuilder {
31 git_repository *repo;
32 git_strmap *map;
33 };
34
35 GIT_INLINE(bool) git_tree_entry__is_tree(const struct git_tree_entry *e)
36 {
37 return (S_ISDIR(e->attr) && !S_ISGITLINK(e->attr));
38 }
39
40 extern int git_tree_entry_icmp(const git_tree_entry *e1, const git_tree_entry *e2);
41
42 void git_tree__free(void *tree);
43 int git_tree__parse(void *tree, git_odb_object *obj);
44
45 /**
46 * Lookup the first position in the tree with a given prefix.
47 *
48 * @param tree a previously loaded tree.
49 * @param prefix the beginning of a path to find in the tree.
50 * @return index of the first item at or after the given prefix.
51 */
52 int git_tree__prefix_position(const git_tree *tree, const char *prefix);
53
54
55 /**
56 * Write a tree to the given repository
57 */
58 int git_tree__write_index(
59 git_oid *oid, git_index *index, git_repository *repo);
60
61 /**
62 * Obsolete mode kept for compatibility reasons
63 */
64 #define GIT_FILEMODE_BLOB_GROUP_WRITABLE 0100664
65
66 #endif