Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repo-settings: create core.featureAdoptionRate setting
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 'core.featureAdoptionRate' config setting that allows integer values. This is a rating from 0 to 10 for the user's willingness to adopt new or experimental features that improve Git performance. The default is 0, meaning "don't change anything!" A value of 10 would mean "I'm willing for some behavior to change to get the best performance I can get, and can take experimental features in their first release." As we integrate this with more config settings, we will make this scale more clear. This config setting only changes the default values of other config settings. If the setting is given explicitly, then take the explicit value. This change adds these two defaults when core.featureAdoptionRate is at least three: * core.commitGraph=true * gc.writeCommitGraph=true The use of "three or higher" for these settings means that a value of 3 means "I'm willing to add optional features that can augment the data on disk in favor of improved performance, but those features should be stable after being included in multiple major releases." 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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
1 parent
a6a95cd
commit 0a01e97
Showing
8 changed files
with
90 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "cache.h" | ||
#include "repository.h" | ||
#include "config.h" | ||
#include "repo-settings.h" | ||
|
||
#define UPDATE_DEFAULT(s,v) do { if (s == -1) { s = v; } } while(0) | ||
|
||
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.featureadoptionrate")) { | ||
int rate = git_config_int(key, value); | ||
if (rate >= 3) { | ||
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; | ||
} | ||
|
||
void prepare_repo_settings(struct repository *r) | ||
{ | ||
if (r->settings) | ||
return; | ||
|
||
r->settings = xmalloc(sizeof(*r->settings)); | ||
|
||
/* Defaults */ | ||
r->settings->core_commit_graph = -1; | ||
r->settings->gc_write_commit_graph = -1; | ||
|
||
repo_config(r, git_repo_config, r->settings); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef REPO_SETTINGS_H | ||
#define REPO_SETTINGS_H | ||
|
||
struct repo_settings { | ||
char core_commit_graph; | ||
char gc_write_commit_graph; | ||
}; | ||
|
||
struct repository; | ||
|
||
void prepare_repo_settings(struct repository *r); | ||
|
||
#endif /* REPO_SETTINGS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters