Skip to content

Commit 88968eb

Browse files
derrickstoleegitster
authored andcommitted
commit-graph: verify commit date
Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1373e54 commit 88968eb

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

commit-graph.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,12 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
986986
oid_to_hex(&cur_oid),
987987
graph_commit->generation,
988988
max_generation + 1);
989+
990+
if (graph_commit->date != odb_commit->date)
991+
graph_report("commit date for commit %s in commit-graph is %"PRItime" != %"PRItime,
992+
oid_to_hex(&cur_oid),
993+
graph_commit->date,
994+
odb_commit->date);
989995
}
990996

991997
return verify_commit_graph_error;

t/t5318-commit-graph.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ GRAPH_BYTE_COMMIT_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN))
273273
GRAPH_BYTE_COMMIT_EXTRA_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 4))
274274
GRAPH_BYTE_COMMIT_WRONG_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 3))
275275
GRAPH_BYTE_COMMIT_GENERATION=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 11))
276+
GRAPH_BYTE_COMMIT_DATE=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 12))
276277

277278
# usage: corrupt_graph_and_verify <position> <data> <string>
278279
# Manipulates the commit-graph file at the position
@@ -377,4 +378,9 @@ test_expect_success 'detect incorrect generation number' '
377378
"non-zero generation number"
378379
'
379380

381+
test_expect_success 'detect incorrect commit date' '
382+
corrupt_graph_and_verify $GRAPH_BYTE_COMMIT_DATE "\01" \
383+
"commit date"
384+
'
385+
380386
test_done

0 commit comments

Comments
 (0)