Skip to content

Commit 49418d1

Browse files
committed
Merge branch 'ob/more-repo-config-values' into jch
* ob/more-repo-config-values: env: move "warn_on_object_refname_ambiguity" into `struct repo_config_values` env: move "sparse_expect_files_outside_of_patterns" into `repo_config_values` env: move "core_sparse_checkout_cone" into `struct repo_config_values` environment: move "precomposed_unicode" into `struct repo_config_values` environment: move "pack_compression_level" into `struct repo_config_values` environment: move `zlib_compression_level` into `struct repo_config_values` environment: move "check_stat" into `struct repo_config_values` environment: move "trust_ctime" into `struct repo_config_values`
2 parents 4944388 + 15c1234 commit 49418d1

20 files changed

Lines changed: 126 additions & 88 deletions

builtin/cat-file.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ static int batch_objects(struct batch_options *opt)
930930
struct strbuf input = STRBUF_INIT;
931931
struct strbuf output = STRBUF_INIT;
932932
struct expand_data data = EXPAND_DATA_INIT;
933+
struct repo_config_values *cfg = repo_config_values(the_repository);
933934
int save_warning;
934935
int retval = 0;
935936

@@ -1002,8 +1003,8 @@ static int batch_objects(struct batch_options *opt)
10021003
* warn) ends up dwarfing the actual cost of the object lookups
10031004
* themselves. We can work around it by just turning off the warning.
10041005
*/
1005-
save_warning = warn_on_object_refname_ambiguity;
1006-
warn_on_object_refname_ambiguity = 0;
1006+
save_warning = cfg->warn_on_object_refname_ambiguity;
1007+
cfg->warn_on_object_refname_ambiguity = 0;
10071008

10081009
if (opt->batch_mode == BATCH_MODE_QUEUE_AND_DISPATCH) {
10091010
batch_objects_command(opt, &output, &data);
@@ -1031,7 +1032,7 @@ static int batch_objects(struct batch_options *opt)
10311032
cleanup:
10321033
strbuf_release(&input);
10331034
strbuf_release(&output);
1034-
warn_on_object_refname_ambiguity = save_warning;
1035+
cfg->warn_on_object_refname_ambiguity = save_warning;
10351036
return retval;
10361037
}
10371038

builtin/fast-import.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ static int store_object(
965965
unsigned long hdrlen, deltalen;
966966
struct git_hash_ctx c;
967967
git_zstream s;
968+
struct repo_config_values *cfg = repo_config_values(the_repository);
968969

969970
hdrlen = format_object_header((char *)hdr, sizeof(hdr), type,
970971
dat->len);
@@ -1005,7 +1006,7 @@ static int store_object(
10051006
} else
10061007
delta = NULL;
10071008

1008-
git_deflate_init(&s, pack_compression_level);
1009+
git_deflate_init(&s, cfg->pack_compression_level);
10091010
if (delta) {
10101011
s.next_in = delta;
10111012
s.avail_in = deltalen;
@@ -1032,7 +1033,7 @@ static int store_object(
10321033
if (delta) {
10331034
FREE_AND_NULL(delta);
10341035

1035-
git_deflate_init(&s, pack_compression_level);
1036+
git_deflate_init(&s, cfg->pack_compression_level);
10361037
s.next_in = (void *)dat->buf;
10371038
s.avail_in = dat->len;
10381039
s.avail_out = git_deflate_bound(&s, s.avail_in);
@@ -1115,6 +1116,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
11151116
struct git_hash_ctx c;
11161117
git_zstream s;
11171118
struct hashfile_checkpoint checkpoint;
1119+
struct repo_config_values *cfg = repo_config_values(the_repository);
11181120
int status = Z_OK;
11191121

11201122
/* Determine if we should auto-checkpoint. */
@@ -1134,7 +1136,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
11341136

11351137
crc32_begin(pack_file);
11361138

1137-
git_deflate_init(&s, pack_compression_level);
1139+
git_deflate_init(&s, cfg->pack_compression_level);
11381140

11391141
hdrlen = encode_in_pack_object_header(out_buf, out_sz, OBJ_BLOB, len);
11401142

builtin/index-pack.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,8 +1417,9 @@ static int write_compressed(struct hashfile *f, void *in, unsigned int size)
14171417
git_zstream stream;
14181418
int status;
14191419
unsigned char outbuf[4096];
1420+
struct repo_config_values *cfg = repo_config_values(the_repository);
14201421

1421-
git_deflate_init(&stream, zlib_compression_level);
1422+
git_deflate_init(&stream, cfg->zlib_compression_level);
14221423
stream.next_in = in;
14231424
stream.avail_in = size;
14241425

builtin/mv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ int cmd_mv(int argc,
575575

576576
if (ignore_sparse &&
577577
cfg->apply_sparse_checkout &&
578-
core_sparse_checkout_cone) {
578+
cfg->core_sparse_checkout_cone) {
579579
/*
580580
* NEEDSWORK: we are *not* paying attention to
581581
* "out-to-out" move (<source> is out-of-cone and

builtin/pack-objects.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,9 @@ static unsigned long do_compress(void **pptr, unsigned long size)
386386
git_zstream stream;
387387
void *in, *out;
388388
unsigned long maxsize;
389+
struct repo_config_values *cfg = repo_config_values(the_repository);
389390

390-
git_deflate_init(&stream, pack_compression_level);
391+
git_deflate_init(&stream, cfg->pack_compression_level);
391392
maxsize = git_deflate_bound(&stream, size);
392393

393394
in = *pptr;
@@ -413,8 +414,9 @@ static unsigned long write_large_blob_data(struct odb_read_stream *st, struct ha
413414
unsigned char ibuf[1024 * 16];
414415
unsigned char obuf[1024 * 16];
415416
unsigned long olen = 0;
417+
struct repo_config_values *cfg = repo_config_values(the_repository);
416418

417-
git_deflate_init(&stream, pack_compression_level);
419+
git_deflate_init(&stream, cfg->pack_compression_level);
418420

419421
for (;;) {
420422
ssize_t readlen;
@@ -4796,6 +4798,7 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv)
47964798
struct setup_revision_opt s_r_opt = {
47974799
.allow_exclude_promisor_objects = 1,
47984800
};
4801+
struct repo_config_values *cfg = repo_config_values(the_repository);
47994802
char line[1000];
48004803
int flags = 0;
48014804
int save_warning;
@@ -4806,8 +4809,8 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv)
48064809
/* make sure shallows are read */
48074810
is_repository_shallow(the_repository);
48084811

4809-
save_warning = warn_on_object_refname_ambiguity;
4810-
warn_on_object_refname_ambiguity = 0;
4812+
save_warning = cfg->warn_on_object_refname_ambiguity;
4813+
cfg->warn_on_object_refname_ambiguity = 0;
48114814

48124815
while (fgets(line, sizeof(line), stdin) != NULL) {
48134816
int len = strlen(line);
@@ -4835,7 +4838,7 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv)
48354838
die(_("bad revision '%s'"), line);
48364839
}
48374840

4838-
warn_on_object_refname_ambiguity = save_warning;
4841+
cfg->warn_on_object_refname_ambiguity = save_warning;
48394842

48404843
if (use_bitmap_index && !get_object_list_from_bitmap(revs))
48414844
return;
@@ -5013,6 +5016,7 @@ int cmd_pack_objects(int argc,
50135016
struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
50145017
struct list_objects_filter_options filter_options =
50155018
LIST_OBJECTS_FILTER_INIT;
5019+
struct repo_config_values *cfg = repo_config_values(the_repository);
50165020

50175021
struct option pack_objects_options[] = {
50185022
OPT_CALLBACK_F('q', "quiet", &progress, NULL,
@@ -5094,7 +5098,7 @@ int cmd_pack_objects(int argc,
50945098
N_("ignore packs that have companion .keep file")),
50955099
OPT_STRING_LIST(0, "keep-pack", &keep_pack_list, N_("name"),
50965100
N_("ignore this pack")),
5097-
OPT_INTEGER(0, "compression", &pack_compression_level,
5101+
OPT_INTEGER(0, "compression", &cfg->pack_compression_level,
50985102
N_("pack compression level")),
50995103
OPT_BOOL(0, "keep-true-parents", &grafts_keep_true_parents,
51005104
N_("do not hide commits by grafts")),
@@ -5253,10 +5257,10 @@ int cmd_pack_objects(int argc,
52535257

52545258
if (!reuse_object)
52555259
reuse_delta = 0;
5256-
if (pack_compression_level == -1)
5257-
pack_compression_level = Z_DEFAULT_COMPRESSION;
5258-
else if (pack_compression_level < 0 || pack_compression_level > Z_BEST_COMPRESSION)
5259-
die(_("bad pack compression level %d"), pack_compression_level);
5260+
if (cfg->pack_compression_level == -1)
5261+
cfg->pack_compression_level = Z_DEFAULT_COMPRESSION;
5262+
else if (cfg->pack_compression_level < 0 || cfg->pack_compression_level > Z_BEST_COMPRESSION)
5263+
die(_("bad pack compression level %d"), cfg->pack_compression_level);
52605264

52615265
if (!delta_search_threads) /* --threads=0 means autodetect */
52625266
delta_search_threads = online_cpus();

builtin/sparse-checkout.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix,
7373

7474
memset(&pl, 0, sizeof(pl));
7575

76-
pl.use_cone_patterns = core_sparse_checkout_cone;
76+
pl.use_cone_patterns = cfg->core_sparse_checkout_cone;
7777

7878
sparse_filename = get_sparse_checkout_filename();
7979
res = add_patterns_from_file_to_list(sparse_filename, "", 0, &pl, NULL, 0);
@@ -334,6 +334,7 @@ static int write_patterns_and_update(struct repository *repo,
334334
FILE *fp;
335335
struct lock_file lk = LOCK_INIT;
336336
int result;
337+
struct repo_config_values *cfg = repo_config_values(the_repository);
337338

338339
sparse_filename = get_sparse_checkout_filename();
339340

@@ -353,7 +354,7 @@ static int write_patterns_and_update(struct repository *repo,
353354
if (!fp)
354355
die_errno(_("unable to fdopen %s"), get_lock_file_path(&lk));
355356

356-
if (core_sparse_checkout_cone)
357+
if (cfg->core_sparse_checkout_cone)
357358
write_cone_to_file(fp, pl);
358359
else
359360
write_patterns_to_file(fp, pl);
@@ -402,15 +403,15 @@ static enum sparse_checkout_mode update_cone_mode(int *cone_mode) {
402403

403404
/* If not specified, use previous definition of cone mode */
404405
if (*cone_mode == -1 && cfg->apply_sparse_checkout)
405-
*cone_mode = core_sparse_checkout_cone;
406+
*cone_mode = cfg->core_sparse_checkout_cone;
406407

407408
/* Set cone/non-cone mode appropriately */
408409
cfg->apply_sparse_checkout = 1;
409410
if (*cone_mode == 1 || *cone_mode == -1) {
410-
core_sparse_checkout_cone = 1;
411+
cfg->core_sparse_checkout_cone = 1;
411412
return MODE_CONE_PATTERNS;
412413
}
413-
core_sparse_checkout_cone = 0;
414+
cfg->core_sparse_checkout_cone = 0;
414415
return MODE_ALL_PATTERNS;
415416
}
416417

@@ -577,7 +578,9 @@ static void add_patterns_from_input(struct pattern_list *pl,
577578
FILE *file)
578579
{
579580
int i;
580-
if (core_sparse_checkout_cone) {
581+
struct repo_config_values *cfg = repo_config_values(the_repository);
582+
583+
if (cfg->core_sparse_checkout_cone) {
581584
struct strbuf line = STRBUF_INIT;
582585

583586
hashmap_init(&pl->recursive_hashmap, pl_hashmap_cmp, NULL, 0);
@@ -636,13 +639,14 @@ static void add_patterns_cone_mode(int argc, const char **argv,
636639
struct pattern_entry *pe;
637640
struct hashmap_iter iter;
638641
struct pattern_list existing;
642+
struct repo_config_values *cfg = repo_config_values(the_repository);
639643
char *sparse_filename = get_sparse_checkout_filename();
640644

641645
add_patterns_from_input(pl, argc, argv,
642646
use_stdin ? stdin : NULL);
643647

644648
memset(&existing, 0, sizeof(existing));
645-
existing.use_cone_patterns = core_sparse_checkout_cone;
649+
existing.use_cone_patterns = cfg->core_sparse_checkout_cone;
646650

647651
if (add_patterns_from_file_to_list(sparse_filename, "", 0,
648652
&existing, NULL, 0))
@@ -690,7 +694,7 @@ static int modify_pattern_list(struct repository *repo,
690694

691695
switch (m) {
692696
case ADD:
693-
if (core_sparse_checkout_cone)
697+
if (cfg->core_sparse_checkout_cone)
694698
add_patterns_cone_mode(args->nr, args->v, pl, use_stdin);
695699
else
696700
add_patterns_literal(args->nr, args->v, pl, use_stdin);
@@ -723,11 +727,12 @@ static void sanitize_paths(struct repository *repo,
723727
const char *prefix, int skip_checks)
724728
{
725729
int i;
730+
struct repo_config_values *cfg = repo_config_values(the_repository);
726731

727732
if (!args->nr)
728733
return;
729734

730-
if (prefix && *prefix && core_sparse_checkout_cone) {
735+
if (prefix && *prefix && cfg->core_sparse_checkout_cone) {
731736
/*
732737
* The args are not pathspecs, so unfortunately we
733738
* cannot imitate how cmd_add() uses parse_pathspec().
@@ -745,10 +750,10 @@ static void sanitize_paths(struct repository *repo,
745750
if (skip_checks)
746751
return;
747752

748-
if (prefix && *prefix && !core_sparse_checkout_cone)
753+
if (prefix && *prefix && !cfg->core_sparse_checkout_cone)
749754
die(_("please run from the toplevel directory in non-cone mode"));
750755

751-
if (core_sparse_checkout_cone) {
756+
if (cfg->core_sparse_checkout_cone) {
752757
for (i = 0; i < args->nr; i++) {
753758
if (args->v[i][0] == '/')
754759
die(_("specify directories rather than patterns (no leading slash)"));
@@ -770,7 +775,7 @@ static void sanitize_paths(struct repository *repo,
770775
if (S_ISSPARSEDIR(ce->ce_mode))
771776
continue;
772777

773-
if (core_sparse_checkout_cone)
778+
if (cfg->core_sparse_checkout_cone)
774779
die(_("'%s' is not a directory; to treat it as a directory anyway, rerun with --skip-checks"), args->v[i]);
775780
else
776781
warning(_("pass a leading slash before paths such as '%s' if you want a single file (see NON-CONE PROBLEMS in the git-sparse-checkout manual)."), args->v[i]);
@@ -837,6 +842,7 @@ static struct sparse_checkout_set_opts {
837842
static int sparse_checkout_set(int argc, const char **argv, const char *prefix,
838843
struct repository *repo)
839844
{
845+
struct repo_config_values *cfg = repo_config_values(the_repository);
840846
int default_patterns_nr = 2;
841847
const char *default_patterns[] = {"/*", "!/*/", NULL};
842848

@@ -874,7 +880,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix,
874880
* non-cone mode, if nothing is specified, manually select just the
875881
* top-level directory (much as 'init' would do).
876882
*/
877-
if (!core_sparse_checkout_cone && !set_opts.use_stdin && argc == 0) {
883+
if (!cfg->core_sparse_checkout_cone && !set_opts.use_stdin && argc == 0) {
878884
for (int i = 0; i < default_patterns_nr; i++)
879885
strvec_push(&patterns, default_patterns[i]);
880886
} else {
@@ -978,7 +984,7 @@ static int sparse_checkout_clean(int argc, const char **argv,
978984
setup_work_tree(the_repository);
979985
if (!cfg->apply_sparse_checkout)
980986
die(_("must be in a sparse-checkout to clean directories"));
981-
if (!core_sparse_checkout_cone)
987+
if (!cfg->core_sparse_checkout_cone)
982988
die(_("must be in a cone-mode sparse-checkout to clean directories"));
983989

984990
argc = parse_options(argc, argv, prefix,
@@ -1142,6 +1148,7 @@ static int sparse_checkout_check_rules(int argc, const char **argv, const char *
11421148
FILE *fp;
11431149
int ret;
11441150
struct pattern_list pl = {0};
1151+
struct repo_config_values *cfg = repo_config_values(the_repository);
11451152
char *sparse_filename;
11461153
check_rules_opts.cone_mode = -1;
11471154

@@ -1153,7 +1160,7 @@ static int sparse_checkout_check_rules(int argc, const char **argv, const char *
11531160
check_rules_opts.cone_mode = 1;
11541161

11551162
update_cone_mode(&check_rules_opts.cone_mode);
1156-
pl.use_cone_patterns = core_sparse_checkout_cone;
1163+
pl.use_cone_patterns = cfg->core_sparse_checkout_cone;
11571164
if (check_rules_opts.rules_file) {
11581165
fp = xfopen(check_rules_opts.rules_file, "r");
11591166
add_patterns_from_input(&pl, argc, argv, fp);

compat/precompose_utf8.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,18 @@ void probe_utf8_pathname_composition(void)
4848
static const char *auml_nfc = "\xc3\xa4";
4949
static const char *auml_nfd = "\x61\xcc\x88";
5050
int output_fd;
51-
if (precomposed_unicode != -1)
51+
struct repo_config_values *cfg = repo_config_values(the_repository);
52+
53+
if (cfg->precomposed_unicode != -1)
5254
return; /* We found it defined in the global config, respect it */
5355
repo_git_path_replace(the_repository, &path, "%s", auml_nfc);
5456
output_fd = open(path.buf, O_CREAT|O_EXCL|O_RDWR, 0600);
5557
if (output_fd >= 0) {
5658
close(output_fd);
5759
repo_git_path_replace(the_repository, &path, "%s", auml_nfd);
58-
precomposed_unicode = access(path.buf, R_OK) ? 0 : 1;
60+
cfg->precomposed_unicode = access(path.buf, R_OK) ? 0 : 1;
5961
repo_config_set(the_repository, "core.precomposeunicode",
60-
precomposed_unicode ? "true" : "false");
62+
cfg->precomposed_unicode ? "true" : "false");
6163
repo_git_path_replace(the_repository, &path, "%s", auml_nfc);
6264
if (unlink(path.buf))
6365
die_errno(_("failed to unlink '%s'"), path.buf);
@@ -69,14 +71,16 @@ const char *precompose_string_if_needed(const char *in)
6971
{
7072
size_t inlen;
7173
size_t outlen;
74+
struct repo_config_values *cfg = repo_config_values(the_repository);
75+
7276
if (!in)
7377
return NULL;
7478
if (has_non_ascii(in, (size_t)-1, &inlen)) {
7579
iconv_t ic_prec;
7680
char *out;
77-
if (precomposed_unicode < 0)
78-
repo_config_get_bool(the_repository, "core.precomposeunicode", &precomposed_unicode);
79-
if (precomposed_unicode != 1)
81+
if (cfg->precomposed_unicode < 0)
82+
repo_config_get_bool(the_repository, "core.precomposeunicode", &cfg->precomposed_unicode);
83+
if (cfg->precomposed_unicode != 1)
8084
return in;
8185
ic_prec = iconv_open(repo_encoding, path_encoding);
8286
if (ic_prec == (iconv_t) -1)
@@ -130,7 +134,9 @@ PREC_DIR *precompose_utf8_opendir(const char *dirname)
130134

131135
struct dirent_prec_psx *precompose_utf8_readdir(PREC_DIR *prec_dir)
132136
{
137+
struct repo_config_values *cfg = repo_config_values(the_repository);
133138
struct dirent *res;
139+
134140
res = readdir(prec_dir->dirp);
135141
if (res) {
136142
size_t namelenz = strlen(res->d_name) + 1; /* \0 */
@@ -149,7 +155,7 @@ struct dirent_prec_psx *precompose_utf8_readdir(PREC_DIR *prec_dir)
149155
prec_dir->dirent_nfc->d_ino = res->d_ino;
150156
prec_dir->dirent_nfc->d_type = res->d_type;
151157

152-
if ((precomposed_unicode == 1) && has_non_ascii(res->d_name, (size_t)-1, NULL)) {
158+
if ((cfg->precomposed_unicode == 1) && has_non_ascii(res->d_name, (size_t)-1, NULL)) {
153159
if (prec_dir->ic_precompose == (iconv_t)-1) {
154160
die("iconv_open(%s,%s) failed, but needed:\n"
155161
" precomposed unicode is not supported.\n"

0 commit comments

Comments
 (0)