To correctly perform its testing function, test-dump-untracked-cache should not change the state of the untracked cache in the index. As a previous patch makes read_index_from() change the untracked cache status and as test-dump-untracked-cache indirectly calls this function, we need a mechanism to prevent read_index_from() to change the untracked cache state when it's called from test-dump-untracked-cache. Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx> --- cache.h | 2 ++ config.c | 3 +++ environment.c | 6 ++++++ test-dump-untracked-cache.c | 2 ++ 4 files changed, 13 insertions(+) diff --git a/cache.h b/cache.h index 59a15fd..89c7e10 100644 --- a/cache.h +++ b/cache.h @@ -1605,6 +1605,8 @@ extern int git_config_get_maybe_bool(const char *key, int *dest); extern int git_config_get_pathname(const char *key, const char **dest); extern int git_config_get_untracked_cache(void); +extern int ignore_untracked_cache_config; + struct key_value_info { const char *filename; int linenr; diff --git a/config.c b/config.c index 647a15e..a4f70f7 100644 --- a/config.c +++ b/config.c @@ -1599,6 +1599,9 @@ int git_config_get_untracked_cache(void) int val = -1; const char *v; + if (ignore_untracked_cache_config) + return -1; + if (!git_config_get_maybe_bool("core.untrackedcache", &val)) return val; diff --git a/environment.c b/environment.c index 1cc4aab..74294ee 100644 --- a/environment.c +++ b/environment.c @@ -87,6 +87,12 @@ int auto_comment_line_char; /* Parallel index stat data preload? */ int core_preload_index = 1; +/* + * This is to ensure that the untracked cache is not modified, for + * example in test programs like test-dump-untracked-cache. + */ +int ignore_untracked_cache_config; + /* This is set by setup_git_dir_gently() and/or git_default_config() */ char *git_work_tree_cfg; static char *work_tree; diff --git a/test-dump-untracked-cache.c b/test-dump-untracked-cache.c index 25d855d..8d1293c 100644 --- a/test-dump-untracked-cache.c +++ b/test-dump-untracked-cache.c @@ -44,6 +44,8 @@ int main(int ac, char **av) { struct untracked_cache *uc; struct strbuf base = STRBUF_INIT; + + ignore_untracked_cache_config = 1; setup_git_directory(); if (read_cache() < 0) die("unable to read index file"); -- 2.7.0.36.g20612a7 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html