test-read-graph: include extra post-parse info

It can be helpful to verify that the 'struct commit_graph' that results from parsing a commit-graph is correctly structured. The existence of different chunks is not enough to verify that all of the optional features are correctly enabled. Update 'test-tool read-graph' to output an "options:" line that includes information for different parts of the struct commit_graph. In particular, this change demonstrates that the read_generation_data option is never being enabled, which will be fixed in a later change. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Mar 1, 2022 at 19:48 UTC c78c7a959cacf20eb55a694ed9e20921afb306cf
4 files changed +20
t/helper/test-read-graph.c
+13
@@ -3,6 +3,7 @@
3 #include "commit-graph.h"
4 #include "repository.h"
5 #include "object-store.h"
6 +#include "bloom.h"
7
8 int cmd__read_graph(int argc, const char **argv)
9 {
@@ -45,6 +46,18 @@ int cmd__read_graph(int argc, const char **argv)
46 printf(" bloom_data");
47 printf("\n");
48
49 + printf("options:");
50 + if (graph->bloom_filter_settings)
51 + printf(" bloom(%"PRIu32",%"PRIu32",%"PRIu32")",
52 + graph->bloom_filter_settings->hash_version,
53 + graph->bloom_filter_settings->bits_per_entry,
54 + graph->bloom_filter_settings->num_hashes);
55 + if (graph->read_generation_data)
56 + printf(" read_generation_data");
57 + if (graph->topo_levels)
58 + printf(" topo_levels");
59 + printf("\n");
60 +
61 UNLEAK(graph);
62
63 return 0;
t/t4216-log-bloom.sh
+1
@@ -48,6 +48,7 @@ graph_read_expect () {
48 header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0
49 num_commits: $1
50 chunks: oid_fanout oid_lookup commit_metadata generation_data bloom_indexes bloom_data
51 + options: bloom(1,10,7)
52 EOF
53 test-tool read-graph >actual &&
54 test_cmp expect actual
t/t5318-commit-graph.sh
+1
@@ -104,6 +104,7 @@ graph_read_expect() {
104 header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0
105 num_commits: $1
106 chunks: oid_fanout oid_lookup commit_metadata$OPTIONAL
107 + options:
108 EOF
109 test-tool read-graph >output &&
110 test_cmp expect output
t/t5324-split-commit-graph.sh
+5
@@ -34,6 +34,7 @@ graph_read_expect() {
34 header: 43475048 1 $(test_oid oid_version) 4 $NUM_BASE
35 num_commits: $1
36 chunks: oid_fanout oid_lookup commit_metadata generation_data
37 + options:
38 EOF
39 test-tool read-graph >output &&
40 test_cmp expect output
@@ -508,6 +509,7 @@ test_expect_success 'setup repo for mixed generation commit-graph-chain' '
509 header: 43475048 1 $(test_oid oid_version) 4 1
510 num_commits: $NUM_SECOND_LAYER_COMMITS
511 chunks: oid_fanout oid_lookup commit_metadata
512 + options:
513 EOF
514 test_cmp expect output &&
515 git commit-graph verify &&
@@ -540,6 +542,7 @@ test_expect_success 'do not write generation data chunk if not present on existi
542 header: 43475048 1 $(test_oid oid_version) 4 2
543 num_commits: $NUM_THIRD_LAYER_COMMITS
544 chunks: oid_fanout oid_lookup commit_metadata
545 + options:
546 EOF
547 test_cmp expect output &&
548 git commit-graph verify
@@ -581,6 +584,7 @@ test_expect_success 'do not write generation data chunk if the topmost remaining
584 header: 43475048 1 $(test_oid oid_version) 4 2
585 num_commits: $(($NUM_THIRD_LAYER_COMMITS + $NUM_FOURTH_LAYER_COMMITS))
586 chunks: oid_fanout oid_lookup commit_metadata
587 + options:
588 EOF
589 test_cmp expect output &&
590 git commit-graph verify
@@ -620,6 +624,7 @@ test_expect_success 'write generation data chunk if topmost remaining layer has
624 header: 43475048 1 $(test_oid oid_version) 5 1
625 num_commits: $(($NUM_SECOND_LAYER_COMMITS + $NUM_THIRD_LAYER_COMMITS + $NUM_FOURTH_LAYER_COMMITS + $NUM_FIFTH_LAYER_COMMITS))
626 chunks: oid_fanout oid_lookup commit_metadata generation_data
627 + options:
628 EOF
629 test_cmp expect output
630 )