Skip to content

Commit 39d8831

Browse files
szedergitster
authored andcommitted
commit-graph: turn a group of write-related macro flags into an enum
Signed-off-by: SZEDER Gábor <[email protected]> Acked-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9916073 commit 39d8831

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

builtin/commit-graph.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static int graph_write(int argc, const char **argv)
154154
struct string_list *commit_hex = NULL;
155155
struct string_list lines;
156156
int result = 0;
157-
unsigned int flags = COMMIT_GRAPH_PROGRESS;
157+
enum commit_graph_write_flags flags = COMMIT_GRAPH_WRITE_PROGRESS;
158158

159159
static struct option builtin_commit_graph_write_options[] = {
160160
OPT_STRING(0, "object-dir", &opts.obj_dir,
@@ -192,9 +192,9 @@ static int graph_write(int argc, const char **argv)
192192
if (!opts.obj_dir)
193193
opts.obj_dir = get_object_directory();
194194
if (opts.append)
195-
flags |= COMMIT_GRAPH_APPEND;
195+
flags |= COMMIT_GRAPH_WRITE_APPEND;
196196
if (opts.split)
197-
flags |= COMMIT_GRAPH_SPLIT;
197+
flags |= COMMIT_GRAPH_WRITE_SPLIT;
198198

199199
read_replace_refs = 0;
200200

builtin/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
687687

688688
if (gc_write_commit_graph &&
689689
write_commit_graph_reachable(get_object_directory(),
690-
!quiet && !daemonized ? COMMIT_GRAPH_PROGRESS : 0,
690+
!quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
691691
NULL))
692692
return 1;
693693

commit-graph.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,8 @@ static int add_ref_to_list(const char *refname,
11331133
return 0;
11341134
}
11351135

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,
11371138
const struct split_commit_graph_opts *split_opts)
11381139
{
11391140
struct string_list list = STRING_LIST_INIT_DUP;
@@ -1750,7 +1751,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
17501751
int write_commit_graph(const char *obj_dir,
17511752
struct string_list *pack_indexes,
17521753
struct string_list *commit_hex,
1753-
unsigned int flags,
1754+
enum commit_graph_write_flags flags,
17541755
const struct split_commit_graph_opts *split_opts)
17551756
{
17561757
struct write_commit_graph_context *ctx;
@@ -1771,9 +1772,9 @@ int write_commit_graph(const char *obj_dir,
17711772
if (len && ctx->obj_dir[len - 1] == '/')
17721773
ctx->obj_dir[len - 1] = 0;
17731774

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;
17771778
ctx->split_opts = split_opts;
17781779

17791780
if (ctx->split) {

commit-graph.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd,
7171
*/
7272
int generation_numbers_enabled(struct repository *r);
7373

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+
};
7779

7880
struct split_commit_graph_opts {
7981
int size_multiple;
@@ -87,12 +89,13 @@ struct split_commit_graph_opts {
8789
* is not compatible with the commit-graph feature, then the
8890
* methods will return 0 without writing a commit-graph.
8991
*/
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,
9194
const struct split_commit_graph_opts *split_opts);
9295
int write_commit_graph(const char *obj_dir,
9396
struct string_list *pack_indexes,
9497
struct string_list *commit_hex,
95-
unsigned int flags,
98+
enum commit_graph_write_flags flags,
9699
const struct split_commit_graph_opts *split_opts);
97100

98101
#define COMMIT_GRAPH_VERIFY_SHALLOW (1 << 0)

0 commit comments

Comments
 (0)