Merge branch 'sb/unpack-trees-cleanup'
Code cleanup. * sb/unpack-trees-cleanup: unpack-trees: factor progress setup out of check_updates unpack-trees: remove unneeded continue unpack-trees: move checkout state into check_updatesmaint
commit
0c0e0fd0ca
|
@ -218,29 +218,42 @@ static void unlink_entry(const struct cache_entry *ce)
|
||||||
schedule_dir_for_removal(ce->name, ce_namelen(ce));
|
schedule_dir_for_removal(ce->name, ce_namelen(ce));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_updates(struct unpack_trees_options *o,
|
static struct progress *get_progress(struct unpack_trees_options *o)
|
||||||
const struct checkout *state)
|
|
||||||
{
|
{
|
||||||
unsigned cnt = 0, total = 0;
|
unsigned cnt = 0, total = 0;
|
||||||
struct progress *progress = NULL;
|
|
||||||
struct index_state *index = &o->result;
|
struct index_state *index = &o->result;
|
||||||
int i;
|
|
||||||
int errs = 0;
|
|
||||||
|
|
||||||
if (o->update && o->verbose_update) {
|
if (!o->update || !o->verbose_update)
|
||||||
for (total = cnt = 0; cnt < index->cache_nr; cnt++) {
|
return NULL;
|
||||||
const struct cache_entry *ce = index->cache[cnt];
|
|
||||||
if (ce->ce_flags & (CE_UPDATE | CE_WT_REMOVE))
|
|
||||||
total++;
|
|
||||||
}
|
|
||||||
|
|
||||||
progress = start_progress_delay(_("Checking out files"),
|
for (; cnt < index->cache_nr; cnt++) {
|
||||||
total, 50, 1);
|
const struct cache_entry *ce = index->cache[cnt];
|
||||||
cnt = 0;
|
if (ce->ce_flags & (CE_UPDATE | CE_WT_REMOVE))
|
||||||
|
total++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return start_progress_delay(_("Checking out files"),
|
||||||
|
total, 50, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int check_updates(struct unpack_trees_options *o)
|
||||||
|
{
|
||||||
|
unsigned cnt = 0;
|
||||||
|
int errs = 0;
|
||||||
|
struct progress *progress = NULL;
|
||||||
|
struct index_state *index = &o->result;
|
||||||
|
struct checkout state = CHECKOUT_INIT;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
state.force = 1;
|
||||||
|
state.quiet = 1;
|
||||||
|
state.refresh_cache = 1;
|
||||||
|
state.istate = index;
|
||||||
|
|
||||||
|
progress = get_progress(o);
|
||||||
|
|
||||||
if (o->update)
|
if (o->update)
|
||||||
git_attr_set_direction(GIT_ATTR_CHECKOUT, &o->result);
|
git_attr_set_direction(GIT_ATTR_CHECKOUT, index);
|
||||||
for (i = 0; i < index->cache_nr; i++) {
|
for (i = 0; i < index->cache_nr; i++) {
|
||||||
const struct cache_entry *ce = index->cache[i];
|
const struct cache_entry *ce = index->cache[i];
|
||||||
|
|
||||||
|
@ -248,10 +261,9 @@ static int check_updates(struct unpack_trees_options *o,
|
||||||
display_progress(progress, ++cnt);
|
display_progress(progress, ++cnt);
|
||||||
if (o->update && !o->dry_run)
|
if (o->update && !o->dry_run)
|
||||||
unlink_entry(ce);
|
unlink_entry(ce);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
remove_marked_cache_entries(&o->result);
|
remove_marked_cache_entries(index);
|
||||||
remove_scheduled_dirs();
|
remove_scheduled_dirs();
|
||||||
|
|
||||||
for (i = 0; i < index->cache_nr; i++) {
|
for (i = 0; i < index->cache_nr; i++) {
|
||||||
|
@ -264,7 +276,7 @@ static int check_updates(struct unpack_trees_options *o,
|
||||||
display_progress(progress, ++cnt);
|
display_progress(progress, ++cnt);
|
||||||
ce->ce_flags &= ~CE_UPDATE;
|
ce->ce_flags &= ~CE_UPDATE;
|
||||||
if (o->update && !o->dry_run) {
|
if (o->update && !o->dry_run) {
|
||||||
errs |= checkout_entry(ce, state, NULL);
|
errs |= checkout_entry(ce, &state, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1094,14 +1106,9 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
||||||
int i, ret;
|
int i, ret;
|
||||||
static struct cache_entry *dfc;
|
static struct cache_entry *dfc;
|
||||||
struct exclude_list el;
|
struct exclude_list el;
|
||||||
struct checkout state = CHECKOUT_INIT;
|
|
||||||
|
|
||||||
if (len > MAX_UNPACK_TREES)
|
if (len > MAX_UNPACK_TREES)
|
||||||
die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
|
die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
|
||||||
state.force = 1;
|
|
||||||
state.quiet = 1;
|
|
||||||
state.refresh_cache = 1;
|
|
||||||
state.istate = &o->result;
|
|
||||||
|
|
||||||
memset(&el, 0, sizeof(el));
|
memset(&el, 0, sizeof(el));
|
||||||
if (!core_apply_sparse_checkout || !o->update)
|
if (!core_apply_sparse_checkout || !o->update)
|
||||||
|
@ -1238,7 +1245,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
||||||
}
|
}
|
||||||
|
|
||||||
o->src_index = NULL;
|
o->src_index = NULL;
|
||||||
ret = check_updates(o, &state) ? (-2) : 0;
|
ret = check_updates(o) ? (-2) : 0;
|
||||||
if (o->dst_index) {
|
if (o->dst_index) {
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
if (!o->result.cache_tree)
|
if (!o->result.cache_tree)
|
||||||
|
|
Loading…
Reference in New Issue