Re: [PATCH v2 10/11] maintenance: add auto condition for commit-graph task
- From
- Jonathan Tan <jonathantanmy@google.com>
- Date
- Aug 19, 2020, 00:09 UTC
- Message-ID
- <20200819000947.2844392-1-jonathantanmy@google.com>
- In-Reply-To
- <fc097c389a963065fc0bb5991bdebdca8824b121.1597760589.git.gitgitgadget@gmail.com>
> Instead of writing a new commit-graph in every 'git maintenance run > --auto' process (when maintenance.commit-graph.enalbed is configured to
s/enalbed/enabled/
> +/* Remember to update object flag allocation in object.h */ > +#define PARENT1 (1u<<16)
Why this name? "SEEN" seems perfectly fine.
Show 7 quoted lines
> +static int num_commits_not_in_graph = 0;
> +static int limit_commits_not_in_graph = 100;
> +
> +static int dfs_on_ref(const char *refname,
> + const struct object_id *oid, int flags,
> + void *cb_data)
> +{[snip]
Show 13 quoted lines
> +static int should_write_commit_graph(void)
> +{
> + int result;
> +
> + git_config_get_int("maintenance.commit-graph.auto",
> + &limit_commits_not_in_graph);
> +
> + if (!limit_commits_not_in_graph)
> + return 0;
> + if (limit_commits_not_in_graph < 0)
> + return 1;
> +
> + result = for_each_ref(dfs_on_ref, NULL);I don't like introducing the mutable global num_commits_not_in_graph especially when there seems to be at least one easy alternative (e.g. putting it in cb_data) but I know that this is a pattern than existing code.