tree.h 1.5 KB
Newer Older
Vicent Marti committed
1
/*
Edward Thomson committed
2
 * Copyright (C) the libgit2 contributors. All rights reserved.
Vicent Marti committed
3 4 5 6
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
 */
7 8 9
#ifndef INCLUDE_tree_h__
#define INCLUDE_tree_h__

10
#include "git2/tree.h"
11
#include "repository.h"
Vicent Marti committed
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
	git_oid oid;
21 22
	bool pooled;
	char filename[GIT_FLEX_ARRAY];
23 24
};

25
struct git_tree {
26
	git_object object;
27
	git_vector entries;
28
	git_pool pool;
29 30
};

31
struct git_treebuilder {
32
	git_repository *repo;
33
	git_strmap *map;
34 35
};

Vicent Martí committed
36
GIT_INLINE(bool) git_tree_entry__is_tree(const struct git_tree_entry *e)
37
{
38
	return (S_ISDIR(e->attr) && !S_ISGITLINK(e->attr));
39 40
}

41 42
extern int git_tree_entry_icmp(const git_tree_entry *e1, const git_tree_entry *e2);

43
void git_tree__free(void *tree);
44
int git_tree__parse(void *tree, git_odb_object *obj);
45

46 47 48 49 50 51 52
/**
 * Lookup the first position in the tree with a given prefix.
 *
 * @param tree a previously loaded tree.
 * @param prefix the beginning of a path to find in the tree.
 * @return index of the first item at or after the given prefix.
 */
53
int git_tree__prefix_position(const git_tree *tree, const char *prefix);
54

55 56 57 58

/**
 * Write a tree to the given repository
 */
59 60
int git_tree__write_index(
	git_oid *oid, git_index *index, git_repository *repo);
61

nulltoken committed
62 63 64 65
/**
 * Obsolete mode kept for compatibility reasons
 */
#define GIT_FILEMODE_BLOB_GROUP_WRITABLE 0100664
66

67
#endif