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

[PATCH 4/9] fsck: support referenced promisor objects

From
JHJeff Hostetler <git@jeffhostetler.com>
Date
Nov 2, 2017, 20:20 UTC
Message-ID
<20171102202052.58762-5-git@jeffhostetler.com>
In-Reply-To
<20171102202052.58762-1-git@jeffhostetler.com>
From: Jonathan Tan <jonathantanmy@google.com>

Teach fsck to not treat missing promisor objects indirectly pointed to by refs as an error when extensions.partialcloneremote is set.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
---
 builtin/fsck.c           | 11 +++++++++++
 t/t0410-partial-clone.sh | 23 +++++++++++++++++++++++
 2 files changed, 34 insertions(+)
diff --git a/builtin/fsck.c b/builtin/fsck.c
index ee937bb..4c2a56d 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -149,6 +149,15 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
 	if (obj->flags & REACHABLE)
 		return 0;
 	obj->flags |= REACHABLE;
+
+	if (is_promisor_object(&obj->oid))
+		/*
+		 * Further recursion does not need to be performed on this
+		 * object since it is a promisor object (so it does not need to
+		 * be added to "pending").
+		 */
+		return 0;
+
 	if (!(obj->flags & HAS_OBJ)) {
 		if (parent && !has_object_file(&obj->oid)) {
 			printf("broken link from %7s %s\n",
@@ -208,6 +217,8 @@ static void check_reachable_object(struct object *obj)
 	 * do a full fsck
 	 */
 	if (!(obj->flags & HAS_OBJ)) {
+		if (is_promisor_object(&obj->oid))
+			return;
 		if (has_sha1_pack(obj->oid.hash))
 			return; /* it is in pack - forget about it */
 		printf("missing %s %s\n", printable_type(obj),
diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
index 5a03ead..b1d404e 100755
--- a/t/t0410-partial-clone.sh
+++ b/t/t0410-partial-clone.sh
@@ -102,4 +102,27 @@ test_expect_success 'missing ref object, but promised, passes fsck' '
 	git -C repo fsck
 '
 
+test_expect_success 'missing object, but promised, passes fsck' '
+	rm -rf repo &&
+	test_create_repo repo &&
+	test_commit -C repo 1 &&
+	test_commit -C repo 2 &&
+	test_commit -C repo 3 &&
+	git -C repo tag -a annotated_tag -m "annotated tag" &&
+
+	C=$(git -C repo rev-parse 1) &&
+	T=$(git -C repo rev-parse 2^{tree}) &&
+	B=$(git hash-object repo/3.t) &&
+	AT=$(git -C repo rev-parse annotated_tag) &&
+
+	promise_and_delete "$C" &&
+	promise_and_delete "$T" &&
+	promise_and_delete "$B" &&
+	promise_and_delete "$AT" &&
+
+	git -C repo config core.repositoryformatversion 1 &&
+	git -C repo config extensions.partialcloneremote "arbitrary string" &&
+	git -C repo fsck
+'
+
 test_done
-- 
2.9.3
Previous: Jeff HostetlerNext: Jeff Hostetler
Message 18 of 19 in “WIP Partial clone part 2: fsck and promisors”
  1. 0/9 WIP Partial clone part 2: fsck and promisorsJeff Hostetler, Nov 2, 2017
  2. 1/9 extension.partialclone: introduce partial clone extensionJeff Hostetler, Nov 2, 2017
  3. Jonathan TanNov 2, 2017
  4. Jeff HostetlerNov 3, 2017
  5. Jonathan TanNov 3, 2017
  6. Jeff HostetlerNov 6, 2017
  7. Jonathan TanNov 6, 2017
  8. Jeff HostetlerNov 8, 2017
  9. Jonathan TanNov 8, 2017
  10. Jeff HostetlerNov 8, 2017
  11. Jeff HostetlerNov 16, 2017
  12. 5/9 fsck: support promisor objects as CLI argumentJeff Hostetler, Nov 2, 2017
  13. 8/9 sha1_file: support lazily fetching missing objectsJeff Hostetler, Nov 2, 2017
  14. 3/9 fsck: support refs pointing to promisor objectsJeff Hostetler, Nov 2, 2017
  15. 6/9 index-pack: refactor writing of .keep filesJeff Hostetler, Nov 2, 2017
  16. 7/9 introduce fetch-object: fetch one promisor objectJeff Hostetler, Nov 2, 2017
  17. 9/9 gc: do not repack promisor packfilesJeff Hostetler, Nov 2, 2017
  18. 4/9 fsck: support referenced promisor objectsJeff Hostetler, Nov 2, 2017
  19. 2/9 fsck: introduce partialclone extensionJeff Hostetler, Nov 2, 2017

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.