revwalk: get rid of obsolete marking code We've now moved to code that's closer to git and produces the output during the preparation phase, so we no longer process the commits as part of generating the output. This makes a chunk of code redundant, as we're simply short-circuiting it by detecting we've processed the commits alrady.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
diff --git a/src/revwalk.c b/src/revwalk.c
index ec9cc57..cea7630 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -13,6 +13,7 @@
#include "revwalk.h"
#include "git2/revparse.h"
#include "merge.h"
+#include "vector.h"
GIT__USE_OIDMAP
@@ -41,97 +42,6 @@ git_commit_list_node *git_revwalk__commit_lookup(
return commit;
}
-typedef git_array_t(git_commit_list_node*) commit_list_node_array;
-
-static bool interesting_arr(commit_list_node_array arr)
-{
- git_commit_list_node **n;
- size_t i = 0, size;
-
- size = git_array_size(arr);
- for (i = 0; i < size; i++) {
- n = git_array_get(arr, i);
- if (!*n)
- break;
-
- if (!(*n)->uninteresting)
- return true;
- }
-
- return false;
-}
-
-static int mark_uninteresting(git_revwalk *walk, git_commit_list_node *commit)
-{
- int error;
- unsigned short i;
- commit_list_node_array pending = GIT_ARRAY_INIT;
- git_commit_list_node **tmp;
-
- assert(commit);
-
- do {
- commit->uninteresting = 1;
-
- if ((error = git_commit_list_parse(walk, commit)) < 0)
- return error;
-
- for (i = 0; i < commit->out_degree; ++i)
- if (!commit->parents[i]->uninteresting) {
- git_commit_list_node **node = git_array_alloc(pending);
- GITERR_CHECK_ALLOC(node);
- *node = commit->parents[i];
- }
-
- tmp = git_array_pop(pending);
- commit = tmp ? *tmp : NULL;
-
- } while (commit != NULL && interesting_arr(pending));
-
- git_array_clear(pending);
-
- return 0;
-}
-
-static int process_commit(git_revwalk *walk, git_commit_list_node *commit, int hide)
-{
- int error;
-
- if (!hide && walk->hide_cb)
- hide = walk->hide_cb(&commit->oid, walk->hide_cb_payload);
-
- if (hide && mark_uninteresting(walk, commit) < 0)
- return -1;
-
- if (commit->seen)
- return 0;
-
- commit->seen = 1;
-
- if ((error = git_commit_list_parse(walk, commit)) < 0)
- return error;
-
- if (!hide)
- return walk->enqueue(walk, commit);
-
- return 0;
-}
-
-static int process_commit_parents(git_revwalk *walk, git_commit_list_node *commit)
-{
- unsigned short i, max;
- int error = 0;
-
- max = commit->out_degree;
- if (walk->first_parent && commit->out_degree)
- max = 1;
-
- for (i = 0; i < max && !error; ++i)
- error = process_commit(walk, commit->parents[i], commit->uninteresting);
-
- return error;
-}
-
static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting, int from_glob)
{
git_oid commit_id;
@@ -321,17 +231,12 @@ static int revwalk_enqueue_unsorted(git_revwalk *walk, git_commit_list_node *com
static int revwalk_next_timesort(git_commit_list_node **object_out, git_revwalk *walk)
{
- int error;
git_commit_list_node *next;
- while ((next = git_pqueue_pop(&walk->iterator_time)) != NULL)
- if (!next->uninteresting) {
- if ((error = process_commit_parents(walk, next)) < 0)
- return error;
-
- *object_out = next;
- return 0;
- }
+ if ((next = git_pqueue_pop(&walk->iterator_time)) != NULL) {
+ *object_out = next;
+ return 0;
+ }
giterr_clear();
return GIT_ITEROVER;
@@ -339,17 +244,12 @@ static int revwalk_next_timesort(git_commit_list_node **object_out, git_revwalk
static int revwalk_next_unsorted(git_commit_list_node **object_out, git_revwalk *walk)
{
- int error;
git_commit_list_node *next;
- while ((next = git_commit_list_pop(&walk->iterator_rand)) != NULL)
- if (!next->uninteresting) {
- if ((error = process_commit_parents(walk, next)) < 0)
- return error;
-
- *object_out = next;
- return 0;
- }
+ if ((next = git_commit_list_pop(&walk->iterator_rand)) != NULL) {
+ *object_out = next;
+ return 0;
+ }
giterr_clear();
return GIT_ITEROVER;
@@ -375,19 +275,6 @@ static int revwalk_next_reverse(git_commit_list_node **object_out, git_revwalk *
return *object_out ? 0 : GIT_ITEROVER;
}
-static int contains(git_pqueue *list, git_commit_list_node *node)
-{
- size_t i;
-
- for (i = 0; i < git_pqueue_size(list); i++) {
- git_commit_list_node *commit = git_pqueue_get(list, i);
- if (commit == node)
- return 1;
- }
-
- return 0;
-}
-
static void mark_parents_uninteresting(git_commit_list_node *commit)
{
unsigned short i;