pack-objects: create pack.useSparse setting
The '--sparse' flag in 'git pack-objects' changes the algorithm used to enumerate objects to one that is faster for individual users pushing new objects that change only a small cone of the working directory. The sparse algorithm is not recommended for a server, which likely sends new objects that appear across the entire working directory. Create a 'pack.useSparse' setting that enables this new algorithm. This allows 'git push' to use this algorithm without passing a '--sparse' flag all the way through four levels of run_command() calls. If the '--no-sparse' flag is set, then this config setting is overridden. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Jan 16, 2019 at 10:26 UTC
3d036eb0d2c778941cd31b8785d5036949e8778b
3 files changed
+28
Documentation/config/pack.txt
+9
@@ -105,6 +105,15 @@ pack.useBitmaps::
105
true. You should not generally need to turn this off unless
106
you are debugging pack bitmaps.
107
108
+pack.useSparse::
109
+ When true, git will default to using the '--sparse' option in
110
+ 'git pack-objects' when the '--revs' option is present. This
111
+ algorithm only walks trees that appear in paths that introduce new
112
+ objects. This can have significant performance benefits when
113
+ computing a pack to send a small change. However, it is possible
114
+ that extra objects are added to the pack-file if the included
115
+ commits contain certain types of direct renames.
116
+
117
pack.writeBitmaps (deprecated)::
118
This is a deprecated synonym for `repack.writeBitmaps`.
119
builtin/pack-objects.c
+4
@@ -2711,6 +2711,10 @@ static int git_pack_config(const char *k, const char *v, void *cb)
2711
use_bitmap_index_default = git_config_bool(k, v);
2712
return 0;
2713
}
2714
+ if (!strcmp(k, "pack.usesparse")) {
2715
+ sparse = git_config_bool(k, v);
2716
+ return 0;
2717
+ }
2718
if (!strcmp(k, "pack.threads")) {
2719
delta_search_threads = git_config_int(k, v);
2720
if (delta_search_threads < 0)
t/t5322-pack-objects-sparse.sh
+15
@@ -118,4 +118,19 @@ test_expect_success 'sparse pack-objects' '
118
test_cmp expect_sparse_objects.txt sparse_objects.txt
119
'
120
121
+test_expect_success 'pack.useSparse enables algorithm' '
122
+ git config pack.useSparse true &&
123
+ git pack-objects --stdout --revs <packinput.txt >sparse.pack &&
124
+ git index-pack -o sparse.idx sparse.pack &&
125
+ git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
126
+ test_cmp expect_sparse_objects.txt sparse_objects.txt
127
+'
128
+
129
+test_expect_success 'pack.useSparse overridden' '
130
+ git pack-objects --stdout --revs --no-sparse <packinput.txt >sparse.pack &&
131
+ git index-pack -o sparse.idx sparse.pack &&
132
+ git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
133
+ test_cmp required_objects.txt sparse_objects.txt
134
+'
135
+
136
test_done