git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 4/4] connected: search promisor objects generically

From
Patrick Steinhardt <ps@pks.im>
Date
Jun 25, 2026, 09:57 UTC
Message-ID
<20260625-pks-connected-generic-promisor-checks-v3-4-7308f3b9dc44@pks.im>
In-Reply-To
<20260625-pks-connected-generic-promisor-checks-v3-0-7308f3b9dc44@pks.im>

When performing connectivity checks we have to figure out whether any of the new objects are promisor objects, as we cannot assume full connectivity if so.

This check is performed by iterating through all packfiles in the repository and searching each of them for the given object. Of course, this mechanism is quite specific to implementation details of the object database, as we assume that it uses packfiles in the first place.

Refactor the logic so that we instead use `odb_for_each_object_ext()` with an object prefix filter and the `ODB_FOR_EACH_OBJECT_PROMISOR_ONLY` flag. This will yield all objects that have the exact object name and that are part of a promisor pack in a generic way.

Add a test to verify that we indeed use the optimization.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 connected.c              | 35 ++++++++++++++++++++++++-----------
 t/t5616-partial-clone.sh | 24 ++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/connected.c b/connected.c
index d2b334173f..929b9bd28d 100644
--- a/connected.c
+++ b/connected.c
@@ -11,6 +11,15 @@
 #include "packfile.h"
 #include "promisor-remote.h"
 
+static int promised_object_cb(const struct object_id *oid UNUSED,
+			      struct object_info *oi UNUSED,
+			      void *payload)
+{
+	bool *found = payload;
+	*found = true;
+	return 1;
+}
+
 /*
  * 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
@@ -30,25 +39,29 @@ static int check_connected_promisor(oid_iterate_fn fn,
 				    void *cb_data,
 				    const struct object_id **oid)
 {
+	struct odb_for_each_object_options opts = {
+		.flags = ODB_FOR_EACH_OBJECT_PROMISOR_ONLY,
+		.prefix_hex_len = the_repository->hash_algo->hexsz,
+	};
+	int err;
+
 	odb_reprepare(the_repository->objects);
 	do {
-		struct packed_git *p;
+		bool found = false;
 
-		repo_for_each_pack(the_repository, p) {
-			if (!p->pack_promisor)
-				continue;
-			if (find_pack_entry_one(*oid, p))
-				goto promisor_pack_found;
-		}
+		opts.prefix = *oid;
+
+		err = odb_for_each_object_ext(the_repository->objects, NULL,
+					      promised_object_cb, &found, &opts);
+		if (err < 0)
+			return err;
 
 		/*
 		 * We have found an object that is not part of a promisor pack,
 		 * and thus we cannot skip the full connectivity check.
 		 */
-		return 0;
-
-promisor_pack_found:
-		;
+		if (!found)
+			return 0;
 	} while ((*oid = fn(cb_data)) != NULL);
 
 	return 1;
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index 1c2805acca..905052072d 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -97,6 +97,30 @@ test_expect_success 'partial fetch inherits filter settings' '
 	test_line_count = 5 observed
 '
 
+test_expect_success 'partial fetch does not spawn rev-list connectivity check' '
+	test_when_finished "rm -rf connectivity-remote connectivity-client" &&
+	git init connectivity-remote &&
+	test_commit -C connectivity-remote one &&
+	git -C connectivity-remote config uploadpack.allowfilter 1 &&
+	git -C connectivity-remote config uploadpack.allowanysha1inwant 1 &&
+
+	git clone --no-checkout --filter=blob:none \
+		"file://$(pwd)/connectivity-remote" connectivity-client &&
+
+	# When doing a partial fetch where all tips are part of a promisor pack
+	# we want to skip the connectivity check, as these objects are allowed
+	# to not be fully connected.
+	test_commit -C connectivity-remote two &&
+	GIT_TRACE2_EVENT="$(pwd)/partial.trace" git -C connectivity-client fetch origin &&
+	test_subcommand_flex ! git rev-list --objects --stdin <partial.trace &&
+
+	# Otherwise, when doing a fetch where any of the tips is not part of a
+	# promisor pack, then we must run the connectivity check.
+	test_commit -C connectivity-remote three &&
+	GIT_TRACE2_EVENT="$(pwd)/full.trace" git -C connectivity-client fetch --no-filter origin &&
+	test_subcommand_flex git rev-list --objects --stdin <full.trace
+'
+
 # force dynamic object fetch using diff.
 # we should only get 1 new blob (for the file in origin/main).
 test_expect_success 'verify diff causes dynamic object fetch' '
-- 
2.55.0.rc1.745.g43192e7977.dirty
Previous: Patrick SteinhardtNext: Junio C Hamano
Message 23 of 25 in “connected: search promisor objects generically”
  1. 0/3 connected: search promisor objects genericallyPatrick Steinhardt, Jun 22, 2026
  2. 1/3 odb/source-packed: extract logic to skip certain packsPatrick Steinhardt, Jun 22, 2026
  3. Junio C HamanoJun 22, 2026
  4. 2/3 odb/source-packed: support flags when iterating an object prefixPatrick Steinhardt, Jun 22, 2026
  5. 3/3 connected: search promisor objects genericallyPatrick Steinhardt, Jun 22, 2026
  6. Junio C HamanoJun 22, 2026
  7. Patrick SteinhardtJun 24, 2026
  8. Christian CouderJun 23, 2026
  9. Patrick SteinhardtJun 24, 2026
  10. 0/4 connected: search promisor objects genericallyPatrick Steinhardt, Jun 24, 2026
  11. 1/4 odb/source-packed: extract logic to skip certain packsPatrick Steinhardt, Jun 24, 2026
  12. 2/4 odb/source-packed: support flags when iterating an object prefixPatrick Steinhardt, Jun 24, 2026
  13. Christian CouderJun 24, 2026
  14. Patrick SteinhardtJun 25, 2026
  15. 3/4 connected: split out promisor-based connectivity checkPatrick Steinhardt, Jun 24, 2026
  16. 4/4 connected: search promisor objects genericallyPatrick Steinhardt, Jun 24, 2026
  17. Junio C HamanoJun 24, 2026
  18. Patrick SteinhardtJun 25, 2026
  19. 0/4 connected: search promisor objects genericallyPatrick Steinhardt, Jun 25, 2026
  20. 1/4 odb/source-packed: extract logic to skip certain packsPatrick Steinhardt, Jun 25, 2026
  21. 2/4 odb/source-packed: support flags when iterating an object prefixPatrick Steinhardt, Jun 25, 2026
  22. 3/4 connected: split out promisor-based connectivity checkPatrick Steinhardt, Jun 25, 2026
  23. 4/4 connected: search promisor objects genericallyPatrick Steinhardt, Jun 25, 2026
  24. Junio C HamanoJun 25, 2026
  25. Christian CouderJun 26, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.