@@ -277,8 +277,8 @@ static struct option builtin_rm_options[] = {
277277
278278int cmd_rm (int argc , const char * * argv , const char * prefix )
279279{
280- int i , newfd ;
281- const char * * pathspec ;
280+ int i , newfd , seen_any ;
281+ const char * * pathspec , * match ;
282282 char * seen ;
283283
284284 git_config (git_default_config , NULL );
@@ -314,7 +314,6 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
314314 pathspec = get_pathspec (prefix , argv );
315315 refresh_index (& the_index , REFRESH_QUIET , pathspec , NULL , NULL );
316316
317- seen = NULL ;
318317 for (i = 0 ; pathspec [i ] ; i ++ )
319318 /* nothing */ ;
320319 seen = xcalloc (i , 1 );
@@ -328,27 +327,24 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
328327 list .entry [list .nr ++ ].is_submodule = S_ISGITLINK (ce -> ce_mode );
329328 }
330329
331- if (pathspec ) {
332- const char * match ;
333- int seen_any = 0 ;
334- for (i = 0 ; (match = pathspec [i ]) != NULL ; i ++ ) {
335- if (!seen [i ]) {
336- if (!ignore_unmatch ) {
337- die (_ ("pathspec '%s' did not match any files" ),
338- match );
339- }
340- }
341- else {
342- seen_any = 1 ;
330+
331+ seen_any = 0 ;
332+ for (i = 0 ; (match = pathspec [i ]) != NULL ; i ++ ) {
333+ if (!seen [i ]) {
334+ if (!ignore_unmatch ) {
335+ die (_ ("pathspec '%s' did not match any files" ),
336+ match );
343337 }
344- if (!recursive && seen [i ] == MATCHED_RECURSIVELY )
345- die (_ ("not removing '%s' recursively without -r" ),
346- * match ? match : "." );
347338 }
348-
349- if (! seen_any )
350- exit (0 );
339+ else {
340+ seen_any = 1 ;
341+ }
342+ if (!recursive && seen [i ] == MATCHED_RECURSIVELY )
343+ die (_ ("not removing '%s' recursively without -r" ),
344+ * match ? match : "." );
351345 }
346+ if (!seen_any )
347+ exit (0 );
352348
353349 /*
354350 * If not forced, the file, the index and the HEAD (if exists)
0 commit comments