@@ -24,8 +24,8 @@ static int info_only;
2424static int force_remove ;
2525static int verbose ;
2626static int mark_valid_only ;
27- #define MARK_VALID 1
28- #define UNMARK_VALID 2
27+ #define MARK_FLAG 1
28+ #define UNMARK_FLAG 2
2929
3030static void report (const char * fmt , ...)
3131{
@@ -40,19 +40,15 @@ static void report(const char *fmt, ...)
4040 va_end (vp );
4141}
4242
43- static int mark_valid (const char * path )
43+ static int mark_ce_flags (const char * path , int flag , int mark )
4444{
4545 int namelen = strlen (path );
4646 int pos = cache_name_pos (path , namelen );
4747 if (0 <= pos ) {
48- switch (mark_valid_only ) {
49- case MARK_VALID :
50- active_cache [pos ]-> ce_flags |= CE_VALID ;
51- break ;
52- case UNMARK_VALID :
53- active_cache [pos ]-> ce_flags &= ~CE_VALID ;
54- break ;
55- }
48+ if (mark )
49+ active_cache [pos ]-> ce_flags |= flag ;
50+ else
51+ active_cache [pos ]-> ce_flags &= ~flag ;
5652 cache_tree_invalidate_path (active_cache_tree , path );
5753 active_cache_changed = 1 ;
5854 return 0 ;
@@ -276,7 +272,7 @@ static void update_one(const char *path, const char *prefix, int prefix_length)
276272 goto free_return ;
277273 }
278274 if (mark_valid_only ) {
279- if (mark_valid ( p ))
275+ if (mark_ce_flags ( p , CE_VALID , mark_valid_only == MARK_FLAG ))
280276 die ("Unable to mark file %s" , path );
281277 goto free_return ;
282278 }
@@ -647,11 +643,11 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
647643 continue ;
648644 }
649645 if (!strcmp (path , "--assume-unchanged" )) {
650- mark_valid_only = MARK_VALID ;
646+ mark_valid_only = MARK_FLAG ;
651647 continue ;
652648 }
653649 if (!strcmp (path , "--no-assume-unchanged" )) {
654- mark_valid_only = UNMARK_VALID ;
650+ mark_valid_only = UNMARK_FLAG ;
655651 continue ;
656652 }
657653 if (!strcmp (path , "--info-only" )) {
0 commit comments