summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2011-08-03 18:59:30 -0700
committerVicent Martí <tanoku@gmail.com>2011-08-03 18:59:30 -0700
commit31bf5f38575fdffb27326a2b2bae88d096bb0071 (patch)
treeff0d57473b6ab5f4510e9b8969f9c64e96c232f7 /include/git2
parent20c1bca1234b7e726ef5826ed329cd466a32e405 (diff)
parent65cb1586c45b6ca2e74753b93e8677edcae903ae (diff)
downloadlibgit2-31bf5f38575fdffb27326a2b2bae88d096bb0071.tar.gz
Merge pull request #345 from carlosmn/gsoc2011/indexer
Implement a pack indexer
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/indexer.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/include/git2/indexer.h b/include/git2/indexer.h
new file mode 100644
index 000000000..6c31956b1
--- /dev/null
+++ b/include/git2/indexer.h
@@ -0,0 +1,67 @@
+#ifndef _INCLUDE_git_indexer_h__
+#define _INCLUDE_git_indexer_h__
+
+#include "git2/common.h"
+#include "git2/oid.h"
+
+/**
+ * This is passed as the first argument to the callback to allow the
+ * user to see the progress.
+ */
+typedef struct git_indexer_stats {
+ unsigned int total;
+ unsigned int processed;
+} git_indexer_stats;
+
+
+typedef struct git_indexer git_indexer;
+
+/**
+ * Create a new indexer instance
+ *
+ * @param out where to store the indexer instance
+ * @param packname the absolute filename of the packfile to index
+ */
+GIT_EXTERN(int) git_indexer_new(git_indexer **out, const char *packname);
+
+/**
+ * Iterate over the objects in the packfile and extract the information
+ *
+ * Indexing a packfile can be very expensive so this function is
+ * expected to be run in a worker thread and the stats used to provide
+ * feedback the user.
+ *
+ * @param idx the indexer instance
+ * @param stats storage for the running state
+ */
+GIT_EXTERN(int) git_indexer_run(git_indexer *idx, git_indexer_stats *stats);
+
+/**
+ * Write the index file to disk.
+ *
+ * The file will be stored as pack-$hash.idx in the same directory as
+ * the packfile.
+ *
+ * @param idx the indexer instance
+ */
+GIT_EXTERN(int) git_indexer_write(git_indexer *idx);
+
+/**
+ * Get the packfile's hash
+ *
+ * A packfile's name is derived from the sorted hashing of all object
+ * names. This is only correct after the index has been written to disk.
+ *
+ * @param idx the indexer instance
+ */
+GIT_EXTERN(const git_oid *) git_indexer_hash(git_indexer *idx);
+
+/**
+ * Free the indexer and its resources
+ *
+ * @param idx the indexer to free
+ */
+GIT_EXTERN(void) git_indexer_free(git_indexer *idx);
+
+
+#endif