Merge branch 'jh/partial-clone' into next
authorJunio C Hamano <gitster@pobox.com>
Wed, 28 Mar 2018 19:14:48 +0000 (12:14 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 28 Mar 2018 19:14:48 +0000 (12:14 -0700)
* jh/partial-clone:
unpack-trees: release oid_array after use in check_updates()

1  2 
unpack-trees.c
diff --combined unpack-trees.c
index 31a2cf2d0b5422b6c046da1a5f7600557b75977c,2253c910427c7dcb9f1cf7ed282d37a7dd8d8ae9..79fd97074ec238714634de1c9e6144accdc710f3
@@@ -14,7 -14,6 +14,7 @@@
  #include "dir.h"
  #include "submodule.h"
  #include "submodule-config.h"
 +#include "fsmonitor.h"
  #include "fetch-object.h"
  
  /*
@@@ -195,10 -194,10 +195,10 @@@ static int do_add_entry(struct unpack_t
  static struct cache_entry *dup_entry(const struct cache_entry *ce)
  {
        unsigned int size = ce_size(ce);
 -      struct cache_entry *new = xmalloc(size);
 +      struct cache_entry *new_entry = xmalloc(size);
  
 -      memcpy(new, ce, size);
 -      return new;
 +      memcpy(new_entry, ce, size);
 +      return new_entry;
  }
  
  static void add_entry(struct unpack_trees_options *o,
@@@ -391,6 -390,7 +391,7 @@@ static int check_updates(struct unpack_
                        fetch_objects(repository_format_partial_clone,
                                      &to_fetch);
                fetch_if_missing = fetch_if_missing_store;
+               oid_array_clear(&to_fetch);
        }
        for (i = 0; i < index->cache_nr; i++) {
                struct cache_entry *ce = index->cache[i];
@@@ -431,7 -431,6 +432,7 @@@ static int apply_sparse_checkout(struc
                ce->ce_flags &= ~CE_SKIP_WORKTREE;
        if (was_skip_worktree != ce_skip_worktree(ce)) {
                ce->ce_flags |= CE_UPDATE_IN_BASE;
 +              mark_fsmonitor_invalid(istate, ce);
                istate->cache_changed |= CE_ENTRY_CHANGED;
        }
  
@@@ -1508,8 -1507,8 +1509,8 @@@ static int verify_uptodate_1(const stru
                add_rejected_path(o, error_type, ce->name);
  }
  
 -static int verify_uptodate(const struct cache_entry *ce,
 -                         struct unpack_trees_options *o)
 +int verify_uptodate(const struct cache_entry *ce,
 +                  struct unpack_trees_options *o)
  {
        if (!o->skip_sparse_checkout && (ce->ce_flags & CE_NEW_SKIP_WORKTREE))
                return 0;
@@@ -1528,7 -1527,7 +1529,7 @@@ static void invalidate_ce_path(const st
        if (!ce)
                return;
        cache_tree_invalidate_path(o->src_index, ce->name);
 -      untracked_cache_invalidate_path(o->src_index, ce->name);
 +      untracked_cache_invalidate_path(o->src_index, ce->name, 1);
  }
  
  /*
@@@ -1565,15 -1564,15 +1566,15 @@@ static int verify_clean_subdirectory(co
        int cnt = 0;
  
        if (S_ISGITLINK(ce->ce_mode)) {
 -              unsigned char sha1[20];
 -              int sub_head = resolve_gitlink_ref(ce->name, "HEAD", sha1);
 +              struct object_id oid;
 +              int sub_head = resolve_gitlink_ref(ce->name, "HEAD", &oid);
                /*
                 * If we are not going to update the submodule, then
                 * we don't care.
                 */
 -              if (!sub_head && !hashcmp(sha1, ce->oid.hash))
 +              if (!sub_head && !oidcmp(&oid, &ce->oid))
                        return 0;
 -              return verify_clean_submodule(sub_head ? NULL : sha1_to_hex(sha1),
 +              return verify_clean_submodule(sub_head ? NULL : oid_to_hex(&oid),
                                              ce, error_type, o);
        }
  
@@@ -2161,9 -2160,6 +2162,9 @@@ int oneway_merge(const struct cache_ent
                            ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE))
                                update |= CE_UPDATE;
                }
 +              if (o->update && S_ISGITLINK(old->ce_mode) &&
 +                  should_update_submodules() && !verify_uptodate(old, o))
 +                      update |= CE_UPDATE;
                add_entry(o, old, update, 0);
                return 0;
        }