Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use generation numbers for --topo-order #25

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,11 +655,10 @@ struct commit *pop_commit(struct commit_list **stack)
/* count number of children that have not been emitted */
define_commit_slab(indegree_slab, int);

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

static void record_author_date(struct author_date_slab *author_date,
struct commit *commit)
void record_author_date(struct author_date_slab *author_date,
struct commit *commit)
{
const char *buffer = get_commit_buffer(commit, NULL);
struct ident_split ident;
Expand All @@ -684,8 +683,8 @@ static void record_author_date(struct author_date_slab *author_date,
unuse_commit_buffer(commit, buffer);
}

static int compare_commits_by_author_date(const void *a_, const void *b_,
void *cb_data)
int compare_commits_by_author_date(const void *a_, const void *b_,
void *cb_data)
{
const struct commit *a = a_, *b = b_;
struct author_date_slab *author_date = cb_data;
Expand Down
7 changes: 7 additions & 0 deletions commit.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "gpg-interface.h"
#include "string-list.h"
#include "pretty.h"
#include "commit-slab.h"

#define COMMIT_NOT_FROM_GRAPH 0xFFFFFFFF
#define GENERATION_NUMBER_INFINITY 0xFFFFFFFF
Expand Down Expand Up @@ -328,6 +329,12 @@ extern int remove_signature(struct strbuf *buf);
*/
extern int check_commit_signature(const struct commit *commit, struct signature_check *sigc);

/* record author-date for each commit object */
struct author_date_slab;
void record_author_date(struct author_date_slab *author_date,
struct commit *commit);

int compare_commits_by_author_date(const void *a_, const void *b_, void *unused);
int compare_commits_by_commit_date(const void *a_, const void *b_, void *unused);
int compare_commits_by_gen_then_commit_date(const void *a_, const void *b_, void *unused);

Expand Down
4 changes: 2 additions & 2 deletions object.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct object_array {

/*
* object flag allocation:
* revision.h: 0---------10 2526
* revision.h: 0---------10 25----28
* fetch-pack.c: 01
* negotiator/default.c: 2--5
* walker.c: 0-2
Expand All @@ -78,7 +78,7 @@ struct object_array {
* builtin/show-branch.c: 0-------------------------------------------26
* builtin/unpack-objects.c: 2021
*/
#define FLAG_BITS 27
#define FLAG_BITS 29

/*
* The object type is stored in 3 bits.
Expand Down
9 changes: 9 additions & 0 deletions prio-queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,12 @@ void *prio_queue_get(struct prio_queue *queue)
}
return result;
}

void *prio_queue_peek(struct prio_queue *queue)
{
if (!queue->nr)
return NULL;
if (!queue->compare)
return queue->array[queue->nr - 1].data;
return queue->array[0].data;
}
6 changes: 6 additions & 0 deletions prio-queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ extern void prio_queue_put(struct prio_queue *, void *thing);
*/
extern void *prio_queue_get(struct prio_queue *);

/*
* Gain access to the "thing" that would be returned by
* prio_queue_get, but do not remove it from the queue.
*/
extern void *prio_queue_peek(struct prio_queue *);

extern void clear_prio_queue(struct prio_queue *);

/* Reverse the LIFO elements */
Expand Down
Loading