@@ -35,6 +35,14 @@ static int mark_skip_worktree_only;
35
35
#define UNMARK_FLAG 2
36
36
static struct strbuf mtime_dir = STRBUF_INIT ;
37
37
38
+ /* Untracked cache mode */
39
+ enum uc_mode {
40
+ UC_UNSPECIFIED = -1 ,
41
+ UC_DISABLE = 0 ,
42
+ UC_ENABLE ,
43
+ UC_FORCE
44
+ };
45
+
38
46
__attribute__((format (printf , 1 , 2 )))
39
47
static void report (const char * fmt , ...)
40
48
{
@@ -902,7 +910,7 @@ static int reupdate_callback(struct parse_opt_ctx_t *ctx,
902
910
int cmd_update_index (int argc , const char * * argv , const char * prefix )
903
911
{
904
912
int newfd , entries , has_errors = 0 , line_termination = '\n' ;
905
- int untracked_cache = -1 ;
913
+ enum uc_mode untracked_cache = UC_UNSPECIFIED ;
906
914
int read_from_stdin = 0 ;
907
915
int prefix_length = prefix ? strlen (prefix ) : 0 ;
908
916
int preferred_index_format = 0 ;
@@ -997,7 +1005,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
997
1005
OPT_BOOL (0 , "untracked-cache" , & untracked_cache ,
998
1006
N_ ("enable/disable untracked cache" )),
999
1007
OPT_SET_INT (0 , "force-untracked-cache" , & untracked_cache ,
1000
- N_ ("enable untracked cache without testing the filesystem" ), 2 ),
1008
+ N_ ("enable untracked cache without testing the filesystem" ), UC_FORCE ),
1001
1009
OPT_END ()
1002
1010
};
1003
1011
@@ -1104,10 +1112,10 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
1104
1112
the_index .split_index = NULL ;
1105
1113
the_index .cache_changed |= SOMETHING_CHANGED ;
1106
1114
}
1107
- if (untracked_cache > 0 ) {
1115
+ if (untracked_cache > UC_DISABLE ) {
1108
1116
struct untracked_cache * uc ;
1109
1117
1110
- if (untracked_cache < 2 ) {
1118
+ if (untracked_cache < UC_FORCE ) {
1111
1119
setup_work_tree ();
1112
1120
if (!test_if_untracked_cache_is_supported ())
1113
1121
return 1 ;
@@ -1122,7 +1130,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
1122
1130
}
1123
1131
add_untracked_ident (the_index .untracked );
1124
1132
the_index .cache_changed |= UNTRACKED_CHANGED ;
1125
- } else if (! untracked_cache && the_index .untracked ) {
1133
+ } else if (untracked_cache == UC_DISABLE && the_index .untracked ) {
1126
1134
free_untracked_cache (the_index .untracked );
1127
1135
the_index .untracked = NULL ;
1128
1136
the_index .cache_changed |= UNTRACKED_CHANGED ;
0 commit comments