mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-10 22:15:04 -05:00
environment: move "trust_ctime" into struct repo_config_values
The `core.trustctime` configuration is currently stored in the global variable `trust_ctime`, which makes it shared across repository instances in a single process. Store it instead in `repo_config_values`, where eagerly‑parsed repository configuration lives. `core.trustctime` is parsed eagerly because it is used in low‑level stat‑matching functions (`match_stat_data()`), where a lazy parse could cause unexpected fatal errors, result in a performance regression and complicate libification efforts. This preserves that behavior while tying the value to the repository from which it was read, avoiding cross‑repository state leakage and continuing the effort to reduce reliance on global configuration state. Update all references to use repo_config_values(). Mentored-by: Christian Couder <christian.couder@gmail.com> Signed-off-by: Olamide Caleb Bello <belkid98@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
94f057755b
commit
18684282df
@@ -42,7 +42,6 @@ static int pack_compression_seen;
|
||||
static int zlib_compression_seen;
|
||||
|
||||
int trust_executable_bit = 1;
|
||||
int trust_ctime = 1;
|
||||
int check_stat = 1;
|
||||
int has_symlinks = 1;
|
||||
int minimum_abbrev = 4, default_abbrev = -1;
|
||||
@@ -309,7 +308,7 @@ int git_default_core_config(const char *var, const char *value,
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(var, "core.trustctime")) {
|
||||
trust_ctime = git_config_bool(var, value);
|
||||
cfg->trust_ctime = git_config_bool(var, value);
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(var, "core.checkstat")) {
|
||||
@@ -721,4 +720,5 @@ void repo_config_values_init(struct repo_config_values *cfg)
|
||||
cfg->attributes_file = NULL;
|
||||
cfg->apply_sparse_checkout = 0;
|
||||
cfg->branch_track = BRANCH_TRACK_REMOTE;
|
||||
cfg->trust_ctime = 1;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ struct repo_config_values {
|
||||
/* section "core" config values */
|
||||
char *attributes_file;
|
||||
int apply_sparse_checkout;
|
||||
int trust_ctime;
|
||||
|
||||
/* section "branch" config values */
|
||||
enum branch_track branch_track;
|
||||
@@ -161,7 +162,6 @@ extern char *git_work_tree_cfg;
|
||||
|
||||
/* Environment bits from configuration mechanism */
|
||||
extern int trust_executable_bit;
|
||||
extern int trust_ctime;
|
||||
extern int check_stat;
|
||||
extern int has_symlinks;
|
||||
extern int minimum_abbrev, default_abbrev;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "git-compat-util.h"
|
||||
#include "environment.h"
|
||||
#include "statinfo.h"
|
||||
#include "repository.h"
|
||||
|
||||
/*
|
||||
* Munge st_size into an unsigned int.
|
||||
@@ -63,17 +64,18 @@ void fake_lstat_data(const struct stat_data *sd, struct stat *st)
|
||||
int match_stat_data(const struct stat_data *sd, struct stat *st)
|
||||
{
|
||||
int changed = 0;
|
||||
struct repo_config_values *cfg = repo_config_values(the_repository);
|
||||
|
||||
if (sd->sd_mtime.sec != (unsigned int)st->st_mtime)
|
||||
changed |= MTIME_CHANGED;
|
||||
if (trust_ctime && check_stat &&
|
||||
if (cfg->trust_ctime && check_stat &&
|
||||
sd->sd_ctime.sec != (unsigned int)st->st_ctime)
|
||||
changed |= CTIME_CHANGED;
|
||||
|
||||
#ifdef USE_NSEC
|
||||
if (check_stat && sd->sd_mtime.nsec != ST_MTIME_NSEC(*st))
|
||||
changed |= MTIME_CHANGED;
|
||||
if (trust_ctime && check_stat &&
|
||||
if (cfg->trust_ctime && check_stat &&
|
||||
sd->sd_ctime.nsec != ST_CTIME_NSEC(*st))
|
||||
changed |= CTIME_CHANGED;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user