@@ -613,3 +613,6 @@ core.size::
+
* `gc.writeCommitGraph=true` eneables writing commit-graph files during
`git gc`.
++
+* `index.version=4` uses prefix-compression to reduce the size of the
+.git/index file.
@@ -24,3 +24,4 @@ index.threads::
index.version::
Specify the version with which new index files should be
initialized. This does not affect existing repositories.
+ If `core.size=large`, then the default value is 4.
@@ -25,6 +25,7 @@
#include "fsmonitor.h"
#include "thread-utils.h"
#include "progress.h"
+#include "repo-settings.h"
/* Mask for the name length in ce_flags in the on-disk index */
@@ -1599,16 +1600,17 @@ struct cache_entry *refresh_cache_entry(struct index_state *istate,
#define INDEX_FORMAT_DEFAULT 3
-static unsigned int get_index_format_default(void)
+static unsigned int get_index_format_default(struct repository *r)
{
char *envversion = getenv("GIT_INDEX_VERSION");
char *endp;
- int value;
unsigned int version = INDEX_FORMAT_DEFAULT;
if (!envversion) {
- if (!git_config_get_int("index.version", &value))
- version = value;
+ prepare_repo_settings(r);
+
+ if (r->settings->index_version >= 0)
+ version = r->settings->index_version;
if (version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < version) {
warning(_("index.version set, but the value is invalid.\n"
"Using version %i"), INDEX_FORMAT_DEFAULT);
@@ -2765,7 +2767,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
}
if (!istate->version) {
- istate->version = get_index_format_default();
+ istate->version = get_index_format_default(the_repository);
if (git_env_bool("GIT_TEST_SPLIT_INDEX", 0))
init_split_index(istate);
}
@@ -14,6 +14,7 @@ static int git_repo_config(const char *key, const char *value, void *cb)
if (!strcmp(value, "large")) {
UPDATE_DEFAULT(rs->core_commit_graph, 1);
UPDATE_DEFAULT(rs->gc_write_commit_graph, 1);
+ UPDATE_DEFAULT(rs->index_version, 4);
}
return 0;
}
@@ -25,6 +26,10 @@ static int git_repo_config(const char *key, const char *value, void *cb)
rs->gc_write_commit_graph = git_config_bool(key, value);
return 0;
}
+ if (!strcmp(key, "index.version")) {
+ rs->index_version = git_config_int(key, value);
+ return 0;
+ }
return 1;
}
@@ -39,6 +44,7 @@ void prepare_repo_settings(struct repository *r)
/* Defaults */
r->settings->core_commit_graph = -1;
r->settings->gc_write_commit_graph = -1;
+ r->settings->index_version = -1;
repo_config(r, git_repo_config, r->settings);
}
@@ -4,6 +4,7 @@
struct repo_settings {
char core_commit_graph;
char gc_write_commit_graph;
+ int index_version;
};
struct repository;