]>
Commit | Line | Data |
---|---|---|
f5918330 VM |
1 | /* |
2 | * This file is free software; you can redistribute it and/or modify | |
3 | * it under the terms of the GNU General Public License, version 2, | |
4 | * as published by the Free Software Foundation. | |
5 | * | |
6 | * In addition to the permissions in the GNU General Public License, | |
7 | * the authors give you unlimited permission to link the compiled | |
8 | * version of this file into combinations with other programs, | |
9 | * and to distribute those combinations without any restriction | |
10 | * coming from the use of this file. (The General Public License | |
11 | * restrictions do apply in other respects; for example, they cover | |
12 | * modification of the file, and distribution when not linked into | |
13 | * a combined executable.) | |
14 | * | |
15 | * This file is distributed in the hope that it will be useful, but | |
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | * General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License | |
21 | * along with this program; see the file COPYING. If not, write to | |
22 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, | |
23 | * Boston, MA 02110-1301, USA. | |
24 | */ | |
06160502 SP |
25 | #ifndef INCLUDE_git_revwalk_h__ |
26 | #define INCLUDE_git_revwalk_h__ | |
27 | ||
257bd746 | 28 | #include "common.h" |
d12299fe | 29 | #include "types.h" |
06160502 SP |
30 | |
31 | /** | |
f5918330 | 32 | * @file git2/revwalk.h |
06160502 SP |
33 | * @brief Git revision traversal routines |
34 | * @defgroup git_revwalk Git revision traversal routines | |
35 | * @ingroup Git | |
36 | * @{ | |
37 | */ | |
38 | GIT_BEGIN_DECL | |
39 | ||
e5d1faef | 40 | /** |
3315782c | 41 | * Sort the repository contents in no particular ordering; |
0037e491 | 42 | * this sorting is arbitrary, implementation-specific |
e5d1faef | 43 | * and subject to change at any time. |
3315782c | 44 | * This is the default sorting for new walkers. |
e5d1faef | 45 | */ |
3315782c | 46 | #define GIT_SORT_NONE (0) |
e5d1faef VM |
47 | |
48 | /** | |
3315782c | 49 | * Sort the repository contents in topological order |
e5d1faef VM |
50 | * (parents before children); this sorting mode |
51 | * can be combined with time sorting. | |
52 | */ | |
3315782c | 53 | #define GIT_SORT_TOPOLOGICAL (1 << 0) |
e5d1faef VM |
54 | |
55 | /** | |
3315782c | 56 | * Sort the repository contents by commit time; |
e5d1faef VM |
57 | * this sorting mode can be combined with |
58 | * topological sorting. | |
59 | */ | |
3315782c | 60 | #define GIT_SORT_TIME (1 << 1) |
e5d1faef VM |
61 | |
62 | /** | |
3315782c | 63 | * Iterate through the repository contents in reverse |
e5d1faef VM |
64 | * order; this sorting mode can be combined with |
65 | * any of the above. | |
66 | */ | |
3315782c VM |
67 | #define GIT_SORT_REVERSE (1 << 2) |
68 | ||
06160502 | 69 | /** |
3315782c | 70 | * Allocate a new revision walker to iterate through a repo. |
06160502 | 71 | * |
1795f879 | 72 | * @param walker pointer to the new revision walker |
3315782c | 73 | * @param repo the repo to walk through |
1795f879 | 74 | * @return 0 on success; error code otherwise |
06160502 | 75 | */ |
1795f879 | 76 | GIT_EXTERN(int) git_revwalk_new(git_revwalk **walker, git_repository *repo); |
06160502 SP |
77 | |
78 | /** | |
0037e491 | 79 | * Reset the walking machinery for reuse. |
3315782c | 80 | * @param walker handle to reset. |
06160502 | 81 | */ |
3315782c | 82 | GIT_EXTERN(void) git_revwalk_reset(git_revwalk *walker); |
06160502 SP |
83 | |
84 | /** | |
3315782c VM |
85 | * Mark a commit to start traversal from. |
86 | * The commit object must belong to the repo which is being walked through. | |
87 | * | |
88 | * @param walker the walker being used for the traversal. | |
1bb11859 | 89 | * @param commit the commit to start from. |
06160502 | 90 | */ |
3315782c | 91 | GIT_EXTERN(int) git_revwalk_push(git_revwalk *walk, git_commit *commit); |
06160502 SP |
92 | |
93 | /** | |
94 | * Mark a commit (and its ancestors) uninteresting for the output. | |
3315782c | 95 | * @param walker the walker being used for the traversal. |
1bb11859 | 96 | * @param commit the commit that will be ignored during the traversal |
06160502 | 97 | */ |
3315782c | 98 | GIT_EXTERN(int) git_revwalk_hide(git_revwalk *walk, git_commit *commit); |
06160502 SP |
99 | |
100 | /** | |
101 | * Get the next commit from the revision traversal. | |
3315782c | 102 | * @param walk the walker to pop the commit from. |
06160502 SP |
103 | * @return next commit; NULL if there is no more output. |
104 | */ | |
3315782c | 105 | GIT_EXTERN(git_commit *) git_revwalk_next(git_revwalk *walk); |
06160502 | 106 | |
e5d1faef VM |
107 | /** |
108 | * Change the sorting mode when iterating through the | |
3315782c VM |
109 | * repository's contents. |
110 | * Changing the sorting mode resets the walker. | |
111 | * @param walk the walker being used for the traversal. | |
e5d1faef VM |
112 | * @param sort_mode combination of GIT_RPSORT_XXX flags |
113 | */ | |
1795f879 | 114 | GIT_EXTERN(int) git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode); |
e5d1faef | 115 | |
06160502 SP |
116 | /** |
117 | * Free a revwalk previously allocated. | |
3315782c | 118 | * @param walk traversal handle to close. If NULL nothing occurs. |
06160502 | 119 | */ |
3315782c | 120 | GIT_EXTERN(void) git_revwalk_free(git_revwalk *walk); |
06160502 | 121 | |
a13bc8e7 VM |
122 | /** |
123 | * Return the repository on which this walker | |
124 | * is operating. | |
125 | * | |
126 | * @param walk the revision walker | |
127 | * @return the repository being walked | |
128 | */ | |
129 | GIT_EXTERN(git_repository *) git_revwalk_repository(git_revwalk *walk); | |
130 | ||
06160502 SP |
131 | /** @} */ |
132 | GIT_END_DECL | |
133 | #endif |