11
11
#include "run-command.h"
12
12
#include "transport.h"
13
13
#include "version.h"
14
+ #include "prio-queue.h"
14
15
15
16
static int transfer_unpack_limit = -1 ;
16
17
static int fetch_unpack_limit = -1 ;
@@ -37,7 +38,7 @@ static int marked;
37
38
*/
38
39
#define MAX_IN_VAIN 256
39
40
40
- static struct commit_list * rev_list ;
41
+ static struct prio_queue rev_list = { compare_commits_by_commit_date } ;
41
42
static int non_common_revs , multi_ack , use_sideband , allow_tip_sha1_in_want ;
42
43
43
44
static void rev_list_push (struct commit * commit , int mark )
@@ -49,7 +50,7 @@ static void rev_list_push(struct commit *commit, int mark)
49
50
if (parse_commit (commit ))
50
51
return ;
51
52
52
- commit_list_insert_by_date ( commit , & rev_list );
53
+ prio_queue_put ( & rev_list , commit );
53
54
54
55
if (!(commit -> object .flags & COMMON ))
55
56
non_common_revs ++ ;
@@ -122,10 +123,10 @@ static const unsigned char *get_rev(void)
122
123
unsigned int mark ;
123
124
struct commit_list * parents ;
124
125
125
- if (rev_list == NULL || non_common_revs == 0 )
126
+ if (rev_list . nr == 0 || non_common_revs == 0 )
126
127
return NULL ;
127
128
128
- commit = rev_list -> item ;
129
+ commit = prio_queue_get ( & rev_list ) ;
129
130
if (!commit -> object .parsed )
130
131
parse_commit (commit );
131
132
parents = commit -> parents ;
@@ -152,8 +153,6 @@ static const unsigned char *get_rev(void)
152
153
mark_common (parents -> item , 1 , 0 );
153
154
parents = parents -> next ;
154
155
}
155
-
156
- rev_list = rev_list -> next ;
157
156
}
158
157
159
158
return commit -> object .sha1 ;
@@ -442,7 +441,7 @@ static int find_common(struct fetch_pack_args *args,
442
441
in_vain = 0 ;
443
442
got_continue = 1 ;
444
443
if (ack == ACK_ready ) {
445
- rev_list = NULL ;
444
+ clear_prio_queue ( & rev_list ) ;
446
445
got_ready = 1 ;
447
446
}
448
447
break ;
@@ -505,7 +504,7 @@ static int mark_complete(const char *refname, const unsigned char *sha1, int fla
505
504
struct commit * commit = (struct commit * )o ;
506
505
if (!(commit -> object .flags & COMPLETE )) {
507
506
commit -> object .flags |= COMPLETE ;
508
- commit_list_insert_by_date (commit , & complete );
507
+ commit_list_insert (commit , & complete );
509
508
}
510
509
}
511
510
return 0 ;
@@ -622,6 +621,7 @@ static int everything_local(struct fetch_pack_args *args,
622
621
if (!args -> depth ) {
623
622
for_each_ref (mark_complete , NULL );
624
623
for_each_alternate_ref (mark_alternate_complete , NULL );
624
+ commit_list_sort_by_date (& complete );
625
625
if (cutoff )
626
626
mark_recent_complete_commits (args , cutoff );
627
627
}
0 commit comments