commit-graph: fix GRAPH_MIN_SIZE
The GRAPH_MIN_SIZE macro should be the smallest size of a parsable commit-graph file. However, the minimum number of chunks was wrong. It is possible to write a commit-graph file with zero commits, and that violates this macro's value. Rewrite the macro, and use extra macros to better explain the magic constants. 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
0e3b97cccbec2bd01eae4b3267bf00a9bfb277d8
1 file changed
+3
-2
commit-graph.c
+3
-2
@@ -35,10 +35,11 @@
35
36
#define GRAPH_LAST_EDGE 0x80000000
37
38
+#define GRAPH_HEADER_SIZE 8
39
#define GRAPH_FANOUT_SIZE (4 * 256)
40
#define GRAPH_CHUNKLOOKUP_WIDTH 12
40
-#define GRAPH_MIN_SIZE (5 * GRAPH_CHUNKLOOKUP_WIDTH + GRAPH_FANOUT_SIZE + \
41
- GRAPH_OID_LEN + 8)
41
+#define GRAPH_MIN_SIZE (GRAPH_HEADER_SIZE + 4 * GRAPH_CHUNKLOOKUP_WIDTH \
42
+ + GRAPH_FANOUT_SIZE + GRAPH_OID_LEN)
43
44
char *get_commit_graph_filename(const char *obj_dir)
45
{