]> git.ipfire.org Git - thirdparty/git.git/blobdiff - connected.c
t5411: add basic test cases for proc-receive hook
[thirdparty/git.git] / connected.c
index c337f5f7f4dd0797a8dd3c4e54fb77fd1b4f6df4..3135b71e1961ae421855ad4b05887c795c437490 100644 (file)
@@ -52,23 +52,41 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
                strbuf_release(&idx_file);
        }
 
-       if (opt->check_refs_only) {
+       if (has_promisor_remote()) {
                /*
                 * 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.
+                * received, in a promisor packfile, the objects pointed to by
+                * each wanted ref.
+                *
+                * Before checking for promisor packs, be sure we have the
+                * latest pack-files loaded into memory.
                 */
+               reprepare_packed_git(the_repository);
                do {
-                       if (!repo_has_object_file_with_flags(the_repository, &oid,
-                                                            OBJECT_INFO_SKIP_FETCH_OBJECT))
-                               return 1;
+                       struct packed_git *p;
+
+                       for (p = get_all_packs(the_repository); p; p = p->next) {
+                               if (!p->pack_promisor)
+                                       continue;
+                               if (find_pack_entry_one(oid.hash, p))
+                                       goto promisor_pack_found;
+                       }
+                       /*
+                        * Fallback to rev-list with oid and the rest of the
+                        * object IDs provided by fn.
+                        */
+                       goto no_promisor_pack_found;
+promisor_pack_found:
+                       ;
                } while (!fn(cb_data, &oid));
                return 0;
        }
 
+no_promisor_pack_found:
        if (opt->shallow_file) {
                argv_array_push(&rev_list.args, "--shallow-file");
                argv_array_push(&rev_list.args, opt->shallow_file);