Added new error codes. Improved error handling.
[libgit2.git] / src / git / revwalk.h
blob027a51a064c6a3d91392f31f32b041bb1920ec60
1 #ifndef INCLUDE_git_revwalk_h__
2 #define INCLUDE_git_revwalk_h__
4 #include "common.h"
5 #include "odb.h"
6 #include "commit.h"
8 /**
9 * @file git/revwalk.h
10 * @brief Git revision traversal routines
11 * @defgroup git_revwalk Git revision traversal routines
12 * @ingroup Git
13 * @{
15 GIT_BEGIN_DECL
17 /**
18 * Sort the revpool contents in no particular ordering;
19 * this sorting is arbritary, implementation-specific
20 * and subject to change at any time.
21 * This is the default sorting for new revision pools.
23 #define GIT_RPSORT_NONE (0)
25 /**
26 * Sort the revpool contents in topological order
27 * (parents before children); this sorting mode
28 * can be combined with time sorting.
30 #define GIT_RPSORT_TOPOLOGICAL (1 << 0)
32 /**
33 * Sort the revpool contents by commit time;
34 * this sorting mode can be combined with
35 * topological sorting.
37 #define GIT_RPSORT_TIME (1 << 1)
39 /**
40 * Iterate through the revpool contents in reverse
41 * order; this sorting mode can be combined with
42 * any of the above.
44 #define GIT_RPSORT_REVERSE (1 << 2)
46 /**
47 * Allocate a new revision traversal pool.
49 * The configuration is copied during allocation. Changes
50 * to the configuration after allocation do not affect the pool
51 * returned by this function. Callers may safely free the
52 * passed configuration after the function completes.
54 * @param db the database objects are read from.
55 * @return the new traversal handle; NULL if memory is exhausted.
57 GIT_EXTERN(git_revpool *) gitrp_alloc(git_odb *db);
59 /**
60 * Reset the traversal machinary for reuse.
61 * @param pool traversal handle to reset.
63 GIT_EXTERN(void) gitrp_reset(git_revpool *pool);
65 /**
66 * Mark an object to start traversal from.
67 * @param pool the pool being used for the traversal.
68 * @param commit the commit to start from.
70 GIT_EXTERN(int) gitrp_push(git_revpool *pool, git_commit *commit);
72 /**
73 * Mark a commit (and its ancestors) uninteresting for the output.
74 * @param pool the pool being used for the traversal.
75 * @param commit the commit that will be ignored during the traversal
77 GIT_EXTERN(int) gitrp_hide(git_revpool *pool, git_commit *commit);
79 /**
80 * Get the next commit from the revision traversal.
81 * @param pool the pool to pop the commit from.
82 * @return next commit; NULL if there is no more output.
84 GIT_EXTERN(git_commit *) gitrp_next(git_revpool *pool);
86 /**
87 * Change the sorting mode when iterating through the
88 * revision pool's contents.
89 * @param sort_mode combination of GIT_RPSORT_XXX flags
91 GIT_EXTERN(void) gitrp_sorting(git_revpool *pool, unsigned int sort_mode);
93 /**
94 * Free a revwalk previously allocated.
95 * @param pool traversal handle to close. If NULL nothing occurs.
97 GIT_EXTERN(void) gitrp_free(git_revpool *pool);
99 /** @} */
100 GIT_END_DECL
101 #endif