Skip to content

Commit eaab83d

Browse files
chriscoolgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 113e641 commit eaab83d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Documentation/git-update-index.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SYNOPSIS
1818
[--[no-]skip-worktree]
1919
[--ignore-submodules]
2020
[--[no-]split-index]
21-
[--[no-|force-]untracked-cache]
21+
[--[no-|test-|force-]untracked-cache]
2222
[--really-refresh] [--unresolve] [--again | -g]
2323
[--info-only] [--index-info]
2424
[-z] [--stdin] [--index-version <n>]
@@ -180,6 +180,16 @@ may not support it yet.
180180
system must change `st_mtime` field of a directory if files
181181
are added or deleted in that directory.
182182

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+
183193
--force-untracked-cache::
184194
For safety, `--untracked-cache` performs tests on the working
185195
directory to make sure untracked cache can be used. These

builtin/update-index.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ enum uc_mode {
4040
UC_UNSPECIFIED = -1,
4141
UC_DISABLE = 0,
4242
UC_ENABLE,
43+
UC_TEST,
4344
UC_FORCE
4445
};
4546

@@ -1004,6 +1005,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
10041005
N_("enable or disable split index")),
10051006
OPT_BOOL(0, "untracked-cache", &untracked_cache,
10061007
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),
10071010
OPT_SET_INT(0, "force-untracked-cache", &untracked_cache,
10081011
N_("enable untracked cache without testing the filesystem"), UC_FORCE),
10091012
OPT_END()
@@ -1119,6 +1122,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
11191122
setup_work_tree();
11201123
if (!test_if_untracked_cache_is_supported())
11211124
return 1;
1125+
if (untracked_cache == UC_TEST)
1126+
return 0;
11221127
}
11231128
if (!the_index.untracked) {
11241129
uc = xcalloc(1, sizeof(*uc));

0 commit comments

Comments
 (0)