@@ -277,8 +277,8 @@ static struct option builtin_rm_options[] = {
277
277
278
278
int cmd_rm (int argc , const char * * argv , const char * prefix )
279
279
{
280
- int i , newfd ;
281
- const char * * pathspec ;
280
+ int i , newfd , seen_any ;
281
+ const char * * pathspec , * match ;
282
282
char * seen ;
283
283
284
284
git_config (git_default_config , NULL );
@@ -314,7 +314,6 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
314
314
pathspec = get_pathspec (prefix , argv );
315
315
refresh_index (& the_index , REFRESH_QUIET , pathspec , NULL , NULL );
316
316
317
- seen = NULL ;
318
317
for (i = 0 ; pathspec [i ] ; i ++ )
319
318
/* nothing */ ;
320
319
seen = xcalloc (i , 1 );
@@ -328,27 +327,24 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
328
327
list .entry [list .nr ++ ].is_submodule = S_ISGITLINK (ce -> ce_mode );
329
328
}
330
329
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 );
343
337
}
344
- if (!recursive && seen [i ] == MATCHED_RECURSIVELY )
345
- die (_ ("not removing '%s' recursively without -r" ),
346
- * match ? match : "." );
347
338
}
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 : "." );
351
345
}
346
+ if (!seen_any )
347
+ exit (0 );
352
348
353
349
/*
354
350
* If not forced, the file, the index and the HEAD (if exists)
0 commit comments