commit-graph: turn a group of write-related macro flags into an enum

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Acked-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Aug 5, 2019 at 10:02 UTC 39d88318569188c0544c3c0f8207f2e1b1829e60
4 files changed +18 -14
builtin/commit-graph.c
+3 -3
@@ -154,7 +154,7 @@ static int graph_write(int argc, const char **argv)
154 struct string_list *commit_hex = NULL;
155 struct string_list lines;
156 int result = 0;
157 - unsigned int flags = COMMIT_GRAPH_PROGRESS;
157 + enum commit_graph_write_flags flags = COMMIT_GRAPH_WRITE_PROGRESS;
158
159 static struct option builtin_commit_graph_write_options[] = {
160 OPT_STRING(0, "object-dir", &opts.obj_dir,
@@ -192,9 +192,9 @@ static int graph_write(int argc, const char **argv)
192 if (!opts.obj_dir)
193 opts.obj_dir = get_object_directory();
194 if (opts.append)
195 - flags |= COMMIT_GRAPH_APPEND;
195 + flags |= COMMIT_GRAPH_WRITE_APPEND;
196 if (opts.split)
197 - flags |= COMMIT_GRAPH_SPLIT;
197 + flags |= COMMIT_GRAPH_WRITE_SPLIT;
198
199 read_replace_refs = 0;
200
builtin/gc.c
+1 -1
@@ -687,7 +687,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
687
688 if (gc_write_commit_graph &&
689 write_commit_graph_reachable(get_object_directory(),
690 - !quiet && !daemonized ? COMMIT_GRAPH_PROGRESS : 0,
690 + !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
691 NULL))
692 return 1;
693
commit-graph.c
+6 -5
@@ -1133,7 +1133,8 @@ static int add_ref_to_list(const char *refname,
1133 return 0;
1134 }
1135
1136 -int write_commit_graph_reachable(const char *obj_dir, unsigned int flags,
1136 +int write_commit_graph_reachable(const char *obj_dir,
1137 + enum commit_graph_write_flags flags,
1138 const struct split_commit_graph_opts *split_opts)
1139 {
1140 struct string_list list = STRING_LIST_INIT_DUP;
@@ -1750,7 +1751,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
1751 int write_commit_graph(const char *obj_dir,
1752 struct string_list *pack_indexes,
1753 struct string_list *commit_hex,
1753 - unsigned int flags,
1754 + enum commit_graph_write_flags flags,
1755 const struct split_commit_graph_opts *split_opts)
1756 {
1757 struct write_commit_graph_context *ctx;
@@ -1771,9 +1772,9 @@ int write_commit_graph(const char *obj_dir,
1772 if (len && ctx->obj_dir[len - 1] == '/')
1773 ctx->obj_dir[len - 1] = 0;
1774
1774 - ctx->append = flags & COMMIT_GRAPH_APPEND ? 1 : 0;
1775 - ctx->report_progress = flags & COMMIT_GRAPH_PROGRESS ? 1 : 0;
1776 - ctx->split = flags & COMMIT_GRAPH_SPLIT ? 1 : 0;
1775 + ctx->append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0;
1776 + ctx->report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0;
1777 + ctx->split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0;
1778 ctx->split_opts = split_opts;
1779
1780 if (ctx->split) {
commit-graph.h
+8 -5
@@ -71,9 +71,11 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
71 */
72 int generation_numbers_enabled(struct repository *r);
73
74 -#define COMMIT_GRAPH_APPEND (1 << 0)
75 -#define COMMIT_GRAPH_PROGRESS (1 << 1)
76 -#define COMMIT_GRAPH_SPLIT (1 << 2)
74 +enum commit_graph_write_flags {
75 + COMMIT_GRAPH_WRITE_APPEND = (1 << 0),
76 + COMMIT_GRAPH_WRITE_PROGRESS = (1 << 1),
77 + COMMIT_GRAPH_WRITE_SPLIT = (1 << 2)
78 +};
79
80 struct split_commit_graph_opts {
81 int size_multiple;
@@ -87,12 +89,13 @@ struct split_commit_graph_opts {
89 * is not compatible with the commit-graph feature, then the
90 * methods will return 0 without writing a commit-graph.
91 */
90 -int write_commit_graph_reachable(const char *obj_dir, unsigned int flags,
92 +int write_commit_graph_reachable(const char *obj_dir,
93 + enum commit_graph_write_flags flags,
94 const struct split_commit_graph_opts *split_opts);
95 int write_commit_graph(const char *obj_dir,
96 struct string_list *pack_indexes,
97 struct string_list *commit_hex,
95 - unsigned int flags,
98 + enum commit_graph_write_flags flags,
99 const struct split_commit_graph_opts *split_opts);
100
101 #define COMMIT_GRAPH_VERIFY_SHALLOW (1 << 0)