Re: [PATCH 01/11] repo-settings: create repo.size=large setting
On 6/3/2019 4:18 PM, Derrick Stolee via GitGitGadget wrote:
Show 27 quoted lines
> From: Derrick Stolee <dstolee@microsoft.com>
>
> Several advanced config settings are highly recommended for clients
> using large repositories. Power users learn these one-by-one and
> enable them as they see fit. This could be made simpler, to allow
> more users to have access to these almost-always beneficial features
> (and more beneficial in larger repos).
>
> Create a 'repo.size' config setting whose only accepted value is
> 'large'. When a repo.size=large is given, change the default values
> of some config settings. If the setting is given explicitly, then
> take the explicit value.
>
> This change adds these two defaults to the repo.size=large setting:
>
> * core.commitGraph=true
> * gc.writeCommitGraph=true
>
> To centralize these config options and properly set the defaults,
> create a repo_settings that contains chars for each config variable.
> Use -1 as "unset", with 0 for false and 1 for true.
>
> The prepare_repo_settings() method ensures that this settings
> struct has been initialized, and avoids double-scanning the config
> settings.
>
> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Show 13 quoted lines
> diff --git a/repo-settings.c b/repo-settings.c
> new file mode 100644
> index 0000000000..6f5e18d92e
> --- /dev/null
> +++ b/repo-settings.c
> @@ -0,0 +1,44 @@
> +#include "cache.h"
> +#include "repository.h"
> +#include "config.h"
> +#include "repo-settings.h"
> +
> +
> +#define UPDATE_DEFAULT(s,v) if (s != -1) { s = v; }We should guard this with a "do { ... } while (0)"Show 23 quoted lines
> +
> +static int git_repo_config(const char *key, const char *value, void *cb)
> +{
> + struct repo_settings *rs = (struct repo_settings *)cb;
> +
> + if (!strcmp(key, "core.size")) {
> + if (!strcmp(value, "large")) {
> + UPDATE_DEFAULT(rs->core_commit_graph, 1);
> + UPDATE_DEFAULT(rs->gc_write_commit_graph, 1);
> + }
> + return 0;
> + }
> + if (!strcmp(key, "core.commitgraph")) {
> + rs->core_commit_graph = git_config_bool(key, value);
> + return 0;
> + }
> + if (!strcmp(key, "gc.writecommitgraph")) {
> + rs->gc_write_commit_graph = git_config_bool(key, value);
> + return 0;
> + }
> +
> + return 1;
> +}