config: move core.ignorestat into repo config
PATCH 1/1 config: move core.ignorestat into repo config
From: Joy Gundu <[email protected]>
The core.ignorestat setting is currently stored in the standalone assume_unchanged global variable. This makes the configuration state harder to encapsulate as Git moves towards being usable as a library.
Store the setting in struct repo_config_values instead and update its consumers to read the value through repo_config_values(). This removes another standalone global while preserving the existing behavior.
Add a test covering the effect of core.ignorestat on updated paths.
---
config: move core.ignorestat into repo config
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2278%2FJoiejoie1%2Foutreachy%2Fassume-unchanged-config-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2278/Joiejoie1/outreachy/assume-unchanged-config-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2278
builtin/update-index.c | 2 +- environment.c | 3 +-- environment.h | 3 +-- read-cache.c | 8 +++++--- t/t2106-update-index-assume-unchanged.sh | 9 +++++++++ 5 files changed, 17 insertions(+), 8 deletions(-)
builtin/update-index.c +1 -1
@@ -431,7 +431,7 @@ static int add_cacheinfo(unsigned int mode, const struct object_id *oid, ce->ce_flags =create_ce_flags (stage); ce->ce_namelen = len; ce->ce_mode =create_ce_mode (mode); -if (assume_unchanged) +if (repo_config_values (the_repository)->assume_unchanged) ce->ce_flags |=CE_VALID ; option = allow_add ?ADD_CACHE_OK_TO_ADD :0 ; option |= allow_replace ?ADD_CACHE_OK_TO_REPLACE :0 ;
environment.c +1 -2
@@ -42,7 +42,6 @@ static int pack_compression_seen;static int zlib_compression_seen;int minimum_abbrev =4 , default_abbrev =-1 ; -int assume_unchanged;char *git_commit_encoding;char *git_log_output_encoding;int fsync_object_files =-1 ;
@@ -371,7 +370,7 @@ int git_default_core_config(const char *var, const char *value, }if (!strcmp (var,"core.ignorestat" )) { - assume_unchanged =git_config_bool (var, value); + cfg->assume_unchanged =git_config_bool (var, value);return 0 ; }
environment.h +1 -2
@@ -146,6 +146,7 @@ struct repo_config_values {int protect_hfs;int protect_ntfs;int ignore_case; +int assume_unchanged;int trust_executable_bit;int has_symlinks;int use_nanosec;
@@ -242,9 +243,7 @@ int have_git_dir(void);/* Environment bits from configuration mechanism */ extern int minimum_abbrev, default_abbrev; -extern int assume_unchanged;extern unsigned long pack_size_limit_cfg; -extern int grafts_keep_true_parents;const char *get_log_output_encoding (void );
read-cache.c +5 -3
@@ -194,7 +194,7 @@ void fill_stat_cache_info(struct index_state *istate, struct cache_entry *ce, st {fill_stat_data (&ce->ce_stat_data, st); -if (assume_unchanged) +if (repo_config_values (the_repository)->assume_unchanged) ce->ce_flags |=CE_VALID ;if (S_ISREG (st->st_mode)) {
@@ -1415,7 +1415,8 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,* is not marked VALID, this is the place to mark it * valid again, under "assume unchanged" mode. */ -if (ignore_valid && assume_unchanged && +if (ignore_valid && +repo_config_values (the_repository)->assume_unchanged && !(ce->ce_flags &CE_VALID )) ;/* mark this one VALID again */ else {
@@ -1450,7 +1451,8 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,* (i.e. things to be edited) will reacquire CE_VALID bit * automatically, which is not really what we want. */ -if (!ignore_valid && assume_unchanged && +if (!ignore_valid && +repo_config_values (the_repository)->assume_unchanged && !(ce->ce_flags &CE_VALID )) updated->ce_flags &= ~CE_VALID ;
t/t2106-update-index-assume-unchanged.sh +9 -0
@@ -24,4 +24,13 @@ test_expect_success 'do not switch branches with dirty file' ' test_grep overwritten err ' +test_expect_success 'core.ignorestat marks updated paths assume-unchanged' ' + git reset --hard && + git update-index --no-assume-unchanged file && + test_config core.ignorestat true && + echo changed >file && + git update-index file && + test "$(git ls-files -v file)" = "h file" +' + test_done
base-commit: 7e34d8174dcda3435d1404c9a30bef46afe6c13e
Signature · 1 line
gitgitgadget