Merge branch 'rs/unpack-trees-reduce-file-scope-global' into maint
authorJunio C Hamano <gitster@pobox.com>
Thu, 29 Sep 2016 23:49:36 +0000 (16:49 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 29 Sep 2016 23:49:36 +0000 (16:49 -0700)
Code cleanup.

* rs/unpack-trees-reduce-file-scope-global:
unpack-trees: pass checkout state explicitly to check_updates()

1  2 
unpack-trees.c
diff --combined unpack-trees.c
index c87a90a08d7d56db2a64a7a42cdd365373557624,74d6dd45604e66e3b139729b5a445ae18abc03cf..2a963f9a7f6e1487fb717c4422c835590ba5de14
@@@ -123,9 -123,9 +123,9 @@@ void setup_unpack_trees_porcelain(struc
        msgs[ERROR_SPARSE_NOT_UPTODATE_FILE] =
                _("Cannot update sparse checkout: the following entries are not up-to-date:\n%s");
        msgs[ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN] =
 -              _("The following Working tree files would be overwritten by sparse checkout update:\n%s");
 +              _("The following working tree files would be overwritten by sparse checkout update:\n%s");
        msgs[ERROR_WOULD_LOSE_ORPHANED_REMOVED] =
 -              _("The following Working tree files would be removed by sparse checkout update:\n%s");
 +              _("The following working tree files would be removed by sparse checkout update:\n%s");
  
        opts->show_all_errors = 1;
        /* rejected paths may not have a static buffer */
@@@ -218,8 -218,8 +218,8 @@@ static void unlink_entry(const struct c
        schedule_dir_for_removal(ce->name, ce_namelen(ce));
  }
  
- static struct checkout state;
static int check_updates(struct unpack_trees_options *o)
+ static int check_updates(struct unpack_trees_options *o,
                       const struct checkout *state)
  {
        unsigned cnt = 0, total = 0;
        struct progress *progress = NULL;
                        display_progress(progress, ++cnt);
                        ce->ce_flags &= ~CE_UPDATE;
                        if (o->update && !o->dry_run) {
-                               errs |= checkout_entry(ce, &state, NULL);
+                               errs |= checkout_entry(ce, state, NULL);
                        }
                }
        }
@@@ -1094,6 -1094,7 +1094,7 @@@ int unpack_trees(unsigned len, struct t
        int i, ret;
        static struct cache_entry *dfc;
        struct exclude_list el;
+       struct checkout state;
  
        if (len > MAX_UNPACK_TREES)
                die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
        }
  
        o->src_index = NULL;
-       ret = check_updates(o) ? (-2) : 0;
+       ret = check_updates(o, &state) ? (-2) : 0;
        if (o->dst_index) {
                if (!ret) {
                        if (!o->result.cache_tree)