Skip to content

Commit

Permalink
Merge branch 'ds/feature-macros' into pu
Browse files Browse the repository at this point in the history
A mechanism to affect the default setting for a (related) group of
configuration variables is introduced.

* ds/feature-macros:
  repo-settings: create feature.experimental setting
  repo-settings: create feature.manyFiles setting
  repo-settings: parse core.untrackedCache
  commit-graph: turn on commit-graph by default
  t6501: use 'git gc' in quiet mode
  repo-settings: consolidate some config settings
  • Loading branch information
gitster committed Aug 22, 2019
2 parents 3d40fba + aaf633c commit 8f776be
Show file tree
Hide file tree
Showing 26 changed files with 224 additions and 115 deletions.
2 changes: 2 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ include::config/difftool.txt[]

include::config/fastimport.txt[]

include::config/feature.txt[]

include::config/fetch.txt[]

include::config/format.txt[]
Expand Down
6 changes: 4 additions & 2 deletions Documentation/config/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ core.untrackedCache::
it will automatically be removed, if set to `false`. Before
setting it to `true`, you should check that mtime is working
properly on your system.
See linkgit:git-update-index[1]. `keep` by default.
See linkgit:git-update-index[1]. `keep` by default, unless
`feature.manyFiles` is enabled which sets this setting to
`true` by default.

core.checkStat::
When missing or is set to `default`, many fields in the stat
Expand Down Expand Up @@ -577,7 +579,7 @@ the `GIT_NOTES_REF` environment variable. See linkgit:git-notes[1].

core.commitGraph::
If true, then git will read the commit-graph file (if it exists)
to parse the graph structure of commits. Defaults to false. See
to parse the graph structure of commits. Defaults to true. See
linkgit:git-commit-graph[1] for more information.

core.useReplaceRefs::
Expand Down
29 changes: 29 additions & 0 deletions Documentation/config/feature.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
feature.*::
The config settings that start with `feature.` modify the defaults of
a group of other config settings. These groups are created by the Git
developer community as recommended defaults and are subject to change.
In particular, new config options may be added with different defaults.

feature.experimental::
Enable config options that are new to Git, and are being considered for
future defaults. Config settings included here may be added or removed
with each release, including minor version updates. These settings may
have unintended interactions since they are so new. Please enable this
setting if you are interested in providing feedback on experimental
features. The new default values are:
+
* `pack.useSparse=true` uses a new algorithm when constructing a pack-file
which can improve `git push` performance in repos with many files.
+
* `fetch.negotiationAlgorithm=skipping` may improve fetch negotiation times by
skipping more commits at a time, reducing the number of round trips.

feature.manyFiles::
Enable config options that optimize for repos with many files in the
working directory. With many files, commands such as `git status` and
`git checkout` may be slow and these new defaults improve performance:
+
* `index.version=4` enables path-prefix compression in the index.
+
* `core.untrackedCache=true` enables the untracked cache. This setting assumes
that mtime is working on your machine.
3 changes: 2 additions & 1 deletion Documentation/config/fetch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ fetch.negotiationAlgorithm::
effort to converge faster, but may result in a larger-than-necessary
packfile; The default is "default" which instructs Git to use the default algorithm
that never skips commits (unless the server has acknowledged it or one
of its descendants).
of its descendants). If `feature.experimental` is enabled, then this
setting defaults to "skipping".
Unknown values will cause 'git fetch' to error out.
+
See also the `--negotiation-tip` option for linkgit:git-fetch[1].
Expand Down
2 changes: 1 addition & 1 deletion Documentation/config/gc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ gc.writeCommitGraph::
If true, then gc will rewrite the commit-graph file when
linkgit:git-gc[1] is run. When using `git gc --auto`
the commit-graph will be updated if housekeeping is
required. Default is false. See linkgit:git-commit-graph[1]
required. Default is true. See linkgit:git-commit-graph[1]
for details.

gc.logExpiry::
Expand Down
1 change: 1 addition & 0 deletions Documentation/config/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 `feature.manyFiles` is enabled, then the default is 4.
3 changes: 2 additions & 1 deletion Documentation/config/pack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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. Default is `false`
unless `feature.experimental` is enabled.

pack.writeBitmaps (deprecated)::
This is a deprecated synonym for `repack.writeBitmaps`.
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ LIB_OBJS += refspec.o
LIB_OBJS += ref-filter.o
LIB_OBJS += remote.o
LIB_OBJS += replace-object.o
LIB_OBJS += repo-settings.o
LIB_OBJS += repository.o
LIB_OBJS += rerere.o
LIB_OBJS += resolve-undo.o
Expand Down
12 changes: 5 additions & 7 deletions builtin/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ static int aggressive_depth = 50;
static int aggressive_window = 250;
static int gc_auto_threshold = 6700;
static int gc_auto_pack_limit = 50;
static int gc_write_commit_graph;
static int detach_auto = 1;
static timestamp_t gc_log_expire_time;
static const char *gc_log_expire = "1.day.ago";
Expand Down Expand Up @@ -149,7 +148,6 @@ static void gc_config(void)
git_config_get_int("gc.aggressivedepth", &aggressive_depth);
git_config_get_int("gc.auto", &gc_auto_threshold);
git_config_get_int("gc.autopacklimit", &gc_auto_pack_limit);
git_config_get_bool("gc.writecommitgraph", &gc_write_commit_graph);
git_config_get_bool("gc.autodetach", &detach_auto);
git_config_get_expiry("gc.pruneexpire", &prune_expire);
git_config_get_expiry("gc.worktreepruneexpire", &prune_worktrees_expire);
Expand Down Expand Up @@ -686,11 +684,11 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
clean_pack_garbage();
}

if (gc_write_commit_graph &&
write_commit_graph_reachable(get_object_directory(),
!quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
NULL))
return 1;
prepare_repo_settings(the_repository);
if (the_repository->settings.gc_write_commit_graph == 1)
write_commit_graph_reachable(get_object_directory(),
!quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
NULL);

if (auto_gc && too_many_loose_objects())
warning(_("There are too many unreachable loose objects; "
Expand Down
8 changes: 4 additions & 4 deletions builtin/pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -2704,10 +2704,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)
Expand Down Expand Up @@ -3332,6 +3328,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);

Expand Down
6 changes: 4 additions & 2 deletions builtin/update-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
struct parse_opt_ctx_t ctx;
strbuf_getline_fn getline_fn;
int parseopt_state = PARSE_OPT_UNKNOWN;
struct repository *r = the_repository;
struct option options[] = {
OPT_BIT('q', NULL, &refresh_args.flags,
N_("continue refresh even when index needs update"),
Expand Down Expand Up @@ -1180,11 +1181,12 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
remove_split_index(&the_index);
}

prepare_repo_settings(r);
switch (untracked_cache) {
case UC_UNSPECIFIED:
break;
case UC_DISABLE:
if (git_config_get_untracked_cache() == 1)
if (r->settings.core_untracked_cache == UNTRACKED_CACHE_WRITE)
warning(_("core.untrackedCache is set to true; "
"remove or change it, if you really want to "
"disable the untracked cache"));
Expand All @@ -1196,7 +1198,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
return !test_if_untracked_cache_is_supported();
case UC_ENABLE:
case UC_FORCE:
if (git_config_get_untracked_cache() == 0)
if (r->settings.core_untracked_cache == UNTRACKED_CACHE_REMOVE)
warning(_("core.untrackedCache is set to false; "
"remove or change it, if you really want to "
"enable the untracked cache"));
Expand Down
6 changes: 3 additions & 3 deletions commit-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ static void prepare_commit_graph_one(struct repository *r, const char *obj_dir)
static int prepare_commit_graph(struct repository *r)
{
struct object_directory *odb;
int config_value;

if (git_env_bool(GIT_TEST_COMMIT_GRAPH_DIE_ON_LOAD, 0))
die("dying as requested by the '%s' variable on commit-graph load!",
Expand All @@ -477,9 +476,10 @@ static int prepare_commit_graph(struct repository *r)
return !!r->objects->commit_graph;
r->objects->commit_graph_attempted = 1;

prepare_repo_settings(r);

if (!git_env_bool(GIT_TEST_COMMIT_GRAPH, 0) &&
(repo_config_get_bool(r, "core.commitgraph", &config_value) ||
!config_value))
r->settings.core_commit_graph != 1)
/*
* This repository is not configured to use commit graphs, so
* do not load one. (But report commit_graph_attempted anyway
Expand Down
24 changes: 0 additions & 24 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2283,30 +2283,6 @@ int git_config_get_expiry_in_days(const char *key, timestamp_t *expiry, timestam
return -1; /* thing exists but cannot be parsed */
}

int git_config_get_untracked_cache(void)
{
int val = -1;
const char *v;

/* Hack for test programs like test-dump-untracked-cache */
if (ignore_untracked_cache_config)
return -1;

if (!git_config_get_maybe_bool("core.untrackedcache", &val))
return val;

if (!git_config_get_value("core.untrackedcache", &v)) {
if (!strcasecmp(v, "keep"))
return -1;

error(_("unknown core.untrackedCache value '%s'; "
"using 'keep' default value"), v);
return -1;
}

return -1; /* default value */
}

int git_config_get_split_index(void)
{
int val;
Expand Down
25 changes: 13 additions & 12 deletions fetch-negotiator.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
#include "fetch-negotiator.h"
#include "negotiator/default.h"
#include "negotiator/skipping.h"
#include "repository.h"

void fetch_negotiator_init(struct fetch_negotiator *negotiator,
const char *algorithm)
void fetch_negotiator_init(struct repository *r,
struct fetch_negotiator *negotiator)
{
if (algorithm) {
if (!strcmp(algorithm, "skipping")) {
skipping_negotiator_init(negotiator);
return;
} else if (!strcmp(algorithm, "default")) {
/* Fall through to default initialization */
} else {
die("unknown fetch negotiation algorithm '%s'", algorithm);
}
prepare_repo_settings(r);
switch(r->settings.fetch_negotiation_algorithm) {
case FETCH_NEGOTIATION_SKIPPING:
skipping_negotiator_init(negotiator);
return;

case FETCH_NEGOTIATION_DEFAULT:
default:
default_negotiator_init(negotiator);
return;
}
default_negotiator_init(negotiator);
}
5 changes: 3 additions & 2 deletions fetch-negotiator.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define FETCH_NEGOTIATOR_H

struct commit;
struct repository;

/*
* An object that supplies the information needed to negotiate the contents of
Expand Down Expand Up @@ -52,7 +53,7 @@ struct fetch_negotiator {
void *data;
};

void fetch_negotiator_init(struct fetch_negotiator *negotiator,
const char *algorithm);
void fetch_negotiator_init(struct repository *r,
struct fetch_negotiator *negotiator);

#endif
11 changes: 5 additions & 6 deletions fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ static int agent_supported;
static int server_supports_filtering;
static struct lock_file shallow_lock;
static const char *alternate_shallow_file;
static char *negotiation_algorithm;
static struct strbuf fsck_msg_types = STRBUF_INIT;

/* Remember to update object flag allocation in object.h */
Expand Down Expand Up @@ -889,12 +888,13 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
struct shallow_info *si,
char **pack_lockfile)
{
struct repository *r = the_repository;
struct ref *ref = copy_ref_list(orig_ref);
struct object_id oid;
const char *agent_feature;
int agent_len;
struct fetch_negotiator negotiator;
fetch_negotiator_init(&negotiator, negotiation_algorithm);
fetch_negotiator_init(r, &negotiator);

sort_ref_list(&ref, ref_compare_name);
QSORT(sought, nr_sought, cmp_ref_by_name);
Expand All @@ -908,7 +908,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,

if (server_supports("shallow"))
print_verbose(args, _("Server supports %s"), "shallow");
else if (args->depth > 0 || is_repository_shallow(the_repository))
else if (args->depth > 0 || is_repository_shallow(r))
die(_("Server does not support shallow clients"));
if (args->depth > 0 || args->deepen_since || args->deepen_not)
args->deepen = 1;
Expand Down Expand Up @@ -1373,14 +1373,15 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
struct shallow_info *si,
char **pack_lockfile)
{
struct repository *r = the_repository;
struct ref *ref = copy_ref_list(orig_ref);
enum fetch_state state = FETCH_CHECK_LOCAL;
struct oidset common = OIDSET_INIT;
struct packet_reader reader;
int in_vain = 0;
int haves_to_send = INITIAL_FLUSH;
struct fetch_negotiator negotiator;
fetch_negotiator_init(&negotiator, negotiation_algorithm);
fetch_negotiator_init(r, &negotiator);
packet_reader_init(&reader, fd[0], NULL, 0,
PACKET_READ_CHOMP_NEWLINE |
PACKET_READ_DIE_ON_ERR_PACKET);
Expand Down Expand Up @@ -1499,8 +1500,6 @@ static void fetch_pack_config(void)
git_config_get_bool("repack.usedeltabaseoffset", &prefer_ofs_delta);
git_config_get_bool("fetch.fsckobjects", &fetch_fsck_objects);
git_config_get_bool("transfer.fsckobjects", &transfer_fsck_objects);
git_config_get_string("fetch.negotiationalgorithm",
&negotiation_algorithm);

git_config(fetch_pack_config_cb, NULL);
}
Expand Down
Loading

0 comments on commit 8f776be

Please sign in to comment.