Skip to content

Commit 62ca33e

Browse files
committed
Merge branch 'ds/reachable-topo-order'
The revision walker machinery learned to take advantage of the commit generation numbers stored in the commit-graph file. * ds/reachable-topo-order: t6012: make rev-list tests more interesting revision.c: generation-based topo-order algorithm commit/revisions: bookkeeping before refactoring revision.c: begin refactoring --topo-order logic test-reach: add rev-list tests test-reach: add run_three_modes method prio-queue: add 'peek' operation
2 parents d166e6a + 561b583 commit 62ca33e

File tree

11 files changed

+427
-39
lines changed

11 files changed

+427
-39
lines changed

commit.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -657,11 +657,10 @@ struct commit *pop_commit(struct commit_list **stack)
657657
/* count number of children that have not been emitted */
658658
define_commit_slab(indegree_slab, int);
659659

660-
/* record author-date for each commit object */
661660
define_commit_slab(author_date_slab, timestamp_t);
662661

663-
static void record_author_date(struct author_date_slab *author_date,
664-
struct commit *commit)
662+
void record_author_date(struct author_date_slab *author_date,
663+
struct commit *commit)
665664
{
666665
const char *buffer = get_commit_buffer(commit, NULL);
667666
struct ident_split ident;
@@ -686,8 +685,8 @@ static void record_author_date(struct author_date_slab *author_date,
686685
unuse_commit_buffer(commit, buffer);
687686
}
688687

689-
static int compare_commits_by_author_date(const void *a_, const void *b_,
690-
void *cb_data)
688+
int compare_commits_by_author_date(const void *a_, const void *b_,
689+
void *cb_data)
691690
{
692691
const struct commit *a = a_, *b = b_;
693692
struct author_date_slab *author_date = cb_data;

commit.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "gpg-interface.h"
99
#include "string-list.h"
1010
#include "pretty.h"
11+
#include "commit-slab.h"
1112

1213
#define COMMIT_NOT_FROM_GRAPH 0xFFFFFFFF
1314
#define GENERATION_NUMBER_INFINITY 0xFFFFFFFF
@@ -333,6 +334,12 @@ extern int remove_signature(struct strbuf *buf);
333334
*/
334335
extern int check_commit_signature(const struct commit *commit, struct signature_check *sigc);
335336

337+
/* record author-date for each commit object */
338+
struct author_date_slab;
339+
void record_author_date(struct author_date_slab *author_date,
340+
struct commit *commit);
341+
342+
int compare_commits_by_author_date(const void *a_, const void *b_, void *unused);
336343
int compare_commits_by_commit_date(const void *a_, const void *b_, void *unused);
337344
int compare_commits_by_gen_then_commit_date(const void *a_, const void *b_, void *unused);
338345

object.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct object_array {
5959

6060
/*
6161
* object flag allocation:
62-
* revision.h: 0---------10 2526
62+
* revision.h: 0---------10 25----28
6363
* fetch-pack.c: 01
6464
* negotiator/default.c: 2--5
6565
* walker.c: 0-2
@@ -78,7 +78,7 @@ struct object_array {
7878
* builtin/show-branch.c: 0-------------------------------------------26
7979
* builtin/unpack-objects.c: 2021
8080
*/
81-
#define FLAG_BITS 27
81+
#define FLAG_BITS 29
8282

8383
/*
8484
* The object type is stored in 3 bits.

prio-queue.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,12 @@ void *prio_queue_get(struct prio_queue *queue)
8585
}
8686
return result;
8787
}
88+
89+
void *prio_queue_peek(struct prio_queue *queue)
90+
{
91+
if (!queue->nr)
92+
return NULL;
93+
if (!queue->compare)
94+
return queue->array[queue->nr - 1].data;
95+
return queue->array[0].data;
96+
}

prio-queue.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ extern void prio_queue_put(struct prio_queue *, void *thing);
4646
*/
4747
extern void *prio_queue_get(struct prio_queue *);
4848

49+
/*
50+
* Gain access to the "thing" that would be returned by
51+
* prio_queue_get, but do not remove it from the queue.
52+
*/
53+
extern void *prio_queue_peek(struct prio_queue *);
54+
4955
extern void clear_prio_queue(struct prio_queue *);
5056

5157
/* Reverse the LIFO elements */

0 commit comments

Comments
 (0)