Merge branch 'jt/cache-tree-allow-missing-object-in-partial-clone'
authorJunio C Hamano <gitster@pobox.com>
Fri, 19 Oct 2018 04:34:08 +0000 (13:34 +0900)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Oct 2018 04:34:08 +0000 (13:34 +0900)
In a partial clone that will lazily be hydrated from the
originating repository, we generally want to avoid "does this
object exist (locally)?" on objects that we deliberately omitted
when we created the clone. The cache-tree codepath (which is used
to write a tree object out of the index) however insisted that the
object exists, even for paths that are outside of the partial
checkout area. The code has been updated to avoid such a check.

* jt/cache-tree-allow-missing-object-in-partial-clone:
cache-tree: skip some blob checks in partial clone

1  2 
cache-tree.c
diff --combined cache-tree.c
index 9c5cf2cc4fdc1f2f4ccc7f352289fe0ec75e8f5d,f210481f9b53d389b1f55c786bc9a8fc34252c97..9d454d24bca62dcdb8c941a64d09b7a53556323a
@@@ -326,6 -326,7 +326,7 @@@ static int update_one(struct cache_tre
                unsigned mode;
                int expected_missing = 0;
                int contains_ita = 0;
+               int ce_missing_ok;
  
                path = ce->name;
                pathlen = ce_namelen(ce);
                        i++;
                }
  
+               ce_missing_ok = mode == S_IFGITLINK || missing_ok ||
+                       (repository_format_partial_clone &&
+                        ce_skip_worktree(ce));
                if (is_null_oid(oid) ||
-                   (mode != S_IFGITLINK && !missing_ok && !has_object_file(oid))) {
+                   (!ce_missing_ok && !has_object_file(oid))) {
                        strbuf_release(&buffer);
                        if (expected_missing)
                                return -1;
@@@ -781,7 -785,7 +785,7 @@@ static void verify_one(struct index_sta
                strbuf_add(&tree_buf, oid->hash, the_hash_algo->rawsz);
        }
        hash_object_file(tree_buf.buf, tree_buf.len, tree_type, &new_oid);
 -      if (oidcmp(&new_oid, &it->oid))
 +      if (!oideq(&new_oid, &it->oid))
                BUG("cache-tree for path %.*s does not match. "
                    "Expected %s got %s", len, path->buf,
                    oid_to_hex(&new_oid), oid_to_hex(&it->oid));