commit-graph: rename "large edges" to "extra edges"

The optional 'Large Edge List' chunk of the commit graph file stores parent information for commits with more than two parents, and the names of most of the macros, variables, struct fields, and functions related to this chunk contain the term "large edges", e.g. write_graph_chunk_large_edges(). However, it's not a really great term, as the edges to the second and subsequent parents stored in this chunk are not any larger than the edges to the first and second parents stored in the "main" 'Commit Data' chunk. It's the number of edges, IOW number of parents, that is larger compared to non-merge and "regular" two-parent merge commits. And indeed, two functions in 'commit-graph.c' have a local variable called 'num_extra_edges' that refer to the same thing, and this "extra edges" term is much better at describing these edges. So let's rename all these references to "large edges" in macro, variable, function, etc. names to "extra edges". There is a GRAPH_OCTOPUS_EDGES_NEEDED macro as well; for the sake of consistency rename it to GRAPH_EXTRA_EDGES_NEEDED. We can do so safely without causing any incompatibility issues, because the term "large edges" doesn't come up in the file format itself in any form (the chunk's magic is {'E', 'D', 'G', 'E'}, there is no 'L' in there), but only in the specification text. The string "large edges", however, does come up in the output of 'git commit-graph read' and in tests looking at its input, but that command is explicitly documented as debugging aid, so we can change its output and the affected tests safely. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Jan 19, 2019 at 21:21 UTC 5af7417bd869d935715a56b2ccdee04d3a79a328
5 files changed +24 -24
Documentation/technical/commit-graph-format.txt
+2 -2
@@ -76,7 +76,7 @@ CHUNK DATA:
76 of the ith commit. Stores value 0x7000000 if no parent in that
77 position. If there are more than two parents, the second value
78 has its most-significant bit on and the other bits store an array
79 - position into the Large Edge List chunk.
79 + position into the Extra Edge List chunk.
80 * The next 8 bytes store the generation number of the commit and
81 the commit time in seconds since EPOCH. The generation number
82 uses the higher 30 bits of the first 4 bytes, while the commit
@@ -84,7 +84,7 @@ CHUNK DATA:
84 2 bits of the lowest byte, storing the 33rd and 34th bit of the
85 commit time.
86
87 - Large Edge List (ID: {'E', 'D', 'G', 'E'}) [Optional]
87 + Extra Edge List (ID: {'E', 'D', 'G', 'E'}) [Optional]
88 This list of 4-byte values store the second through nth parents for
89 all octopus merges. The second parent value in the commit data stores
90 an array position within this list along with the most-significant bit
builtin/commit-graph.c
+2 -2
@@ -110,8 +110,8 @@ static int graph_read(int argc, const char **argv)
110 printf(" oid_lookup");
111 if (graph->chunk_commit_data)
112 printf(" commit_metadata");
113 - if (graph->chunk_large_edges)
114 - printf(" large_edges");
113 + if (graph->chunk_extra_edges)
114 + printf(" extra_edges");
115 printf("\n");
116
117 UNLEAK(graph);
commit-graph.c
+12 -12
@@ -21,7 +21,7 @@
21 #define GRAPH_CHUNKID_OIDFANOUT 0x4f494446 /* "OIDF" */
22 #define GRAPH_CHUNKID_OIDLOOKUP 0x4f49444c /* "OIDL" */
23 #define GRAPH_CHUNKID_DATA 0x43444154 /* "CDAT" */
24 -#define GRAPH_CHUNKID_LARGEEDGES 0x45444745 /* "EDGE" */
24 +#define GRAPH_CHUNKID_EXTRAEDGES 0x45444745 /* "EDGE" */
25
26 #define GRAPH_DATA_WIDTH 36
27
@@ -33,7 +33,7 @@
33 #define GRAPH_OID_VERSION GRAPH_OID_VERSION_SHA1
34 #define GRAPH_OID_LEN GRAPH_OID_LEN_SHA1
35
36 -#define GRAPH_OCTOPUS_EDGES_NEEDED 0x80000000
36 +#define GRAPH_EXTRA_EDGES_NEEDED 0x80000000
37 #define GRAPH_PARENT_MISSING 0x7fffffff
38 #define GRAPH_EDGE_LAST_MASK 0x7fffffff
39 #define GRAPH_PARENT_NONE 0x70000000
@@ -177,11 +177,11 @@ struct commit_graph *load_commit_graph_one(const char *graph_file)
177 graph->chunk_commit_data = data + chunk_offset;
178 break;
179
180 - case GRAPH_CHUNKID_LARGEEDGES:
181 - if (graph->chunk_large_edges)
180 + case GRAPH_CHUNKID_EXTRAEDGES:
181 + if (graph->chunk_extra_edges)
182 chunk_repeated = 1;
183 else
184 - graph->chunk_large_edges = data + chunk_offset;
184 + graph->chunk_extra_edges = data + chunk_offset;
185 break;
186 }
187
@@ -343,12 +343,12 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin
343 edge_value = get_be32(commit_data + g->hash_len + 4);
344 if (edge_value == GRAPH_PARENT_NONE)
345 return 1;
346 - if (!(edge_value & GRAPH_OCTOPUS_EDGES_NEEDED)) {
346 + if (!(edge_value & GRAPH_EXTRA_EDGES_NEEDED)) {
347 pptr = insert_parent_or_die(g, edge_value, pptr);
348 return 1;
349 }
350
351 - parent_data_ptr = (uint32_t*)(g->chunk_large_edges +
351 + parent_data_ptr = (uint32_t*)(g->chunk_extra_edges +
352 4 * (uint64_t)(edge_value & GRAPH_EDGE_LAST_MASK));
353 do {
354 edge_value = get_be32(parent_data_ptr);
@@ -504,7 +504,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
504 if (!parent)
505 edge_value = GRAPH_PARENT_NONE;
506 else if (parent->next)
507 - edge_value = GRAPH_OCTOPUS_EDGES_NEEDED | num_extra_edges;
507 + edge_value = GRAPH_EXTRA_EDGES_NEEDED | num_extra_edges;
508 else {
509 edge_value = sha1_pos(parent->item->object.oid.hash,
510 commits,
@@ -516,7 +516,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
516
517 hashwrite_be32(f, edge_value);
518
519 - if (edge_value & GRAPH_OCTOPUS_EDGES_NEEDED) {
519 + if (edge_value & GRAPH_EXTRA_EDGES_NEEDED) {
520 do {
521 num_extra_edges++;
522 parent = parent->next;
@@ -537,7 +537,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
537 }
538 }
539
540 -static void write_graph_chunk_large_edges(struct hashfile *f,
540 +static void write_graph_chunk_extra_edges(struct hashfile *f,
541 struct commit **commits,
542 int nr_commits)
543 {
@@ -923,7 +923,7 @@ void write_commit_graph(const char *obj_dir,
923 chunk_ids[1] = GRAPH_CHUNKID_OIDLOOKUP;
924 chunk_ids[2] = GRAPH_CHUNKID_DATA;
925 if (num_extra_edges)
926 - chunk_ids[3] = GRAPH_CHUNKID_LARGEEDGES;
926 + chunk_ids[3] = GRAPH_CHUNKID_EXTRAEDGES;
927 else
928 chunk_ids[3] = 0;
929 chunk_ids[4] = 0;
@@ -946,7 +946,7 @@ void write_commit_graph(const char *obj_dir,
946 write_graph_chunk_fanout(f, commits.list, commits.nr);
947 write_graph_chunk_oids(f, GRAPH_OID_LEN, commits.list, commits.nr);
948 write_graph_chunk_data(f, GRAPH_OID_LEN, commits.list, commits.nr);
949 - write_graph_chunk_large_edges(f, commits.list, commits.nr);
949 + write_graph_chunk_extra_edges(f, commits.list, commits.nr);
950
951 close_commit_graph(the_repository);
952 finalize_hashfile(f, NULL, CSUM_HASH_IN_STREAM | CSUM_FSYNC);
commit-graph.h
+1 -1
@@ -49,7 +49,7 @@ struct commit_graph {
49 const uint32_t *chunk_oid_fanout;
50 const unsigned char *chunk_oid_lookup;
51 const unsigned char *chunk_commit_data;
52 - const unsigned char *chunk_large_edges;
52 + const unsigned char *chunk_extra_edges;
53 };
54
55 struct commit_graph *load_commit_graph_one(const char *graph_file);
t/t5318-commit-graph.sh
+7 -7
@@ -122,7 +122,7 @@ test_expect_success 'write graph with merges' '
122 cd "$TRASH_DIRECTORY/full" &&
123 git commit-graph write &&
124 test_path_is_file $objdir/info/commit-graph &&
125 - graph_read_expect "10" "large_edges"
125 + graph_read_expect "10" "extra_edges"
126 '
127
128 graph_git_behavior 'merge 1 vs 2' full merge/1 merge/2
@@ -157,7 +157,7 @@ test_expect_success 'write graph with new commit' '
157 cd "$TRASH_DIRECTORY/full" &&
158 git commit-graph write &&
159 test_path_is_file $objdir/info/commit-graph &&
160 - graph_read_expect "11" "large_edges"
160 + graph_read_expect "11" "extra_edges"
161 '
162
163 graph_git_behavior 'full graph, commit 8 vs merge 1' full commits/8 merge/1
@@ -167,7 +167,7 @@ test_expect_success 'write graph with nothing new' '
167 cd "$TRASH_DIRECTORY/full" &&
168 git commit-graph write &&
169 test_path_is_file $objdir/info/commit-graph &&
170 - graph_read_expect "11" "large_edges"
170 + graph_read_expect "11" "extra_edges"
171 '
172
173 graph_git_behavior 'cleared graph, commit 8 vs merge 1' full commits/8 merge/1
@@ -177,7 +177,7 @@ test_expect_success 'build graph from latest pack with closure' '
177 cd "$TRASH_DIRECTORY/full" &&
178 cat new-idx | git commit-graph write --stdin-packs &&
179 test_path_is_file $objdir/info/commit-graph &&
180 - graph_read_expect "9" "large_edges"
180 + graph_read_expect "9" "extra_edges"
181 '
182
183 graph_git_behavior 'graph from pack, commit 8 vs merge 1' full commits/8 merge/1
@@ -200,7 +200,7 @@ test_expect_success 'build graph from commits with append' '
200 cd "$TRASH_DIRECTORY/full" &&
201 git rev-parse merge/3 | git commit-graph write --stdin-commits --append &&
202 test_path_is_file $objdir/info/commit-graph &&
203 - graph_read_expect "10" "large_edges"
203 + graph_read_expect "10" "extra_edges"
204 '
205
206 graph_git_behavior 'append graph, commit 8 vs merge 1' full commits/8 merge/1
@@ -210,7 +210,7 @@ test_expect_success 'build graph using --reachable' '
210 cd "$TRASH_DIRECTORY/full" &&
211 git commit-graph write --reachable &&
212 test_path_is_file $objdir/info/commit-graph &&
213 - graph_read_expect "11" "large_edges"
213 + graph_read_expect "11" "extra_edges"
214 '
215
216 graph_git_behavior 'append graph, commit 8 vs merge 1' full commits/8 merge/1
@@ -231,7 +231,7 @@ test_expect_success 'write graph in bare repo' '
231 cd "$TRASH_DIRECTORY/bare" &&
232 git commit-graph write &&
233 test_path_is_file $baredir/info/commit-graph &&
234 - graph_read_expect "11" "large_edges"
234 + graph_read_expect "11" "extra_edges"
235 '
236
237 graph_git_behavior 'bare repo with graph, commit 8 vs merge 1' bare commits/8 merge/1