Merge branch 'rs/unpack-trees-reduce-file-scope-global'
authorJunio C Hamano <gitster@pobox.com>
Wed, 21 Sep 2016 22:15:26 +0000 (15:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Sep 2016 22:15:26 +0000 (15:15 -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 88516910cc92538c3553726eb9944ef70e82be2e,74d6dd45604e66e3b139729b5a445ae18abc03cf..3db3f02577a432ddec187873397e63e4c9f5af3e
@@@ -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);
                        }
                }
        }
@@@ -625,7 -625,7 +625,7 @@@ static struct cache_entry *create_ce_en
        ce->ce_mode = create_ce_mode(n->mode);
        ce->ce_flags = create_ce_flags(stage);
        ce->ce_namelen = len;
 -      hashcpy(ce->sha1, n->oid->hash);
 +      oidcpy(&ce->oid, n->oid);
        make_traverse_path(ce->name, info, n);
  
        return ce;
@@@ -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)
@@@ -1287,7 -1288,7 +1288,7 @@@ static int same(const struct cache_entr
        if ((a->ce_flags | b->ce_flags) & CE_CONFLICTED)
                return 0;
        return a->ce_mode == b->ce_mode &&
 -             !hashcmp(a->sha1, b->sha1);
 +             !oidcmp(&a->oid, &b->oid);
  }
  
  
@@@ -1393,7 -1394,7 +1394,7 @@@ static int verify_clean_subdirectory(co
                /* If we are not going to update the submodule, then
                 * we don't care.
                 */
 -              if (!hashcmp(sha1, ce->sha1))
 +              if (!hashcmp(sha1, ce->oid.hash))
                        return 0;
                return verify_clean_submodule(ce, error_type, o);
        }
@@@ -1665,7 -1666,7 +1666,7 @@@ static void show_stage_entry(FILE *o
                fprintf(o, "%s%06o %s %d\t%s\n",
                        label,
                        ce->ce_mode,
 -                      sha1_to_hex(ce->sha1),
 +                      oid_to_hex(&ce->oid),
                        ce_stage(ce),
                        ce->name);
  }