test-dump-untracked-cache: don't modify the untracked cache
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 state of the untracked cache and as test-dump-untracked-cache indirectly calls this function, we need a mechanism to prevent read_index_from() from changing the untracked cache state when it's called from test-dump-untracked-cache. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Jan 27, 2016 at 07:58 UTC
dae6c322fa106d72dabd7551f388715e6a9f2ebf
4 files changed
+22
cache.h
+7
@@ -1604,6 +1604,13 @@ extern int git_config_get_maybe_bool(const char *key, int *dest);
1604
extern int git_config_get_pathname(const char *key, const char **dest);
1605
extern int git_config_get_untracked_cache(void);
1606
1607
+/*
1608
+ * This is a hack for test programs like test-dump-untracked-cache to
1609
+ * ensure that they do not modify the untracked cache when reading it.
1610
+ * Do not use it otherwise!
1611
+ */
1612
+extern int ignore_untracked_cache_config;
1613
+
1614
struct key_value_info {
1615
const char *filename;
1616
int linenr;
config.c
+4
@@ -1599,6 +1599,10 @@ int git_config_get_untracked_cache(void)
1599
int val = -1;
1600
const char *v;
1601
1602
+ /* Hack for test programs like test-dump-untracked-cache */
1603
+ if (ignore_untracked_cache_config)
1604
+ return -1;
1605
+
1606
if (!git_config_get_maybe_bool("core.untrackedcache", &val))
1607
return val;
1608
environment.c
+7
@@ -87,6 +87,13 @@ int auto_comment_line_char;
87
/* Parallel index stat data preload? */
88
int core_preload_index = 1;
89
90
+/*
91
+ * This is a hack for test programs like test-dump-untracked-cache to
92
+ * ensure that they do not modify the untracked cache when reading it.
93
+ * Do not use it otherwise!
94
+ */
95
+int ignore_untracked_cache_config;
96
+
97
/* This is set by setup_git_dir_gently() and/or git_default_config() */
98
char *git_work_tree_cfg;
99
static char *work_tree;
test-dump-untracked-cache.c
+4
@@ -44,6 +44,10 @@ int main(int ac, char **av)
44
{
45
struct untracked_cache *uc;
46
struct strbuf base = STRBUF_INIT;
47
+
48
+ /* Hack to avoid modifying the untracked cache when we read it */
49
+ ignore_untracked_cache_config = 1;
50
+
51
setup_git_directory();
52
if (read_cache() < 0)
53
die("unable to read index file");