Skip to content

Commit b784e44

Browse files
commit-graph: use corrected commit dates for comparision
With corrected commit dates implemented, we no longer have to rely on commit date as a heuristic in paint_down_to_common(). t6024-recursive-merge setups a unique repository where all commits have the same committer date. As such, using committer date for priority queue essentially transforms it to a FIFO queue. As we use corrected commit date, this is no longer true and effects the order in which commits are merged (A and B, then B and C instead of B and C, then A and B). As such, we need to update oid for intermediate stage commit which fails to be merged. TODO: Update intermediate stage commit oid for sha256 as well. Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 9b3cf51 commit b784e44

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

commit-graph.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,17 @@ int generation_numbers_enabled(struct repository *r)
690690
return !!first_generation;
691691
}
692692

693+
int corrected_commit_dates_enabled(struct repository *r)
694+
{
695+
struct commit_graph *g;
696+
if (!prepare_commit_graph(r))
697+
return 0;
698+
699+
g = r->objects->commit_graph;
700+
701+
return !!g->chunk_generation_data;
702+
}
703+
693704
static void close_commit_graph_one(struct commit_graph *g)
694705
{
695706
if (!g)

commit-graph.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ struct commit_graph *parse_commit_graph(void *graph_map, size_t graph_size);
8888
*/
8989
int generation_numbers_enabled(struct repository *r);
9090

91+
/*
92+
* Return 1 if and only if the repository has a commit-graph
93+
* file and corrected commit date offsets are computed in that file.
94+
*/
95+
int corrected_commit_dates_enabled(struct repository *r);
96+
9197
enum commit_graph_write_flags {
9298
COMMIT_GRAPH_WRITE_APPEND = (1 << 0),
9399
COMMIT_GRAPH_WRITE_PROGRESS = (1 << 1),

commit-reach.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static struct commit_list *paint_down_to_common(struct repository *r,
3939
int i;
4040
timestamp_t last_gen = GENERATION_NUMBER_V2_INFINITY;
4141

42-
if (!min_generation)
42+
if (!min_generation && !corrected_commit_dates_enabled(r))
4343
queue.compare = compare_commits_by_commit_date;
4444

4545
one->object.flags |= PARENT1;

t/t6024-recursive-merge.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ test_expect_success 'setup tests' '
6060
GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F &&
6161
6262
test_oid_cache <<-EOF
63-
idxstage1 sha1:ec3fe2a791706733f2d8fa7ad45d9a9672031f5e
63+
idxstage1 sha1:35e1b0dd0fcb603a1b74f9e651a7069e4dedfd48
6464
idxstage1 sha256:b3c8488929903aaebdeb22270cb6d36e5b8724b01ae0d4da24632f158c99676f
6565
EOF
6666
'

0 commit comments

Comments
 (0)