unpack-trees: pass checkout state explicitly to check_updates()
Add a parameter for the struct checkout variable to check_updates() instead of using a static global variable. Passing it explicitly makes object ownership and usage more easily apparent. And we get rid of a static variable; those can be problematic in library-like code. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Sep 13, 2016 at 19:37 UTC
b56aa5b268ee2188c3dee27cc94025f4c647594a
1 file changed
+5
-4
unpack-trees.c
+5
-4
@@ -218,8 +218,8 @@ static void unlink_entry(const struct cache_entry *ce)
218
schedule_dir_for_removal(ce->name, ce_namelen(ce));
219
}
220
221
-static struct checkout state;
222
-static int check_updates(struct unpack_trees_options *o)
221
+static int check_updates(struct unpack_trees_options *o,
222
+ const struct checkout *state)
223
{
224
unsigned cnt = 0, total = 0;
225
struct progress *progress = NULL;
@@ -264,7 +264,7 @@ static int check_updates(struct unpack_trees_options *o)
264
display_progress(progress, ++cnt);
265
ce->ce_flags &= ~CE_UPDATE;
266
if (o->update && !o->dry_run) {
267
- errs |= checkout_entry(ce, &state, NULL);
267
+ errs |= checkout_entry(ce, state, NULL);
268
}
269
}
270
}
@@ -1094,6 +1094,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
1094
int i, ret;
1095
static struct cache_entry *dfc;
1096
struct exclude_list el;
1097
+ struct checkout state;
1098
1099
if (len > MAX_UNPACK_TREES)
1100
die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
@@ -1239,7 +1240,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
1240
}
1241
1242
o->src_index = NULL;
1242
- ret = check_updates(o) ? (-2) : 0;
1243
+ ret = check_updates(o, &state) ? (-2) : 0;
1244
if (o->dst_index) {
1245
if (!ret) {
1246
if (!o->result.cache_tree)