@@ -372,34 +372,39 @@ static int check_updates(struct unpack_trees_options *o)
372
372
state .refresh_cache = 1 ;
373
373
state .istate = index ;
374
374
375
+ if (!o -> update || o -> dry_run ) {
376
+ remove_marked_cache_entries (index , 0 );
377
+ trace_performance_leave ("check_updates" );
378
+ return 0 ;
379
+ }
380
+
375
381
if (o -> clone )
376
382
setup_collided_checkout_detection (& state , index );
377
383
378
384
progress = get_progress (o );
379
385
380
- if (o -> update )
381
- git_attr_set_direction (GIT_ATTR_CHECKOUT );
386
+ git_attr_set_direction (GIT_ATTR_CHECKOUT );
382
387
383
- if (should_update_submodules () && o -> update && ! o -> dry_run )
388
+ if (should_update_submodules ())
384
389
load_gitmodules_file (index , NULL );
385
390
386
391
for (i = 0 ; i < index -> cache_nr ; i ++ ) {
387
392
const struct cache_entry * ce = index -> cache [i ];
388
393
389
394
if (ce -> ce_flags & CE_WT_REMOVE ) {
390
395
display_progress (progress , ++ cnt );
391
- if (o -> update && !o -> dry_run )
392
- unlink_entry (ce );
396
+ unlink_entry (ce );
393
397
}
394
398
}
399
+
395
400
remove_marked_cache_entries (index , 0 );
396
401
remove_scheduled_dirs ();
397
402
398
- if (should_update_submodules () && o -> update && ! o -> dry_run )
403
+ if (should_update_submodules ())
399
404
load_gitmodules_file (index , & state );
400
405
401
406
enable_delayed_checkout (& state );
402
- if (has_promisor_remote () && o -> update && ! o -> dry_run ) {
407
+ if (has_promisor_remote ()) {
403
408
/*
404
409
* Prefetch the objects that are to be checked out in the loop
405
410
* below.
@@ -431,15 +436,12 @@ static int check_updates(struct unpack_trees_options *o)
431
436
ce -> name );
432
437
display_progress (progress , ++ cnt );
433
438
ce -> ce_flags &= ~CE_UPDATE ;
434
- if (o -> update && !o -> dry_run ) {
435
- errs |= checkout_entry (ce , & state , NULL , NULL );
436
- }
439
+ errs |= checkout_entry (ce , & state , NULL , NULL );
437
440
}
438
441
}
439
442
stop_progress (& progress );
440
443
errs |= finish_delayed_checkout (& state , NULL );
441
- if (o -> update )
442
- git_attr_set_direction (GIT_ATTR_CHECKIN );
444
+ git_attr_set_direction (GIT_ATTR_CHECKIN );
443
445
444
446
if (o -> clone )
445
447
report_collided_checkout (index );
0 commit comments