Skip to content

Commit f30e25f

Browse files
committed
repo-settings: create feature.experimental setting
The 'feature.experimental' setting includes config options that are not committed to become defaults, but could use additional testing. Update the following config settings to take new defaults, and to use the repo_settings struct if not already using them: * 'pack.useSparse=true' * 'fetch.negotiationAlgorithm=skipping' In the case of fetch.negotiationAlgorithm, the existing logic would load the config option only when about to use the setting, so had a die() statement on an unknown string value. This is removed as now the config is parsed under prepare_repo_settings(). In general, this die() is probably misplaced and not valuable. A test was removed that checked this die() statement executed. Signed-off-by: Derrick Stolee <[email protected]>
1 parent 082fc57 commit f30e25f

9 files changed

+60
-45
lines changed

Documentation/config/feature.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ feature.*::
44
developer community as recommended defaults and are subject to change.
55
In particular, new config options may be added with different defaults.
66

7+
feature.experimental::
8+
Enable config options that are new to Git, and are being considered for
9+
future defaults. Config settings included here may be added or removed
10+
with each release, including minor version updates. These settings may
11+
have unintended interactions since they are so new. Please enable this
12+
setting if you are interested in providing feedback on experimental
13+
features. The new default values are:
14+
+
15+
* `pack.useSparse=true` uses a new algorithm when constructing a pack-file
16+
which can improve `git push` performance in repos with many files.
17+
+
18+
* `fetch.negotiationAlgorithm=skipping` may improve fetch negotiation times by
19+
skipping more commits at a time, reducing the number of round trips.
20+
721
feature.manyFiles::
822
Enable config options that optimize for repos with many files in the
923
working directory. With many files, commands such as `git status` and

Documentation/config/fetch.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ fetch.negotiationAlgorithm::
5959
effort to converge faster, but may result in a larger-than-necessary
6060
packfile; The default is "default" which instructs Git to use the default algorithm
6161
that never skips commits (unless the server has acknowledged it or one
62-
of its descendants).
62+
of its descendants). If `feature.experimental` is enabled, then this
63+
setting defaults to "skipping".
6364
Unknown values will cause 'git fetch' to error out.
6465
+
6566
See also the `--negotiation-tip` option for linkgit:git-fetch[1].

Documentation/config/pack.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ pack.useSparse::
112112
objects. This can have significant performance benefits when
113113
computing a pack to send a small change. However, it is possible
114114
that extra objects are added to the pack-file if the included
115-
commits contain certain types of direct renames.
115+
commits contain certain types of direct renames. Default is `false`
116+
unless `feature.experimental` is enabled.
116117

117118
pack.writeBitmaps (deprecated)::
118119
This is a deprecated synonym for `repack.writeBitmaps`.

fetch-negotiator.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
#include "fetch-negotiator.h"
33
#include "negotiator/default.h"
44
#include "negotiator/skipping.h"
5+
#include "repository.h"
56

6-
void fetch_negotiator_init(struct fetch_negotiator *negotiator,
7-
const char *algorithm)
7+
void fetch_negotiator_init(struct repository *r,
8+
struct fetch_negotiator *negotiator)
89
{
9-
if (algorithm) {
10-
if (!strcmp(algorithm, "skipping")) {
11-
skipping_negotiator_init(negotiator);
12-
return;
13-
} else if (!strcmp(algorithm, "default")) {
14-
/* Fall through to default initialization */
15-
} else {
16-
die("unknown fetch negotiation algorithm '%s'", algorithm);
17-
}
10+
prepare_repo_settings(r);
11+
switch(r->settings.fetch_negotiation_algorithm) {
12+
case FETCH_NEGOTIATION_SKIPPING:
13+
skipping_negotiator_init(negotiator);
14+
return;
15+
16+
case FETCH_NEGOTIATION_DEFAULT:
17+
default:
18+
default_negotiator_init(negotiator);
19+
return;
1820
}
19-
default_negotiator_init(negotiator);
2021
}

fetch-negotiator.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define FETCH_NEGOTIATOR_H
33

44
struct commit;
5+
struct repository;
56

67
/*
78
* An object that supplies the information needed to negotiate the contents of
@@ -52,7 +53,7 @@ struct fetch_negotiator {
5253
void *data;
5354
};
5455

55-
void fetch_negotiator_init(struct fetch_negotiator *negotiator,
56-
const char *algorithm);
56+
void fetch_negotiator_init(struct repository *r,
57+
struct fetch_negotiator *negotiator);
5758

5859
#endif

fetch-pack.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ static int agent_supported;
3636
static int server_supports_filtering;
3737
static struct lock_file shallow_lock;
3838
static const char *alternate_shallow_file;
39-
static char *negotiation_algorithm;
4039
static struct strbuf fsck_msg_types = STRBUF_INIT;
4140

4241
/* Remember to update object flag allocation in object.h */
@@ -892,12 +891,13 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
892891
struct shallow_info *si,
893892
char **pack_lockfile)
894893
{
894+
struct repository *r = the_repository;
895895
struct ref *ref = copy_ref_list(orig_ref);
896896
struct object_id oid;
897897
const char *agent_feature;
898898
int agent_len;
899899
struct fetch_negotiator negotiator;
900-
fetch_negotiator_init(&negotiator, negotiation_algorithm);
900+
fetch_negotiator_init(r, &negotiator);
901901

902902
sort_ref_list(&ref, ref_compare_name);
903903
QSORT(sought, nr_sought, cmp_ref_by_name);
@@ -911,7 +911,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
911911

912912
if (server_supports("shallow"))
913913
print_verbose(args, _("Server supports %s"), "shallow");
914-
else if (args->depth > 0 || is_repository_shallow(the_repository))
914+
else if (args->depth > 0 || is_repository_shallow(r))
915915
die(_("Server does not support shallow clients"));
916916
if (args->depth > 0 || args->deepen_since || args->deepen_not)
917917
args->deepen = 1;
@@ -1379,14 +1379,15 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
13791379
struct shallow_info *si,
13801380
char **pack_lockfile)
13811381
{
1382+
struct repository *r = the_repository;
13821383
struct ref *ref = copy_ref_list(orig_ref);
13831384
enum fetch_state state = FETCH_CHECK_LOCAL;
13841385
struct oidset common = OIDSET_INIT;
13851386
struct packet_reader reader;
13861387
int in_vain = 0;
13871388
int haves_to_send = INITIAL_FLUSH;
13881389
struct fetch_negotiator negotiator;
1389-
fetch_negotiator_init(&negotiator, negotiation_algorithm);
1390+
fetch_negotiator_init(r, &negotiator);
13901391
packet_reader_init(&reader, fd[0], NULL, 0,
13911392
PACKET_READ_CHOMP_NEWLINE |
13921393
PACKET_READ_DIE_ON_ERR_PACKET);
@@ -1505,8 +1506,6 @@ static void fetch_pack_config(void)
15051506
git_config_get_bool("repack.usedeltabaseoffset", &prefer_ofs_delta);
15061507
git_config_get_bool("fetch.fsckobjects", &fetch_fsck_objects);
15071508
git_config_get_bool("transfer.fsckobjects", &transfer_fsck_objects);
1508-
git_config_get_string("fetch.negotiationalgorithm",
1509-
&negotiation_algorithm);
15101509

15111510
git_config(fetch_pack_config_cb, NULL);
15121511
}

repo-settings.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,29 @@ void prepare_repo_settings(struct repository *r)
3636
free(strval);
3737
}
3838

39+
if (!repo_config_get_string(r, "fetch.negotiationalgorithm", &strval)) {
40+
if (!strcasecmp(strval, "skipping"))
41+
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
42+
else
43+
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
44+
}
45+
3946
if (!repo_config_get_bool(r, "pack.usesparse", &value))
4047
r->settings.pack_use_sparse = value;
4148
if (!repo_config_get_bool(r, "feature.manyfiles", &value) && value) {
4249
UPDATE_DEFAULT_BOOL(r->settings.index_version, 4);
4350
UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_WRITE);
4451
}
52+
if (!repo_config_get_bool(r, "feature.experimental", &value) && value) {
53+
UPDATE_DEFAULT_BOOL(r->settings.pack_use_sparse, 1);
54+
UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_SKIPPING);
55+
}
4556

4657
/* Hack for test programs like test-dump-untracked-cache */
4758
if (ignore_untracked_cache_config)
4859
r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
4960
else
5061
UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_KEEP);
62+
63+
UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_DEFAULT);
5164
}

repository.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ enum untracked_cache_setting {
1818
UNTRACKED_CACHE_WRITE = 2
1919
};
2020

21+
enum fetch_negotiation_setting {
22+
FETCH_NEGOTIATION_UNSET = -1,
23+
FETCH_NEGOTIATION_NONE = 0,
24+
FETCH_NEGOTIATION_DEFAULT = 1,
25+
FETCH_NEGOTIATION_SKIPPING = 2,
26+
};
27+
2128
struct repo_settings {
2229
int initialized;
2330

@@ -28,6 +35,7 @@ struct repo_settings {
2835
enum untracked_cache_setting core_untracked_cache;
2936

3037
int pack_use_sparse;
38+
enum fetch_negotiation_setting fetch_negotiation_algorithm;
3139
};
3240

3341
struct repository {

t/t5552-skipping-fetch-negotiator.sh

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,6 @@ test_expect_success 'commits with no parents are sent regardless of skip distanc
6060
have_not_sent c6 c4 c3
6161
'
6262

63-
test_expect_success 'unknown fetch.negotiationAlgorithm values error out' '
64-
rm -rf server client trace &&
65-
git init server &&
66-
test_commit -C server to_fetch &&
67-
68-
git init client &&
69-
test_commit -C client on_client &&
70-
git -C client checkout on_client &&
71-
72-
test_config -C client fetch.negotiationAlgorithm invalid &&
73-
test_must_fail git -C client fetch "$(pwd)/server" 2>err &&
74-
test_i18ngrep "unknown fetch negotiation algorithm" err &&
75-
76-
# Explicit "default" value
77-
test_config -C client fetch.negotiationAlgorithm default &&
78-
git -C client -c fetch.negotiationAlgorithm=default fetch "$(pwd)/server" &&
79-
80-
# Implementation detail: If there is nothing to fetch, we will not error out
81-
test_config -C client fetch.negotiationAlgorithm invalid &&
82-
git -C client fetch "$(pwd)/server" 2>err &&
83-
test_i18ngrep ! "unknown fetch negotiation algorithm" err
84-
'
85-
8663
test_expect_success 'when two skips collide, favor the larger one' '
8764
rm -rf server client trace &&
8865
git init server &&

0 commit comments

Comments
 (0)