summaryrefslogtreecommitdiff
path: root/src/indexer.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-07-07 19:08:45 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2011-08-02 21:41:05 +0200
commitf23c4a66bde5738a574416db4617ca749ca34f7d (patch)
tree5f3a84e5fbe14e02b6b85aa9900b482921e85d40 /src/indexer.c
parent3412391d4ccf6435b981c46e796cc6988a676fad (diff)
downloadlibgit2-f23c4a66bde5738a574416db4617ca749ca34f7d.tar.gz
Start the runner
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src/indexer.c')
-rw-r--r--src/indexer.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/indexer.c b/src/indexer.c
index b63efc088..97f08dae1 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -23,10 +23,21 @@
* Boston, MA 02110-1301, USA.
*/
+#include "git2/indexer.h"
+
#include "common.h"
#include "pack.h"
+#include "mwindow.h"
#include "posix.h"
+typedef struct git_pack_indexer {
+ struct pack_file *pack;
+ git_vector objects;
+ git_vector deltas;
+ struct stat st;
+ git_indexer_stats stats;
+} git_pack_indexer;
+
static int parse_header(git_pack_indexer *idx)
{
struct pack_header hdr;
@@ -59,6 +70,8 @@ static int parse_header(git_pack_indexer *idx)
if (error < GIT_SUCCESS)
goto cleanup;
+ idx->stats.total = hdr.hdr_entries;
+
return GIT_SUCCESS;
cleanup:
@@ -123,6 +136,27 @@ cleanup:
return error;
}
+/*
+ * Create the index. Every time something interesting happens
+ * (something has been parse or resolved), the callback gets called
+ * with some stats so it can tell the user how hard we're working
+ */
+int git_pack_indexer_run(git_pack_indexer *idx, int (*cb)(const git_indexer_stats *, void *), void *data)
+{
+ git_mwindow_file *mwf = &idx->pack->mwf;
+ int error;
+
+ error = git_mwindow_file_register(mwf);
+ if (error < GIT_SUCCESS)
+ return git__rethrow(error, "Failed to register mwindow file");
+
+ /* notify early */
+ if (cb)
+ cb(&idx->stats, data);
+
+ return error;
+}
+
void git_pack_indexer_free(git_pack_indexer *idx)
{
p_close(idx->pack->pack_fd);