Skip to content

Commit e86f304

Browse files
committed
commit/revisions: bookkeeping before refactoring
There are a few things that need to move around a little before making a big refactoring in the topo-order logic: 1. We need access to record_author_date() and compare_commits_by_author_date() in revision.c. These are used currently by sort_in_topological_order() in commit.c. 2. Moving these methods to commit.h requires adding the author_slab definition to commit.h. 3. The add_parents_to_list() method in revision.c performs logic around the UNINTERESTING flag and other special cases depending on the struct rev_info. Allow this method to ignore a NULL 'list' parameter, as we will not be populating the list for our walk. Signed-off-by: Derrick Stolee <[email protected]>
1 parent fd1a0ab commit e86f304

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

commit.c

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

658-
/* record author-date for each commit object */
659-
define_commit_slab(author_date_slab, timestamp_t);
660-
661-
static void record_author_date(struct author_date_slab *author_date,
662-
struct commit *commit)
658+
void record_author_date(struct author_date_slab *author_date,
659+
struct commit *commit)
663660
{
664661
const char *buffer = get_commit_buffer(commit, NULL);
665662
struct ident_split ident;
@@ -684,8 +681,8 @@ static void record_author_date(struct author_date_slab *author_date,
684681
unuse_commit_buffer(commit, buffer);
685682
}
686683

687-
static int compare_commits_by_author_date(const void *a_, const void *b_,
688-
void *cb_data)
684+
int compare_commits_by_author_date(const void *a_, const void *b_,
685+
void *cb_data)
689686
{
690687
const struct commit *a = a_, *b = b_;
691688
struct author_date_slab *author_date = cb_data;

commit.h

Lines changed: 8 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
@@ -328,6 +329,13 @@ extern int remove_signature(struct strbuf *buf);
328329
*/
329330
extern int check_commit_signature(const struct commit *commit, struct signature_check *sigc);
330331

332+
/* record author-date for each commit object */
333+
define_commit_slab(author_date_slab, timestamp_t);
334+
335+
void record_author_date(struct author_date_slab *author_date,
336+
struct commit *commit);
337+
338+
int compare_commits_by_author_date(const void *a_, const void *b_, void *unused);
331339
int compare_commits_by_commit_date(const void *a_, const void *b_, void *unused);
332340
int compare_commits_by_gen_then_commit_date(const void *a_, const void *b_, void *unused);
333341

revision.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,8 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
808808
if (p->object.flags & SEEN)
809809
continue;
810810
p->object.flags |= SEEN;
811-
commit_list_insert_by_date_cached(p, list, cached_base, cache_ptr);
811+
if (list)
812+
commit_list_insert_by_date_cached(p, list, cached_base, cache_ptr);
812813
}
813814
return 0;
814815
}
@@ -847,7 +848,8 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
847848
p->object.flags |= left_flag;
848849
if (!(p->object.flags & SEEN)) {
849850
p->object.flags |= SEEN;
850-
commit_list_insert_by_date_cached(p, list, cached_base, cache_ptr);
851+
if (list)
852+
commit_list_insert_by_date_cached(p, list, cached_base, cache_ptr);
851853
}
852854
if (revs->first_parent_only)
853855
break;

0 commit comments

Comments
 (0)