@@ -741,6 +741,7 @@ static int reupdate_callback(struct parse_opt_ctx_t *ctx,
741
741
int cmd_update_index (int argc , const char * * argv , const char * prefix )
742
742
{
743
743
int newfd , entries , has_errors = 0 , line_termination = '\n' ;
744
+ int untracked_cache = -1 ;
744
745
int read_from_stdin = 0 ;
745
746
int prefix_length = prefix ? strlen (prefix ) : 0 ;
746
747
int preferred_index_format = 0 ;
@@ -832,6 +833,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
832
833
N_ ("write index in this format" )),
833
834
OPT_BOOL (0 , "split-index" , & split_index ,
834
835
N_ ("enable or disable split index" )),
836
+ OPT_BOOL (0 , "untracked-cache" , & untracked_cache ,
837
+ N_ ("enable/disable untracked cache" )),
835
838
OPT_END ()
836
839
};
837
840
@@ -938,6 +941,19 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
938
941
the_index .split_index = NULL ;
939
942
the_index .cache_changed |= SOMETHING_CHANGED ;
940
943
}
944
+ if (untracked_cache > 0 && !the_index .untracked ) {
945
+ struct untracked_cache * uc ;
946
+
947
+ uc = xcalloc (1 , sizeof (* uc ));
948
+ uc -> exclude_per_dir = ".gitignore" ;
949
+ /* should be the same flags used by git-status */
950
+ uc -> dir_flags = DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES ;
951
+ the_index .untracked = uc ;
952
+ the_index .cache_changed |= UNTRACKED_CHANGED ;
953
+ } else if (!untracked_cache && the_index .untracked ) {
954
+ the_index .untracked = NULL ;
955
+ the_index .cache_changed |= UNTRACKED_CHANGED ;
956
+ }
941
957
942
958
if (active_cache_changed ) {
943
959
if (newfd < 0 ) {
0 commit comments