@@ -616,3 +616,7 @@ core.size::
+
* `index.version=4` uses prefix-compression to reduce the size of the
.git/index file.
++
+* `pack.useSparse=true` uses the sparse tree-walk algorithm, which is
+optimized for enumerating objects during linkgit:git-push[1] from a
+client machine.
@@ -112,7 +112,8 @@ pack.useSparse::
objects. This can have significant performance benefits when
computing a pack to send a small change. However, it is possible
that extra objects are added to the pack-file if the included
- commits contain certain types of direct renames.
+ commits contain certain types of direct renames. Defaults to
+ false, unless `core.size=large`.
pack.writeBitmaps (deprecated)::
This is a deprecated synonym for `repack.writeBitmaps`.
@@ -34,6 +34,7 @@
#include "dir.h"
#include "midx.h"
#include "trace2.h"
+#include "repo-settings.h"
#define IN_PACK(obj) oe_in_pack(&to_pack, obj)
#define SIZE(obj) oe_size(&to_pack, obj)
@@ -2707,10 +2708,6 @@ static int git_pack_config(const char *k, const char *v, void *cb)
use_bitmap_index_default = git_config_bool(k, v);
return 0;
}
- if (!strcmp(k, "pack.usesparse")) {
- sparse = git_config_bool(k, v);
- return 0;
- }
if (!strcmp(k, "pack.threads")) {
delta_search_threads = git_config_int(k, v);
if (delta_search_threads < 0)
@@ -3330,6 +3327,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
read_replace_refs = 0;
sparse = git_env_bool("GIT_TEST_PACK_SPARSE", 0);
+ prepare_repo_settings(the_repository);
+ if (!sparse && the_repository->settings->pack_use_sparse != -1)
+ sparse = the_repository->settings->pack_use_sparse;
+
reset_pack_idx_option(&pack_idx_opts);
git_config(git_pack_config, NULL);
@@ -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->pack_use_sparse, 1);
UPDATE_DEFAULT(rs->index_version, 4);
}
return 0;
@@ -26,6 +27,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, "pack.usesparse")) {
+ rs->pack_use_sparse = git_config_bool(key, value);
+ return 0;
+ }
if (!strcmp(key, "index.version")) {
rs->index_version = git_config_int(key, value);
return 0;
@@ -44,6 +49,7 @@ void prepare_repo_settings(struct repository *r)
/* Defaults */
r->settings->core_commit_graph = -1;
r->settings->gc_write_commit_graph = -1;
+ r->settings->pack_use_sparse = -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;
+ char pack_use_sparse;
int index_version;
};