1313#include "revwalk.h"
1414#include "git2/revparse.h"
1515#include "merge.h"
16+ #include "vector.h"
1617
1718GIT__USE_OIDMAP
1819
@@ -41,97 +42,6 @@ git_commit_list_node *git_revwalk__commit_lookup(
4142 return commit ;
4243}
4344
44- typedef git_array_t (git_commit_list_node * ) commit_list_node_array ;
45-
46- static bool interesting_arr (commit_list_node_array arr )
47- {
48- git_commit_list_node * * n ;
49- size_t i = 0 , size ;
50-
51- size = git_array_size (arr );
52- for (i = 0 ; i < size ; i ++ ) {
53- n = git_array_get (arr , i );
54- if (!* n )
55- break ;
56-
57- if (!(* n )-> uninteresting )
58- return true;
59- }
60-
61- return false;
62- }
63-
64- static int mark_uninteresting (git_revwalk * walk , git_commit_list_node * commit )
65- {
66- int error ;
67- unsigned short i ;
68- commit_list_node_array pending = GIT_ARRAY_INIT ;
69- git_commit_list_node * * tmp ;
70-
71- assert (commit );
72-
73- do {
74- commit -> uninteresting = 1 ;
75-
76- if ((error = git_commit_list_parse (walk , commit )) < 0 )
77- return error ;
78-
79- for (i = 0 ; i < commit -> out_degree ; ++ i )
80- if (!commit -> parents [i ]-> uninteresting ) {
81- git_commit_list_node * * node = git_array_alloc (pending );
82- GITERR_CHECK_ALLOC (node );
83- * node = commit -> parents [i ];
84- }
85-
86- tmp = git_array_pop (pending );
87- commit = tmp ? * tmp : NULL ;
88-
89- } while (commit != NULL && interesting_arr (pending ));
90-
91- git_array_clear (pending );
92-
93- return 0 ;
94- }
95-
96- static int process_commit (git_revwalk * walk , git_commit_list_node * commit , int hide )
97- {
98- int error ;
99-
100- if (!hide && walk -> hide_cb )
101- hide = walk -> hide_cb (& commit -> oid , walk -> hide_cb_payload );
102-
103- if (hide && mark_uninteresting (walk , commit ) < 0 )
104- return -1 ;
105-
106- if (commit -> seen )
107- return 0 ;
108-
109- commit -> seen = 1 ;
110-
111- if ((error = git_commit_list_parse (walk , commit )) < 0 )
112- return error ;
113-
114- if (!hide )
115- return walk -> enqueue (walk , commit );
116-
117- return 0 ;
118- }
119-
120- static int process_commit_parents (git_revwalk * walk , git_commit_list_node * commit )
121- {
122- unsigned short i , max ;
123- int error = 0 ;
124-
125- max = commit -> out_degree ;
126- if (walk -> first_parent && commit -> out_degree )
127- max = 1 ;
128-
129- for (i = 0 ; i < max && !error ; ++ i )
130- error = process_commit (walk , commit -> parents [i ], commit -> uninteresting );
131-
132- return error ;
133- }
134-
13545static int push_commit (git_revwalk * walk , const git_oid * oid , int uninteresting , int from_glob )
13646{
13747 git_oid commit_id ;
@@ -321,35 +231,25 @@ static int revwalk_enqueue_unsorted(git_revwalk *walk, git_commit_list_node *com
321231
322232static int revwalk_next_timesort (git_commit_list_node * * object_out , git_revwalk * walk )
323233{
324- int error ;
325234 git_commit_list_node * next ;
326235
327- while ((next = git_pqueue_pop (& walk -> iterator_time )) != NULL )
328- if (!next -> uninteresting ) {
329- if ((error = process_commit_parents (walk , next )) < 0 )
330- return error ;
331-
332- * object_out = next ;
333- return 0 ;
334- }
236+ if ((next = git_pqueue_pop (& walk -> iterator_time )) != NULL ) {
237+ * object_out = next ;
238+ return 0 ;
239+ }
335240
336241 giterr_clear ();
337242 return GIT_ITEROVER ;
338243}
339244
340245static int revwalk_next_unsorted (git_commit_list_node * * object_out , git_revwalk * walk )
341246{
342- int error ;
343247 git_commit_list_node * next ;
344248
345- while ((next = git_commit_list_pop (& walk -> iterator_rand )) != NULL )
346- if (!next -> uninteresting ) {
347- if ((error = process_commit_parents (walk , next )) < 0 )
348- return error ;
349-
350- * object_out = next ;
351- return 0 ;
352- }
249+ if ((next = git_commit_list_pop (& walk -> iterator_rand )) != NULL ) {
250+ * object_out = next ;
251+ return 0 ;
252+ }
353253
354254 giterr_clear ();
355255 return GIT_ITEROVER ;
@@ -375,19 +275,6 @@ static int revwalk_next_reverse(git_commit_list_node **object_out, git_revwalk *
375275 return * object_out ? 0 : GIT_ITEROVER ;
376276}
377277
378- static int contains (git_pqueue * list , git_commit_list_node * node )
379- {
380- size_t i ;
381-
382- for (i = 0 ; i < git_pqueue_size (list ); i ++ ) {
383- git_commit_list_node * commit = git_pqueue_get (list , i );
384- if (commit == node )
385- return 1 ;
386- }
387-
388- return 0 ;
389- }
390-
391278static void mark_parents_uninteresting (git_commit_list_node * commit )
392279{
393280 unsigned short i ;
0 commit comments