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

#ifndef INCLUDE_tree_cache_h__
#define INCLUDE_tree_cache_h__

#include "common.h"
12
#include "pool.h"
13
#include "buffer.h"
14 15
#include "git2/oid.h"

16
typedef struct git_tree_cache {
17 18 19
	struct git_tree_cache **children;
	size_t children_count;

20
	ssize_t entry_count;
21
	git_oid oid;
22
	size_t namelen;
23
	char name[GIT_FLEX_ARRAY];
24
} git_tree_cache;
25

26
int git_tree_cache_write(git_buf *out, git_tree_cache *tree);
27
int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer_size, git_pool *pool);
28
void git_tree_cache_invalidate_path(git_tree_cache *tree, const char *path);
29
const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char *path);
30
int git_tree_cache_new(git_tree_cache **out, const char *name, git_pool *pool);
31 32 33 34
/**
 * Read a tree as the root of the tree cache (like for `git read-tree`)
 */
int git_tree_cache_read_tree(git_tree_cache **out, const git_tree *tree, git_pool *pool);
35 36 37
void git_tree_cache_free(git_tree_cache *tree);

#endif