commit-graph: verify commit date

Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Jun 27, 2018 at 09:24 UTC 88968ebf86d9b4524b17f6684dd8c67f0c6df652
2 files changed +12
commit-graph.c
+6
@@ -986,6 +986,12 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
986 oid_to_hex(&cur_oid),
987 graph_commit->generation,
988 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);
995 }
996
997 return verify_commit_graph_error;
t/t5318-commit-graph.sh
+6
@@ -273,6 +273,7 @@ GRAPH_BYTE_COMMIT_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN))
273 GRAPH_BYTE_COMMIT_EXTRA_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 4))
274 GRAPH_BYTE_COMMIT_WRONG_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 3))
275 GRAPH_BYTE_COMMIT_GENERATION=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 11))
276 +GRAPH_BYTE_COMMIT_DATE=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 12))
277
278 # usage: corrupt_graph_and_verify <position> <data> <string>
279 # Manipulates the commit-graph file at the position
@@ -377,4 +378,9 @@ test_expect_success 'detect incorrect generation number' '
378 "non-zero generation number"
379 '
380
381 +test_expect_success 'detect incorrect commit date' '
382 + corrupt_graph_and_verify $GRAPH_BYTE_COMMIT_DATE "\01" \
383 + "commit date"
384 +'
385 +
386 test_done