unpack-trees.c: simplify check_updates() code path when o->update is false
PATCH 1/1 unpack-trees.c: simplify check_updates() code path when o->update is false
check_updates() is heavily branched by o->update, which makes it quite difficult to follow. This patch rips "o->update == 0" code path out and put it on top.
Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>
--- unpack-trees.c | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-)
unpack-trees.c +13 -10
@@ -75,7 +75,15 @@ static int check_updates(struct unpack_trees_options *o)int i;int errs =0 ; -if (o->update && o->verbose_update) { +if (!o->update) { +remove_marked_cache_entries (&o->result); +remove_scheduled_dirs (); +for (i =0 ; i < index->cache_nr; i++) + index->cache[i]->ce_flags &= ~CE_UPDATE ; +return 0 ; + } + +if (o->verbose_update) {for (total = cnt =0 ; cnt < index->cache_nr; cnt++) {struct cache_entry *ce = index->cache[cnt];if (ce->ce_flags & (CE_UPDATE |CE_REMOVE ))
@@ -87,15 +95,13 @@ static int check_updates(struct unpack_trees_options *o) cnt =0 ; } -if (o->update) -git_attr_set_direction (GIT_ATTR_CHECKOUT , &o->result); +git_attr_set_direction (GIT_ATTR_CHECKOUT , &o->result);for (i =0 ; i < index->cache_nr; i++) {struct cache_entry *ce = index->cache[i];if (ce->ce_flags &CE_REMOVE ) {display_progress (progress, ++cnt); -if (o->update) -unlink_entry (ce); +unlink_entry (ce); } }remove_marked_cache_entries (&o->result);
@@ -107,14 +113,11 @@ static int check_updates(struct unpack_trees_options *o)if (ce->ce_flags &CE_UPDATE ) {display_progress (progress, ++cnt); ce->ce_flags &= ~CE_UPDATE ; -if (o->update) { - errs |=checkout_entry (ce, &state,NULL ); - } + errs |=checkout_entry (ce, &state,NULL ); } }stop_progress (&progress); -if (o->update) -git_attr_set_direction (GIT_ATTR_CHECKIN ,NULL ); +git_attr_set_direction (GIT_ATTR_CHECKIN ,NULL );return errs !=0 ; }
Signature · 1 line
1.6.3.GIT