]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph: verify commit date
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 27 Jun 2018 13:24:40 +0000 (09:24 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Jun 2018 17:29:10 +0000 (10:29 -0700)
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c
t/t5318-commit-graph.sh

index de656ebbaff88d692fc26b3f8a57d3d8798070ba..3ac28b5eb5c63fd081424fa8354ca15d3dc58cc8 100644 (file)
@@ -986,6 +986,12 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
                                     oid_to_hex(&cur_oid),
                                     graph_commit->generation,
                                     max_generation + 1);
+
+               if (graph_commit->date != odb_commit->date)
+                       graph_report("commit date for commit %s in commit-graph is %"PRItime" != %"PRItime,
+                                    oid_to_hex(&cur_oid),
+                                    graph_commit->date,
+                                    odb_commit->date);
        }
 
        return verify_commit_graph_error;
index 3128e19aef4ad9ab490283d6842321fe026ad2a6..2c65e6a95cc2af085530609add54b9ae103096cc 100755 (executable)
@@ -273,6 +273,7 @@ GRAPH_BYTE_COMMIT_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN))
 GRAPH_BYTE_COMMIT_EXTRA_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 4))
 GRAPH_BYTE_COMMIT_WRONG_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 3))
 GRAPH_BYTE_COMMIT_GENERATION=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 11))
+GRAPH_BYTE_COMMIT_DATE=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 12))
 
 # usage: corrupt_graph_and_verify <position> <data> <string>
 # Manipulates the commit-graph file at the position
@@ -377,4 +378,9 @@ test_expect_success 'detect incorrect generation number' '
                "non-zero generation number"
 '
 
+test_expect_success 'detect incorrect commit date' '
+       corrupt_graph_and_verify $GRAPH_BYTE_COMMIT_DATE "\01" \
+               "commit date"
+'
+
 test_done