Skip to content

Commit 175d67a

Browse files
committed
Merge branch 'ds/doc-scalar-config' into seen
Documentation updates. Comments? * ds/doc-scalar-config: scalar: document config settings scalar: alphabetize and simplify config scalar: remove stale config values scalar: use index.skipHash=true for performance scalar: annotate config file with "set by scalar"
2 parents fc74610 + c483f0a commit 175d67a

File tree

3 files changed

+218
-47
lines changed

3 files changed

+218
-47
lines changed

Documentation/scalar.adoc

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,164 @@ delete <enlistment>::
197197
This subcommand lets you delete an existing Scalar enlistment from your
198198
local file system, unregistering the repository.
199199

200+
REQUIRED AND RECOMMENDED CONFIG
201+
-------------------------------
202+
203+
As part of both `scalar clone` and `scalar register`, certain Git config
204+
values are set to optimize for large repositories or cross-platform support.
205+
These options are updated in new Git versions according to the best known
206+
advice for large repositories, and users can get the latest recommendations
207+
by running `scalar reconfigure [--all]`.
208+
209+
This section lists justifications for the config values that are set in the
210+
latest version.
211+
212+
am.keepCR=true::
213+
This setting is important for cross-platform development across Windows
214+
and non-Windows platforms and keeping carriage return (`\r`) characters
215+
in certain workflows.
216+
217+
commitGraph.changedPaths=true::
218+
This setting helps the background maintenance steps that compute the
219+
serialized commit-graph to also store changed-path Bloom filters. This
220+
accelerates file history commands and allows users to automatically
221+
benefit without running a foreground command.
222+
223+
commitGraph.generationVersion=1::
224+
While the preferred version is 2 for performance reasons, existing users
225+
that had version 1 by default will need special care in upgrading to
226+
version 2. This is likely to change in the future as the upgrade story
227+
is solidifies.
228+
229+
core.autoCRLF=false::
230+
This removes the transformation of worktree files to add CRLF line
231+
endings when only LF line endings exist. This is removed for performance
232+
reasons. Repositories that use tools that care about CRLF line endings
233+
should commit the necessary files with those line endings instead.
234+
235+
core.logAllRefUpdates=true::
236+
This enables the reflog on all branches. While this is a performance
237+
cost for large repositories, it is frequently an important data source
238+
for users to get out of bad situations or to seek support from experts.
239+
240+
core.safeCRLF=false::
241+
Similar to `core.autoCRLF=false`, this disables checks around whether
242+
the CRLF conversion is reversible. This is a performance improvement,
243+
but can be dangerous if `core.autoCRLF` is reenabled by the user.
244+
245+
credential.https://dev.azure.com.useHttpPath=true::
246+
This setting enables the `credential.useHttpPath` feature only for web
247+
URLs for Azure DevOps. This is important for users interacting with that
248+
service using multiple organizations and thus multiple credential
249+
tokens.
250+
251+
feature.experimental=false::
252+
This disables the "experimental" optimizations grouped under this
253+
feature config. The expectation is that all valuable optimizations are
254+
also set explicitly by Scalar config, and any differences are
255+
intentional. Notable differences include several bitmap-related config
256+
options which are disabled for client-focused Scalar repos.
257+
258+
feature.manyFiles=false::
259+
This disables the "many files" optimizations grouped under this feature
260+
config. The expectation is that all valuable optimizations are also set
261+
explicitly by Scalar config, and any differences are intentional.
262+
263+
fetch.showForcedUpdates=false::
264+
This disables the check at the end of `git fetch` that notifies the user
265+
if the ref update was a forced update (one where the previous position
266+
is not reachable from the latest position). This check can be very
267+
expensive in large repositories, so is disabled and replaced with an
268+
advice message. Set `advice.fetchShowForcedUpdates=false` to disable
269+
this advice message.
270+
271+
fetch.unpackLimit=1::
272+
This setting prevents Git from unpacking packfiles into loose objects
273+
as they are downloaded from the server. This feature was intended as a
274+
way to prevent performance issues from too many packfiles, but Scalar
275+
uses background maintenance to group packfiles and cover them with a
276+
multi-pack-index, removing this issue.
277+
278+
fetch.writeCommitGraph=false::
279+
This config setting was created to help users automatically udpate their
280+
commit-graph files as they perform fetches. However, this takes time
281+
from foreground fetches and pulls and Scalar uses background maintenance
282+
for this function instead.
283+
284+
gc.auto=0::
285+
This disables automatic garbage collection, since Scalar uses background
286+
maintenance to keep the repository data in good shape.
287+
288+
gui.GCWarning=false::
289+
Since Scalar disables garbage collection by setting `gc.auto=0`, the
290+
`git-gui` tool may start to warn about this setting. Disable this
291+
warning as Scalar's background maintenance configuration makes the
292+
warning irrelevant.
293+
294+
index.skipHash=true::
295+
Disable computing the hash of the index contents as it is being written.
296+
This assists with performance, especially for large index files.
297+
298+
index.threads=true::
299+
This tells Git to automatically detect how many threads it should use
300+
when reading the index in parallel due to the `core.preloadIndex=true`
301+
setting.
302+
303+
index.version=4::
304+
This index version adds compression to the path names, reducing the size
305+
of the index in a significant way for large repos. This is an important
306+
performance boost.
307+
308+
merge.renames=true::
309+
When computing merges in large repos, it is particularly important to
310+
detect renames to maximize the potential for a result that will validate
311+
correctly. Users performing merges locally are more likely to be doing
312+
so because a server-side merge (via pull request or similar) resulted in
313+
conflicts. While this is the default setting, it is set specifically to
314+
override a potential change to `diff.renames` which a user may set for
315+
performance reasons.
316+
317+
merge.stat=false::
318+
This disables a diff output after computing a merge. This improves
319+
performance of `git merge` for large repos while reducing noisy output.
320+
321+
pack.useBitmaps=false::
322+
This disables the use of `.bitmap` files attached to packfiles. Bitmap
323+
files are optimized for server-side use, not client-side use. Scalar
324+
disables this to avoid some performance issues that can occur if a user
325+
accidentally creates `.bitmap` files.
326+
327+
pack.usePathWalk=true::
328+
This enables the `--path-walk` option to `git pack-objects` by default.
329+
This can accelerate the computation and compression of packfiles created
330+
by `git push` and other repack operations.
331+
332+
receive.autoGC=false::
333+
Similar to `gc.auto`, this setting is disabled in preference of
334+
background maintenance.
335+
336+
status.aheadBehind=false::
337+
This disables the ahead/behind calculation that would normally happen
338+
during a `git status` command. This information is frequently ignored by
339+
users but can be expensive to calculate in large repos that receive
340+
thousands of commits per day. The calculation is replaced with an advice
341+
message that can be disabled by disabling the `advice.statusAheadBehind`
342+
config.
343+
344+
The following settings are different based on which platform is in use:
345+
346+
core.untrackedCache=(true|false)::
347+
The untracked cache feature is important for performance benefits on
348+
large repositories, but has demonstrated some bugs on Windows
349+
filesystems. Thus, this is set for other platforms but disabled on
350+
Windows.
351+
352+
http.sslBackend=schannel::
353+
On Windows, the `openssl` backend has some issues with certain types of
354+
remote providers and certificate types. Override the default setting to
355+
avoid these common problems.
356+
357+
200358
SEE ALSO
201359
--------
202360
linkgit:git-clone[1], linkgit:git-maintenance[1].

scalar.c

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "help.h"
2020
#include "setup.h"
2121
#include "trace2.h"
22+
#include "path.h"
2223

2324
static void setup_enlistment_directory(int argc, const char **argv,
2425
const char * const *usagestr,
@@ -99,16 +100,20 @@ static int set_scalar_config(const struct scalar_config *config, int reconfigure
99100
{
100101
char *value = NULL;
101102
int res;
103+
char *file = repo_git_path(the_repository, "config");
102104

103105
if ((reconfigure && config->overwrite_on_reconfigure) ||
104106
repo_config_get_string(the_repository, config->key, &value)) {
105107
trace2_data_string("scalar", the_repository, config->key, "created");
106-
res = repo_config_set_gently(the_repository, config->key, config->value);
108+
res = repo_config_set_multivar_in_file_gently(the_repository, file, config->key,
109+
config->value, NULL,
110+
" # set by scalar", 0);
107111
} else {
108112
trace2_data_string("scalar", the_repository, config->key, "exists");
109113
res = 0;
110114
}
111115

116+
free(file);
112117
free(value);
113118
return res;
114119
}
@@ -122,13 +127,33 @@ static int have_fsmonitor_support(void)
122127
static int set_recommended_config(int reconfigure)
123128
{
124129
struct scalar_config config[] = {
125-
/* Required */
126-
{ "am.keepCR", "true", 1 },
127-
{ "core.FSCache", "true", 1 },
128-
{ "core.multiPackIndex", "true", 1 },
129-
{ "core.preloadIndex", "true", 1 },
130+
{ "am.keepCR", "true" },
131+
{ "commitGraph.changedPaths", "true" },
132+
{ "commitGraph.generationVersion", "1" },
133+
{ "core.autoCRLF", "false" },
134+
{ "core.logAllRefUpdates", "true" },
135+
{ "core.safeCRLF", "false" },
136+
{ "credential.https://dev.azure.com.useHttpPath", "true" },
137+
{ "feature.experimental", "false" },
138+
{ "feature.manyFiles", "false" },
139+
{ "fetch.showForcedUpdates", "false" },
140+
{ "fetch.unpackLimit", "1" },
141+
{ "fetch.writeCommitGraph", "false" },
142+
{ "gc.auto", "0" },
143+
{ "gui.GCWarning", "false" },
144+
{ "index.skipHash", "true", 1 /* Fix previous setting. */ },
145+
{ "index.threads", "true"},
146+
{ "index.version", "4" },
147+
{ "merge.renames", "true" },
148+
{ "merge.stat", "false" },
149+
{ "pack.useBitmaps", "false" },
150+
{ "pack.usePathWalk", "true" },
151+
{ "receive.autoGC", "false" },
152+
{ "status.aheadBehind", "false" },
153+
154+
/* platform-specific */
130155
#ifndef WIN32
131-
{ "core.untrackedCache", "true", 1 },
156+
{ "core.untrackedCache", "true" },
132157
#else
133158
/*
134159
* Unfortunately, Scalar's Functional Tests demonstrated
@@ -142,36 +167,11 @@ static int set_recommended_config(int reconfigure)
142167
* Therefore, with a sad heart, we disable this very useful
143168
* feature on Windows.
144169
*/
145-
{ "core.untrackedCache", "false", 1 },
146-
#endif
147-
{ "core.logAllRefUpdates", "true", 1 },
148-
{ "credential.https://dev.azure.com.useHttpPath", "true", 1 },
149-
{ "credential.validate", "false", 1 }, /* GCM4W-only */
150-
{ "gc.auto", "0", 1 },
151-
{ "gui.GCWarning", "false", 1 },
152-
{ "index.skipHash", "false", 1 },
153-
{ "index.threads", "true", 1 },
154-
{ "index.version", "4", 1 },
155-
{ "merge.stat", "false", 1 },
156-
{ "merge.renames", "true", 1 },
157-
{ "pack.useBitmaps", "false", 1 },
158-
{ "pack.useSparse", "true", 1 },
159-
{ "receive.autoGC", "false", 1 },
160-
{ "feature.manyFiles", "false", 1 },
161-
{ "feature.experimental", "false", 1 },
162-
{ "fetch.unpackLimit", "1", 1 },
163-
{ "fetch.writeCommitGraph", "false", 1 },
164-
#ifdef WIN32
165-
{ "http.sslBackend", "schannel", 1 },
170+
{ "core.untrackedCache", "false" },
171+
172+
/* Other Windows-specific required settings: */
173+
{ "http.sslBackend", "schannel" },
166174
#endif
167-
/* Optional */
168-
{ "status.aheadBehind", "false" },
169-
{ "commitGraph.changedPaths", "true" },
170-
{ "commitGraph.generationVersion", "1" },
171-
{ "core.autoCRLF", "false" },
172-
{ "core.safeCRLF", "false" },
173-
{ "fetch.showForcedUpdates", "false" },
174-
{ "pack.usePathWalk", "true" },
175175
{ NULL, NULL },
176176
};
177177
int i;
@@ -195,13 +195,18 @@ static int set_recommended_config(int reconfigure)
195195
* for multiple values.
196196
*/
197197
if (repo_config_get_string(the_repository, "log.excludeDecoration", &value)) {
198+
char *file = repo_git_path(the_repository, "config");
198199
trace2_data_string("scalar", the_repository,
199200
"log.excludeDecoration", "created");
200-
if (repo_config_set_multivar_gently(the_repository, "log.excludeDecoration",
201+
if (repo_config_set_multivar_in_file_gently(the_repository, file,
202+
"log.excludeDecoration",
201203
"refs/prefetch/*",
202-
CONFIG_REGEX_NONE, 0))
204+
CONFIG_REGEX_NONE,
205+
" # set by scalar",
206+
0))
203207
return error(_("could not configure "
204208
"log.excludeDecoration"));
209+
free(file);
205210
} else {
206211
trace2_data_string("scalar", the_repository,
207212
"log.excludeDecoration", "exists");

t/t9210-scalar.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,17 @@ test_expect_success 'scalar clone --no-... opts' '
202202
test_expect_success 'scalar reconfigure' '
203203
git init one/src &&
204204
scalar register one &&
205-
git -C one/src config core.preloadIndex false &&
205+
git -C one/src config unset gui.gcwarning &&
206206
scalar reconfigure one &&
207-
test true = "$(git -C one/src config core.preloadIndex)" &&
208-
git -C one/src config core.preloadIndex false &&
207+
test false = "$(git -C one/src config gui.gcwarning)" &&
208+
git -C one/src config unset gui.gcwarning &&
209209
rm one/src/cron.txt &&
210210
GIT_TRACE2_EVENT="$(pwd)/reconfigure" scalar reconfigure -a &&
211211
test_path_is_file one/src/cron.txt &&
212-
test true = "$(git -C one/src config core.preloadIndex)" &&
212+
test false = "$(git -C one/src config gui.gcwarning)" &&
213+
test_grep "GCWarning = false # set by scalar" one/src/.git/config &&
214+
test_grep "excludeDecoration = refs/prefetch/\* # set by scalar" one/src/.git/config &&
215+
213216
test_subcommand git maintenance start <reconfigure &&
214217
test_subcommand ! git maintenance unregister --force <reconfigure &&
215218
@@ -231,25 +234,30 @@ test_expect_success 'scalar reconfigure --all with includeIf.onbranch' '
231234
git init $num/src &&
232235
scalar register $num/src &&
233236
git -C $num/src config includeif."onbranch:foo".path something &&
234-
git -C $num/src config core.preloadIndex false || return 1
237+
git -C $num/src config unset gui.gcwarning || return 1
235238
done &&
236239
237240
scalar reconfigure --all &&
238241
239242
for num in $repos
240243
do
241-
test true = "$(git -C $num/src config core.preloadIndex)" || return 1
244+
test false = "$(git -C $num/src config gui.gcwarning)" || return 1
242245
done
243246
'
244247

245248
test_expect_success 'scalar reconfigure --all with detached HEADs' '
249+
# This test demonstrates an issue with index.skipHash=true and
250+
# this test variable for the split index. Disable the test variable.
251+
GIT_TEST_SPLIT_INDEX= &&
252+
export GIT_TEST_SPLIT_INDEX &&
253+
246254
repos="two three four" &&
247255
for num in $repos
248256
do
249257
rm -rf $num/src &&
250258
git init $num/src &&
251259
scalar register $num/src &&
252-
git -C $num/src config core.preloadIndex false &&
260+
git -C $num/src config unset gui.gcwarning &&
253261
test_commit -C $num/src initial &&
254262
git -C $num/src switch --detach HEAD || return 1
255263
done &&
@@ -258,7 +266,7 @@ test_expect_success 'scalar reconfigure --all with detached HEADs' '
258266
259267
for num in $repos
260268
do
261-
test true = "$(git -C $num/src config core.preloadIndex)" || return 1
269+
test false = "$(git -C $num/src config gui.gcwarning)" || return 1
262270
done
263271
'
264272

@@ -290,7 +298,7 @@ test_expect_success 'scalar supports -c/-C' '
290298
git init sub &&
291299
scalar -C sub -c status.aheadBehind=bogus register &&
292300
test -z "$(git -C sub config --local status.aheadBehind)" &&
293-
test true = "$(git -C sub config core.preloadIndex)"
301+
test false = "$(git -C sub config gui.gcwarning)"
294302
'
295303

296304
test_expect_success '`scalar [...] <dir>` errors out when dir is missing' '

0 commit comments

Comments
 (0)