Skip to content

Commit b56aa5b

Browse files
rscharfegitster
authored andcommitted
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>
1 parent 9194226 commit b56aa5b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

unpack-trees.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ static void unlink_entry(const struct cache_entry *ce)
218218
schedule_dir_for_removal(ce->name, ce_namelen(ce));
219219
}
220220

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)
223223
{
224224
unsigned cnt = 0, total = 0;
225225
struct progress *progress = NULL;
@@ -264,7 +264,7 @@ static int check_updates(struct unpack_trees_options *o)
264264
display_progress(progress, ++cnt);
265265
ce->ce_flags &= ~CE_UPDATE;
266266
if (o->update && !o->dry_run) {
267-
errs |= checkout_entry(ce, &state, NULL);
267+
errs |= checkout_entry(ce, state, NULL);
268268
}
269269
}
270270
}
@@ -1094,6 +1094,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
10941094
int i, ret;
10951095
static struct cache_entry *dfc;
10961096
struct exclude_list el;
1097+
struct checkout state;
10971098

10981099
if (len > MAX_UNPACK_TREES)
10991100
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
12391240
}
12401241

12411242
o->src_index = NULL;
1242-
ret = check_updates(o) ? (-2) : 0;
1243+
ret = check_updates(o, &state) ? (-2) : 0;
12431244
if (o->dst_index) {
12441245
if (!ret) {
12451246
if (!o->result.cache_tree)

0 commit comments

Comments
 (0)