clone: do faster object check for partial clones
[gitweb.git] / connected.c
index 91feb7881545f4143f45b9eb3393de65739cfa92..1ab481fed69b33b48bd95c282d2c0faff897123c 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "object-store.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "connected.h"
@@ -49,6 +50,22 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
                strbuf_release(&idx_file);
        }
 
+       if (opt->check_refs_only) {
+               /*
+                * For partial clones, we don't want to have to do a regular
+                * connectivity check because we have to enumerate and exclude
+                * all promisor objects (slow), and then the connectivity check
+                * itself becomes a no-op because in a partial clone every
+                * object is a promisor object. Instead, just make sure we
+                * received the objects pointed to by each wanted ref.
+                */
+               do {
+                       if (!repo_has_object_file(the_repository, &oid))
+                               return 1;
+               } while (!fn(cb_data, &oid));
+               return 0;
+       }
+
        if (opt->shallow_file) {
                argv_array_push(&rev_list.args, "--shallow-file");
                argv_array_push(&rev_list.args, opt->shallow_file);
@@ -58,8 +75,10 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
        argv_array_push(&rev_list.args, "--stdin");
        if (repository_format_partial_clone)
                argv_array_push(&rev_list.args, "--exclude-promisor-objects");
-       argv_array_push(&rev_list.args, "--not");
-       argv_array_push(&rev_list.args, "--all");
+       if (!opt->is_deepening_fetch) {
+               argv_array_push(&rev_list.args, "--not");
+               argv_array_push(&rev_list.args, "--all");
+       }
        argv_array_push(&rev_list.args, "--quiet");
        if (opt->progress)
                argv_array_pushf(&rev_list.args, "--progress=%s",