commit-graph: collapse parameters into flags

The write_commit_graph() and write_commit_graph_reachable() methods
currently take two boolean parameters: 'append' and 'report_progress'.
As we update these methods, adding more parameters this way becomes
cluttered and hard to maintain.

Collapse these parameters into a 'flags' parameter, and adjust the
callers to provide flags as necessary.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Derrick Stolee
2019-06-12 06:29:38 -07:00
committed by Junio C Hamano
parent e103f7276f
commit 5af8039452
5 changed files with 18 additions and 13 deletions

View File

@ -851,15 +851,14 @@ static int add_ref_to_list(const char *refname,
return 0;
}
int write_commit_graph_reachable(const char *obj_dir, int append,
int report_progress)
int write_commit_graph_reachable(const char *obj_dir, unsigned int flags)
{
struct string_list list = STRING_LIST_INIT_DUP;
int result;
for_each_ref(add_ref_to_list, &list);
result = write_commit_graph(obj_dir, NULL, &list,
append, report_progress);
flags);
string_list_clear(&list, 0);
return result;
@ -868,7 +867,7 @@ int write_commit_graph_reachable(const char *obj_dir, int append,
int write_commit_graph(const char *obj_dir,
struct string_list *pack_indexes,
struct string_list *commit_hex,
int append, int report_progress)
unsigned int flags)
{
struct packed_oid_list oids;
struct packed_commit_list commits;
@ -887,6 +886,8 @@ int write_commit_graph(const char *obj_dir,
struct strbuf progress_title = STRBUF_INIT;
unsigned long approx_nr_objects;
int res = 0;
int append = flags & COMMIT_GRAPH_APPEND;
int report_progress = flags & COMMIT_GRAPH_PROGRESS;
if (!commit_graph_compatible(the_repository))
return 0;