]> git.proxmox.com Git - libgit2.git/blame - include/git2/indexer.h
libgit2 v0.17.0 "Lord of Diffstruction"
[libgit2.git] / include / git2 / indexer.h
CommitLineData
bb742ede 1/*
5e0de328 2 * Copyright (C) 2009-2012 the libgit2 contributors
bb742ede
VM
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 */
3412391d
CMN
7#ifndef _INCLUDE_git_indexer_h__
8#define _INCLUDE_git_indexer_h__
9
2cbca8b0
VM
10#include "common.h"
11#include "oid.h"
f23c4a66 12
a6bbb8ca
LC
13GIT_BEGIN_DECL
14
65cb1586
CMN
15/**
16 * This is passed as the first argument to the callback to allow the
17 * user to see the progress.
18 */
f23c4a66
CMN
19typedef struct git_indexer_stats {
20 unsigned int total;
ab525a74 21 unsigned int processed;
f23c4a66
CMN
22} git_indexer_stats;
23
24
ab525a74 25typedef struct git_indexer git_indexer;
3f93e16c
CMN
26typedef struct git_indexer_stream git_indexer_stream;
27
28/**
29 * Create a new streaming indexer instance
30 *
31 * @param out where to store the inexer instance
32 * @param path to the gitdir (metadata directory)
33 */
34GIT_EXTERN(int) git_indexer_stream_new(git_indexer_stream **out, const char *gitdir);
35
36/**
37 * Add data to the indexer
38 *
39 * @param idx the indexer
40 * @param data the data to add
41 * @param size the size of the data
42 * @param stats stat storage
43 */
dee5515a 44GIT_EXTERN(int) git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t size, git_indexer_stats *stats);
3412391d 45
453ab98d
CMN
46/**
47 * Finalize the pack and index
48 *
49 * Resolve any pending deltas and write out the index file
50 *
51 * @param idx the indexer
52 */
53GIT_EXTERN(int) git_indexer_stream_finalize(git_indexer_stream *idx, git_indexer_stats *stats);
54
1c9c081a
CMN
55/**
56 * Get the packfile's hash
57 *
58 * A packfile's name is derived from the sorted hashing of all object
59 * names. This is only correct after the index has been finalized.
60 *
61 * @param idx the indexer instance
62 */
63GIT_EXTERN(const git_oid *) git_indexer_stream_hash(git_indexer_stream *idx);
64
65/**
66 * Free the indexer and its resources
67 *
68 * @param idx the indexer to free
69 */
70GIT_EXTERN(void) git_indexer_stream_free(git_indexer_stream *idx);
71
65cb1586
CMN
72/**
73 * Create a new indexer instance
74 *
75 * @param out where to store the indexer instance
76 * @param packname the absolute filename of the packfile to index
77 */
ab525a74 78GIT_EXTERN(int) git_indexer_new(git_indexer **out, const char *packname);
65cb1586
CMN
79
80/**
81 * Iterate over the objects in the packfile and extract the information
82 *
83 * Indexing a packfile can be very expensive so this function is
84 * expected to be run in a worker thread and the stats used to provide
85 * feedback the user.
86 *
87 * @param idx the indexer instance
88 * @param stats storage for the running state
89 */
b7c44096 90GIT_EXTERN(int) git_indexer_run(git_indexer *idx, git_indexer_stats *stats);
65cb1586
CMN
91
92/**
93 * Write the index file to disk.
94 *
95 * The file will be stored as pack-$hash.idx in the same directory as
96 * the packfile.
97 *
98 * @param idx the indexer instance
99 */
48b3ad4f 100GIT_EXTERN(int) git_indexer_write(git_indexer *idx);
65cb1586
CMN
101
102/**
103 * Get the packfile's hash
104 *
105 * A packfile's name is derived from the sorted hashing of all object
106 * names. This is only correct after the index has been written to disk.
107 *
108 * @param idx the indexer instance
109 */
110GIT_EXTERN(const git_oid *) git_indexer_hash(git_indexer *idx);
111
112/**
113 * Free the indexer and its resources
114 *
115 * @param idx the indexer to free
116 */
ab525a74 117GIT_EXTERN(void) git_indexer_free(git_indexer *idx);
3412391d 118
a6bbb8ca 119GIT_END_DECL
3412391d
CMN
120
121#endif