tree.h 1.09 KB
Newer Older
Vicent Marti committed
1
/*
schu committed
2
 * Copyright (C) 2009-2012 the libgit2 contributors
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

15
struct git_tree_entry {
16 17
	uint16_t removed;
	uint16_t attr;
18
	git_oid oid;
19
	size_t filename_len;
20
	char filename[1];
21 22
};

23
struct git_tree {
24
	git_object object;
25
	git_vector entries;
26 27
};

28 29 30 31 32
struct git_treebuilder {
	git_vector entries;
};


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

38
void git_tree__free(git_tree *tree);
Vicent Marti committed
39
int git_tree__parse(git_tree *tree, git_odb_object *obj);
40

41 42 43 44 45 46 47
/**
 * 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.
 */
Vicent Martí committed
48
int git_tree__prefix_position(git_tree *tree, const char *prefix);
49 50


51
#endif