update-index: add --test-untracked-cache
It is nice to just be able to test if untracked cache is supported without enabling it. Helped-by: David Turner <dturner@twopensource.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Jan 24, 2016 at 16:28 UTC
eaab83d0e574c9f3440a2364a7975f9ffe75f188
2 files changed
+16
-1
Documentation/git-update-index.txt
+11
-1
@@ -18,7 +18,7 @@ SYNOPSIS
18
[--[no-]skip-worktree]
19
[--ignore-submodules]
20
[--[no-]split-index]
21
- [--[no-|force-]untracked-cache]
21
+ [--[no-|test-|force-]untracked-cache]
22
[--really-refresh] [--unresolve] [--again | -g]
23
[--info-only] [--index-info]
24
[-z] [--stdin] [--index-version <n>]
@@ -180,6 +180,16 @@ may not support it yet.
180
system must change `st_mtime` field of a directory if files
181
are added or deleted in that directory.
182
183
+--test-untracked-cache::
184
+ Only perform tests on the working directory to make sure
185
+ untracked cache can be used. You have to manually enable
186
+ untracked cache using `--force-untracked-cache` (or
187
+ `--untracked-cache` but this will run the tests again)
188
+ afterwards if you really want to use it. If a test fails
189
+ the exit code is 1 and a message explains what is not
190
+ working as needed, otherwise the exit code is 0 and OK is
191
+ printed.
192
+
193
--force-untracked-cache::
194
For safety, `--untracked-cache` performs tests on the working
195
directory to make sure untracked cache can be used. These
builtin/update-index.c
+5
@@ -40,6 +40,7 @@ enum uc_mode {
40
UC_UNSPECIFIED = -1,
41
UC_DISABLE = 0,
42
UC_ENABLE,
43
+ UC_TEST,
44
UC_FORCE
45
};
46
@@ -1004,6 +1005,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
1005
N_("enable or disable split index")),
1006
OPT_BOOL(0, "untracked-cache", &untracked_cache,
1007
N_("enable/disable untracked cache")),
1008
+ OPT_SET_INT(0, "test-untracked-cache", &untracked_cache,
1009
+ N_("test if the filesystem supports untracked cache"), UC_TEST),
1010
OPT_SET_INT(0, "force-untracked-cache", &untracked_cache,
1011
N_("enable untracked cache without testing the filesystem"), UC_FORCE),
1012
OPT_END()
@@ -1119,6 +1122,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
1122
setup_work_tree();
1123
if (!test_if_untracked_cache_is_supported())
1124
return 1;
1125
+ if (untracked_cache == UC_TEST)
1126
+ return 0;
1127
}
1128
if (!the_index.untracked) {
1129
uc = xcalloc(1, sizeof(*uc));