* [PATCH] pack-objects: handle missing promisor objects
@ 2026-11-25 19:40 Alessio Attilio via GitGitGadget
2026-11-25 19:49 ` [PATCH v2] " Alessio Attilio via GitGitGadget
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Alessio Attilio via GitGitGadget @ 2026-11-25 19:40 UTC (permalink / raw)
To: git; +Cc: Alessio Attilio, Alessio Attilio
From: Alessio Attilio <attilio.alessio@protonmail.com>
Objects missing from a partial clone are expected to be absent.
When checking whether an object is in a promisor pack, do not BUG()
if its object info cannot be read. Such an object cannot be included
in the pack, so skip it.
Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
---
pack-objects: handle missing promisor objects
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2333%2Fkairosci%2Fattilio%2Fpack-objects-missing-promisor-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2333/kairosci/attilio/pack-objects-missing-promisor-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2333
builtin/pack-objects.c | 2 +-
t/t0410-partial-clone.sh | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 65c2ad9a86..5228d7f90d 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -5092,7 +5092,7 @@ static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)
};
if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))
- BUG("should_include_obj should only be called on existing objects");
+ return 0;
return source_info.source->type != ODB_SOURCE_PACKED || !source_info.u.packed.pack->pack_promisor;
}
diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
index 788e9a1631..a858aa0a85 100755
--- a/t/t0410-partial-clone.sh
+++ b/t/t0410-partial-clone.sh
@@ -32,6 +32,26 @@ promise_and_delete () {
delete_object repo "$HASH"
}
+test_expect_success 'fetch --unshallow with tree filter when remote has advanced' '
+ rm -rf server server.bare client &&
+ test_create_repo server &&
+ test_commit -C server c1 &&
+ test_commit -C server c2 &&
+ test_commit -C server c3 &&
+ test_commit -C server c4 &&
+ git clone --bare server server.bare &&
+ git -C server.bare config uploadpack.allowfilter true &&
+ git -C server.bare config uploadpack.allowanysha1inwant true &&
+ git init client &&
+ git -C client remote add origin "file://$(pwd)/server.bare" &&
+ tip=$(git -C server rev-parse HEAD~1) &&
+ git -C client fetch --no-tags --depth=1 origin "+$tip:refs/remotes/origin/master" &&
+ git -C client checkout -b master refs/remotes/origin/master &&
+ git -C client fetch --no-tags --filter=tree:0 --unshallow origin \
+ +refs/heads/master:refs/remotes/origin/master &&
+ rm -rf server server.bare client
+'
+
test_expect_success 'extensions.partialclone without filter' '
test_create_repo server &&
git clone --filter="blob:none" "file://$(pwd)/server" client &&
base-commit: 1630431f326e15fcde608827b5ff38422528eb59
--
gitgitgadget
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2] pack-objects: handle missing promisor objects
2026-11-25 19:40 [PATCH] pack-objects: handle missing promisor objects Alessio Attilio via GitGitGadget
@ 2026-11-25 19:49 ` Alessio Attilio via GitGitGadget
2026-11-25 22:47 ` Junio C Hamano
2026-11-25 23:11 ` [PATCH v3] " Alessio Attilio via GitGitGadget
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Alessio Attilio via GitGitGadget @ 2026-11-25 19:49 UTC (permalink / raw)
To: git; +Cc: Alessio Attilio, Alessio Attilio
From: Alessio Attilio <attilio.alessio@protonmail.com>
Objects missing from a partial clone are expected to be absent.
When checking whether an object is in a promisor pack, do not BUG()
if its object info cannot be read. Such an object cannot be included
in the pack, so skip it.
Pass OBJECT_INFO_SKIP_FETCH_OBJECT explicitly so the lookup does not
trigger a lazy fetch.
Test filtered --unshallow and --deepen fetches, as well as a subsequent
fetch that repacks links to promisor commits with missing trees.
Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
---
pack-objects: handle missing promisor objects
Changes since v1:
* Pass OBJECT_INFO_SKIP_FETCH_OBJECT explicitly to avoid lazy fetching
during the lookup.
* Cover both filtered --unshallow and --deepen fetches, and a later
fetch after unshallowing a filtered clone.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2333%2Fkairosci%2Fattilio%2Fpack-objects-missing-promisor-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2333/kairosci/attilio/pack-objects-missing-promisor-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/2333
Range-diff vs v1:
1: 16a9cac809 ! 1: a7e378ca3d pack-objects: handle missing promisor objects
@@ Commit message
if its object info cannot be read. Such an object cannot be included
in the pack, so skip it.
+ Pass OBJECT_INFO_SKIP_FETCH_OBJECT explicitly so the lookup does not
+ trigger a lazy fetch.
+
+ Test filtered --unshallow and --deepen fetches, as well as a subsequent
+ fetch that repacks links to promisor commits with missing trees.
+
Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
## builtin/pack-objects.c ##
@@ builtin/pack-objects.c: static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)
+ .source_infop = &source_info,
};
- if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))
+- if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))
- BUG("should_include_obj should only be called on existing objects");
++ if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info,
++ OBJECT_INFO_SKIP_FETCH_OBJECT)) {
++ /* Missing; assume it is a promisor object. */
+ return 0;
++ }
return source_info.source->type != ODB_SOURCE_PACKED || !source_info.u.packed.pack->pack_promisor;
}
- ## t/t0410-partial-clone.sh ##
-@@ t/t0410-partial-clone.sh: promise_and_delete () {
- delete_object repo "$HASH"
- }
+ ## t/t5616-partial-clone.sh ##
+@@ t/t5616-partial-clone.sh: test_expect_success 'after fetching descendants of non-promisor commits, gc work
+ git -C partial gc --prune=now
+ '
-+test_expect_success 'fetch --unshallow with tree filter when remote has advanced' '
-+ rm -rf server server.bare client &&
-+ test_create_repo server &&
-+ test_commit -C server c1 &&
-+ test_commit -C server c2 &&
-+ test_commit -C server c3 &&
-+ test_commit -C server c4 &&
-+ git clone --bare server server.bare &&
-+ git -C server.bare config uploadpack.allowfilter true &&
-+ git -C server.bare config uploadpack.allowanysha1inwant true &&
-+ git init client &&
-+ git -C client remote add origin "file://$(pwd)/server.bare" &&
-+ tip=$(git -C server rev-parse HEAD~1) &&
-+ git -C client fetch --no-tags --depth=1 origin "+$tip:refs/remotes/origin/master" &&
-+ git -C client checkout -b master refs/remotes/origin/master &&
-+ git -C client fetch --no-tags --filter=tree:0 --unshallow origin \
-+ +refs/heads/master:refs/remotes/origin/master &&
-+ rm -rf server server.bare client
++for opt in --unshallow --deepen=1
++do
++ test_expect_success "filtered fetch $opt of a moved ref repacks local links" '
++ test_when_finished "rm -rf source target" &&
++
++ git init source &&
++ test_commit_bulk -C source 4 &&
++ git -C source config uploadpack.allowFilter true &&
++ git -C source config uploadpack.allowAnySHA1InWant true &&
++ COMMIT=$(git -C source rev-parse main~1) &&
++
++ git init target &&
++ git -C target remote add origin "file://$(pwd)/source" &&
++ git -C target fetch --no-tags --depth=1 origin "+$COMMIT:refs/remotes/origin/main" &&
++
++ # The fetched pack has the new tip whose parent is the local shallow
++ # tip, so index-pack repacks it into a promisor pack. That process
++ # inherits the shallow file and walks into promisor commits whose
++ # trees do not exist.
++ git -C target fetch --no-tags --filter=tree:0 "$opt" origin \
++ +refs/heads/main:refs/remotes/origin/main &&
++ git -C target rev-parse --verify refs/remotes/origin/main >actual &&
++ git -C source rev-parse --verify refs/heads/main >expect &&
++ test_cmp expect actual &&
++ git -C target fsck
++ '
++done
++
++test_expect_success 'repacking local links tolerates missing trees of promisor commits' '
++ test_when_finished "rm -rf source target" &&
++
++ git init source &&
++ test_commit_bulk -C source 4 &&
++ git -C source config uploadpack.allowFilter true &&
++ git -C source config uploadpack.allowAnySHA1InWant true &&
++ COMMIT=$(git -C source rev-parse main~1) &&
++
++ # Fetch a single commit as a non-promisor object, then unshallow it
++ # with a filter that omits trees. The commits below the former
++ # shallow boundary are now promisor objects whose trees are missing.
++ git init target &&
++ git -C target remote add origin "file://$(pwd)/source" &&
++ git -C target fetch --no-tags --depth=1 origin "+$COMMIT:refs/remotes/origin/main" &&
++ git -C target fetch --no-tags --filter=tree:0 --unshallow origin \
++ "+$COMMIT:refs/remotes/origin/main" &&
++ test_path_is_missing target/.git/shallow &&
++
++ # Fetching a descendant of the local non-promisor commit causes
++ # index-pack to repack that commit into a promisor pack. The revision
++ # walk must not die when it reaches the missing trees of promisor commits.
++ git -C target fetch --no-tags --filter=tree:0 origin \
++ +refs/heads/main:refs/remotes/origin/main &&
++ git -C target rev-parse --verify refs/remotes/origin/main &&
++ git -C target fsck
+'
+
- test_expect_success 'extensions.partialclone without filter' '
- test_create_repo server &&
- git clone --filter="blob:none" "file://$(pwd)/server" client &&
+
+ . "$TEST_DIRECTORY"/lib-httpd.sh
+ start_httpd
builtin/pack-objects.c | 7 +++--
t/t5616-partial-clone.sh | 56 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 65c2ad9a86..0b40b23b33 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -5091,8 +5091,11 @@ static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)
.source_infop = &source_info,
};
- if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))
- BUG("should_include_obj should only be called on existing objects");
+ if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info,
+ OBJECT_INFO_SKIP_FETCH_OBJECT)) {
+ /* Missing; assume it is a promisor object. */
+ return 0;
+ }
return source_info.source->type != ODB_SOURCE_PACKED || !source_info.u.packed.pack->pack_promisor;
}
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index 7cc6f58a31..bee6261411 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -747,6 +747,62 @@ test_expect_success 'after fetching descendants of non-promisor commits, gc work
git -C partial gc --prune=now
'
+for opt in --unshallow --deepen=1
+do
+ test_expect_success "filtered fetch $opt of a moved ref repacks local links" '
+ test_when_finished "rm -rf source target" &&
+
+ git init source &&
+ test_commit_bulk -C source 4 &&
+ git -C source config uploadpack.allowFilter true &&
+ git -C source config uploadpack.allowAnySHA1InWant true &&
+ COMMIT=$(git -C source rev-parse main~1) &&
+
+ git init target &&
+ git -C target remote add origin "file://$(pwd)/source" &&
+ git -C target fetch --no-tags --depth=1 origin "+$COMMIT:refs/remotes/origin/main" &&
+
+ # The fetched pack has the new tip whose parent is the local shallow
+ # tip, so index-pack repacks it into a promisor pack. That process
+ # inherits the shallow file and walks into promisor commits whose
+ # trees do not exist.
+ git -C target fetch --no-tags --filter=tree:0 "$opt" origin \
+ +refs/heads/main:refs/remotes/origin/main &&
+ git -C target rev-parse --verify refs/remotes/origin/main >actual &&
+ git -C source rev-parse --verify refs/heads/main >expect &&
+ test_cmp expect actual &&
+ git -C target fsck
+ '
+done
+
+test_expect_success 'repacking local links tolerates missing trees of promisor commits' '
+ test_when_finished "rm -rf source target" &&
+
+ git init source &&
+ test_commit_bulk -C source 4 &&
+ git -C source config uploadpack.allowFilter true &&
+ git -C source config uploadpack.allowAnySHA1InWant true &&
+ COMMIT=$(git -C source rev-parse main~1) &&
+
+ # Fetch a single commit as a non-promisor object, then unshallow it
+ # with a filter that omits trees. The commits below the former
+ # shallow boundary are now promisor objects whose trees are missing.
+ git init target &&
+ git -C target remote add origin "file://$(pwd)/source" &&
+ git -C target fetch --no-tags --depth=1 origin "+$COMMIT:refs/remotes/origin/main" &&
+ git -C target fetch --no-tags --filter=tree:0 --unshallow origin \
+ "+$COMMIT:refs/remotes/origin/main" &&
+ test_path_is_missing target/.git/shallow &&
+
+ # Fetching a descendant of the local non-promisor commit causes
+ # index-pack to repack that commit into a promisor pack. The revision
+ # walk must not die when it reaches the missing trees of promisor commits.
+ git -C target fetch --no-tags --filter=tree:0 origin \
+ +refs/heads/main:refs/remotes/origin/main &&
+ git -C target rev-parse --verify refs/remotes/origin/main &&
+ git -C target fsck
+'
+
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd
base-commit: 1630431f326e15fcde608827b5ff38422528eb59
--
gitgitgadget
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] pack-objects: handle missing promisor objects
2026-11-25 19:49 ` [PATCH v2] " Alessio Attilio via GitGitGadget
@ 2026-11-25 22:47 ` Junio C Hamano
0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2026-11-25 22:47 UTC (permalink / raw)
To: Alessio Attilio via GitGitGadget; +Cc: git, Alessio Attilio
"Alessio Attilio via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Alessio Attilio <attilio.alessio@protonmail.com>
>
> Objects missing from a partial clone are expected to be absent.
> When checking whether an object is in a promisor pack, do not BUG()
> if its object info cannot be read. Such an object cannot be included
> in the pack, so skip it.
>
> Pass OBJECT_INFO_SKIP_FETCH_OBJECT explicitly so the lookup does not
> trigger a lazy fetch.
>
> Test filtered --unshallow and --deepen fetches, as well as a subsequent
> fetch that repacks links to promisor commits with missing trees.
What is missing from the above is when this loose assumption is
activated and why it is safe to "assume it is a promisor object" without
actually validating. To help that, I would imagine that starting the
description by stepping back further and describe what the end user
would does to trigger the code path and what the effects visible to the
end user is that comes from the affected code paths. Such a descriptoin
may start like this, perhaps (I do not claim what you are trying to fix,
so it may be way off---take it as a way to explain why a good commit log
message is important by demonstrating what kind of misunderstanding can
result if the message is not written clearly ;-):
If you try "git repack" in a partial clone, it may try to fetch
objects from the promisor remote when it tries see if they are
not packed (and needs packing), and ...
> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
> index 65c2ad9a86..0b40b23b33 100644
> --- a/builtin/pack-objects.c
> +++ b/builtin/pack-objects.c
> @@ -5091,8 +5091,11 @@ static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)
> .source_infop = &source_info,
> };
>
> - if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))
> - BUG("should_include_obj should only be called on existing objects");
> + if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info,
> + OBJECT_INFO_SKIP_FETCH_OBJECT)) {
> + /* Missing; assume it is a promisor object. */
> + return 0;
> + }
> return source_info.source->type != ODB_SOURCE_PACKED || !source_info.u.packed.pack->pack_promisor;
> }
This function is called only when pack-objects is run with the
(undocumented) "--exclude-promisor-objects-best-effort" option that was
introduced by c08589efdc (index-pack: repack local links into promisor
packs, 2024-11-01), and it is given only when index-pack is running with
the "--promisor" option. In a repository that is not a lazy clone, such
a loose assumption will not get in the picture, which may be what makes
this change less risky.
It is also something worth documenting in the commit log message.
Whenever you write "assume X" in an in-code comment, you should be
careful to say why making such an assumption is safe, and what the
implications are when the assumption turns out to be incorrect.
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3] pack-objects: handle missing promisor objects
2026-11-25 19:40 [PATCH] pack-objects: handle missing promisor objects Alessio Attilio via GitGitGadget
2026-11-25 19:49 ` [PATCH v2] " Alessio Attilio via GitGitGadget
@ 2026-11-25 23:11 ` Alessio Attilio via GitGitGadget
2026-11-26 1:10 ` Junio C Hamano
2026-11-25 23:22 ` [PATCH v4] " Alessio Attilio via GitGitGadget
2026-11-25 23:42 ` [PATCH v5] " Alessio Attilio via GitGitGadget
3 siblings, 1 reply; 8+ messages in thread
From: Alessio Attilio via GitGitGadget @ 2026-11-25 23:11 UTC (permalink / raw)
To: git; +Cc: Alessio Attilio, Alessio Attilio
From: Alessio Attilio <attilio.alessio@protonmail.com>
Objects missing from a partial clone are expected to be absent.
When checking whether an object is in a promisor pack, do not BUG()
if its object info cannot be read. Such an object cannot be included
in the pack, so skip it.
Pass OBJECT_INFO_SKIP_FETCH_OBJECT explicitly so the lookup does not
trigger a lazy fetch.
Test filtered --unshallow and --deepen fetches, as well as a subsequent
fetch that repacks links to promisor commits with missing trees.
Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
---
pack-objects: handle missing promisor objects
Changes since v1:
* Pass OBJECT_INFO_SKIP_FETCH_OBJECT explicitly to avoid lazy fetching
during the lookup.
* Cover filtered --unshallow and --deepen fetches, and a later fetch
after unshallowing a filtered clone.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2333%2Fkairosci%2Fattilio%2Fpack-objects-missing-promisor-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2333/kairosci/attilio/pack-objects-missing-promisor-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/2333
Range-diff vs v2:
1: a7e378ca3d ! 1: cbe2fc475c pack-objects: handle missing promisor objects
@@ builtin/pack-objects.c: static int is_not_in_promisor_pack_obj(struct object *ob
## t/t5616-partial-clone.sh ##
-@@ t/t5616-partial-clone.sh: test_expect_success 'after fetching descendants of non-promisor commits, gc work
- git -C partial gc --prune=now
+@@ t/t5616-partial-clone.sh: test_expect_success 'merge does not lazy-fetch locally written objects' '
+ done &&
+ test_cmp server/only-in-C client/only-in-C
'
-
+for opt in --unshallow --deepen=1
+do
+ test_expect_success "filtered fetch $opt of a moved ref repacks local links" '
@@ t/t5616-partial-clone.sh: test_expect_success 'after fetching descendants of non
+ git -C target rev-parse --verify refs/remotes/origin/main &&
+ git -C target fsck
+'
-+
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd
builtin/pack-objects.c | 7 +++--
t/t5616-partial-clone.sh | 55 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 87c3102e62..371f16c59b 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -5135,8 +5135,11 @@ static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)
.source_infop = &source_info,
};
- if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))
- BUG("should_include_obj should only be called on existing objects");
+ if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info,
+ OBJECT_INFO_SKIP_FETCH_OBJECT)) {
+ /* Missing; assume it is a promisor object. */
+ return 0;
+ }
return source_info.source->type != ODB_SOURCE_PACKED || !source_info.u.packed.pack->pack_promisor;
}
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index 9636652362..44ce9a1ee8 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -790,6 +790,61 @@ test_expect_success 'merge does not lazy-fetch locally written objects' '
done &&
test_cmp server/only-in-C client/only-in-C
'
+for opt in --unshallow --deepen=1
+do
+ test_expect_success "filtered fetch $opt of a moved ref repacks local links" '
+ test_when_finished "rm -rf source target" &&
+
+ git init source &&
+ test_commit_bulk -C source 4 &&
+ git -C source config uploadpack.allowFilter true &&
+ git -C source config uploadpack.allowAnySHA1InWant true &&
+ COMMIT=$(git -C source rev-parse main~1) &&
+
+ git init target &&
+ git -C target remote add origin "file://$(pwd)/source" &&
+ git -C target fetch --no-tags --depth=1 origin "+$COMMIT:refs/remotes/origin/main" &&
+
+ # The fetched pack has the new tip whose parent is the local shallow
+ # tip, so index-pack repacks it into a promisor pack. That process
+ # inherits the shallow file and walks into promisor commits whose
+ # trees do not exist.
+ git -C target fetch --no-tags --filter=tree:0 "$opt" origin \
+ +refs/heads/main:refs/remotes/origin/main &&
+ git -C target rev-parse --verify refs/remotes/origin/main >actual &&
+ git -C source rev-parse --verify refs/heads/main >expect &&
+ test_cmp expect actual &&
+ git -C target fsck
+ '
+done
+
+test_expect_success 'repacking local links tolerates missing trees of promisor commits' '
+ test_when_finished "rm -rf source target" &&
+
+ git init source &&
+ test_commit_bulk -C source 4 &&
+ git -C source config uploadpack.allowFilter true &&
+ git -C source config uploadpack.allowAnySHA1InWant true &&
+ COMMIT=$(git -C source rev-parse main~1) &&
+
+ # Fetch a single commit as a non-promisor object, then unshallow it
+ # with a filter that omits trees. The commits below the former
+ # shallow boundary are now promisor objects whose trees are missing.
+ git init target &&
+ git -C target remote add origin "file://$(pwd)/source" &&
+ git -C target fetch --no-tags --depth=1 origin "+$COMMIT:refs/remotes/origin/main" &&
+ git -C target fetch --no-tags --filter=tree:0 --unshallow origin \
+ "+$COMMIT:refs/remotes/origin/main" &&
+ test_path_is_missing target/.git/shallow &&
+
+ # Fetching a descendant of the local non-promisor commit causes
+ # index-pack to repack that commit into a promisor pack. The revision
+ # walk must not die when it reaches the missing trees of promisor commits.
+ git -C target fetch --no-tags --filter=tree:0 origin \
+ +refs/heads/main:refs/remotes/origin/main &&
+ git -C target rev-parse --verify refs/remotes/origin/main &&
+ git -C target fsck
+'
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd
base-commit: acba8bf9753134d9bde89f94369f775838a8c5fe
--
gitgitgadget
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4] pack-objects: handle missing promisor objects
2026-11-25 19:40 [PATCH] pack-objects: handle missing promisor objects Alessio Attilio via GitGitGadget
2026-11-25 19:49 ` [PATCH v2] " Alessio Attilio via GitGitGadget
2026-11-25 23:11 ` [PATCH v3] " Alessio Attilio via GitGitGadget
@ 2026-11-25 23:22 ` Alessio Attilio via GitGitGadget
2026-11-25 23:42 ` [PATCH v5] " Alessio Attilio via GitGitGadget
3 siblings, 0 replies; 8+ messages in thread
From: Alessio Attilio via GitGitGadget @ 2026-11-25 23:22 UTC (permalink / raw)
To: git; +Cc: Alessio Attilio, Alessio Attilio
From: Alessio Attilio <attilio.alessio@protonmail.com>
During a filtered fetch in a partial clone, index-pack --promisor
re-packs local links from the incoming pack into promisor packs. It
invokes pack-objects with --exclude-promisor-objects-best-effort to
skip links already stored in promisor packs. After a filtered
--unshallow or --deepen, this walk can encounter a promisor commit
whose tree is missing. The object-info lookup then hits a BUG and the
fetch fails.
Do not lazy-fetch while checking these links: this is a best-effort
repack, not a request to retrieve missing objects. If the object is
missing, pack-objects cannot include it, so treat it like an object
already in a promisor pack and continue. This callback is used only by
the best-effort repack started for an incoming promisor pack, whose
output is itself marked promisor. If the missing object was not
actually promised, this still cannot discard available data; the
object was already absent and any later access would fail unless the
promisor remote can provide it.
Test filtered --unshallow and --deepen fetches, as well as a subsequent
fetch that repacks links to promisor commits with missing trees.
Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
---
pack-objects: handle missing promisor objects
Changes since v1:
* Pass OBJECT_INFO_SKIP_FETCH_OBJECT explicitly to avoid lazy fetching
during the lookup.
* Cover filtered --unshallow and --deepen fetches, and a later fetch
after unshallowing a filtered clone.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2333%2Fkairosci%2Fattilio%2Fpack-objects-missing-promisor-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2333/kairosci/attilio/pack-objects-missing-promisor-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/2333
Range-diff vs v3:
1: cbe2fc475c ! 1: b2112b07dd pack-objects: handle missing promisor objects
@@ Metadata
## Commit message ##
pack-objects: handle missing promisor objects
- Objects missing from a partial clone are expected to be absent.
- When checking whether an object is in a promisor pack, do not BUG()
- if its object info cannot be read. Such an object cannot be included
- in the pack, so skip it.
+ During a filtered fetch in a partial clone, index-pack --promisor
+ re-packs local links from the incoming pack into promisor packs. It
+ invokes pack-objects with --exclude-promisor-objects-best-effort to
+ skip links already stored in promisor packs. After a filtered
+ --unshallow or --deepen, this walk can encounter a promisor commit
+ whose tree is missing. The object-info lookup then hits a BUG and the
+ fetch fails.
- Pass OBJECT_INFO_SKIP_FETCH_OBJECT explicitly so the lookup does not
- trigger a lazy fetch.
+ Do not lazy-fetch while checking these links: this is a best-effort
+ repack, not a request to retrieve missing objects. If the object is
+ missing, pack-objects cannot include it, so treat it like an object
+ already in a promisor pack and continue. This callback is used only by
+ the best-effort repack started for an incoming promisor pack, whose
+ output is itself marked promisor. If the missing object was not
+ actually promised, this still cannot discard available data; the
+ object was already absent and any later access would fail unless the
+ promisor remote can provide it.
Test filtered --unshallow and --deepen fetches, as well as a subsequent
fetch that repacks links to promisor commits with missing trees.
builtin/pack-objects.c | 7 +++--
t/t5616-partial-clone.sh | 55 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 87c3102e62..371f16c59b 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -5135,8 +5135,11 @@ static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)
.source_infop = &source_info,
};
- if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))
- BUG("should_include_obj should only be called on existing objects");
+ if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info,
+ OBJECT_INFO_SKIP_FETCH_OBJECT)) {
+ /* Missing; assume it is a promisor object. */
+ return 0;
+ }
return source_info.source->type != ODB_SOURCE_PACKED || !source_info.u.packed.pack->pack_promisor;
}
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index 9636652362..44ce9a1ee8 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -790,6 +790,61 @@ test_expect_success 'merge does not lazy-fetch locally written objects' '
done &&
test_cmp server/only-in-C client/only-in-C
'
+for opt in --unshallow --deepen=1
+do
+ test_expect_success "filtered fetch $opt of a moved ref repacks local links" '
+ test_when_finished "rm -rf source target" &&
+
+ git init source &&
+ test_commit_bulk -C source 4 &&
+ git -C source config uploadpack.allowFilter true &&
+ git -C source config uploadpack.allowAnySHA1InWant true &&
+ COMMIT=$(git -C source rev-parse main~1) &&
+
+ git init target &&
+ git -C target remote add origin "file://$(pwd)/source" &&
+ git -C target fetch --no-tags --depth=1 origin "+$COMMIT:refs/remotes/origin/main" &&
+
+ # The fetched pack has the new tip whose parent is the local shallow
+ # tip, so index-pack repacks it into a promisor pack. That process
+ # inherits the shallow file and walks into promisor commits whose
+ # trees do not exist.
+ git -C target fetch --no-tags --filter=tree:0 "$opt" origin \
+ +refs/heads/main:refs/remotes/origin/main &&
+ git -C target rev-parse --verify refs/remotes/origin/main >actual &&
+ git -C source rev-parse --verify refs/heads/main >expect &&
+ test_cmp expect actual &&
+ git -C target fsck
+ '
+done
+
+test_expect_success 'repacking local links tolerates missing trees of promisor commits' '
+ test_when_finished "rm -rf source target" &&
+
+ git init source &&
+ test_commit_bulk -C source 4 &&
+ git -C source config uploadpack.allowFilter true &&
+ git -C source config uploadpack.allowAnySHA1InWant true &&
+ COMMIT=$(git -C source rev-parse main~1) &&
+
+ # Fetch a single commit as a non-promisor object, then unshallow it
+ # with a filter that omits trees. The commits below the former
+ # shallow boundary are now promisor objects whose trees are missing.
+ git init target &&
+ git -C target remote add origin "file://$(pwd)/source" &&
+ git -C target fetch --no-tags --depth=1 origin "+$COMMIT:refs/remotes/origin/main" &&
+ git -C target fetch --no-tags --filter=tree:0 --unshallow origin \
+ "+$COMMIT:refs/remotes/origin/main" &&
+ test_path_is_missing target/.git/shallow &&
+
+ # Fetching a descendant of the local non-promisor commit causes
+ # index-pack to repack that commit into a promisor pack. The revision
+ # walk must not die when it reaches the missing trees of promisor commits.
+ git -C target fetch --no-tags --filter=tree:0 origin \
+ +refs/heads/main:refs/remotes/origin/main &&
+ git -C target rev-parse --verify refs/remotes/origin/main &&
+ git -C target fsck
+'
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd
base-commit: acba8bf9753134d9bde89f94369f775838a8c5fe
--
gitgitgadget
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v5] pack-objects: handle missing promisor objects
2026-11-25 19:40 [PATCH] pack-objects: handle missing promisor objects Alessio Attilio via GitGitGadget
` (2 preceding siblings ...)
2026-11-25 23:22 ` [PATCH v4] " Alessio Attilio via GitGitGadget
@ 2026-11-25 23:42 ` Alessio Attilio via GitGitGadget
3 siblings, 0 replies; 8+ messages in thread
From: Alessio Attilio via GitGitGadget @ 2026-11-25 23:42 UTC (permalink / raw)
To: git; +Cc: Alessio Attilio, Alessio Attilio
From: Alessio Attilio <attilio.alessio@protonmail.com>
During a filtered fetch in a partial clone, index-pack --promisor
repacks local links from the incoming pack into promisor packs. It
invokes pack-objects with --exclude-promisor-objects-best-effort to
skip links already stored in promisor packs. After a filtered
--unshallow or --deepen, this walk can encounter a promisor commit
whose tree is missing. The object-info lookup then hits a BUG and the
fetch fails.
Do not lazy-fetch while checking these links: this is a best-effort
repack, not a request to retrieve missing objects. If the object is
missing, pack-objects cannot include it, so treat it like an object
already in a promisor pack and continue. This callback is used only by
the best-effort repack started for an incoming promisor pack, whose
output is itself marked promisor. If the missing object was not
actually promised, this still cannot discard available data; the
object was already absent and any later access would fail unless the
promisor remote can provide it.
Test filtered --unshallow and --deepen fetches, as well as a subsequent
fetch that repacks links to promisor commits with missing trees.
Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
---
pack-objects: handle missing promisor objects
Changes since v1:
* Pass OBJECT_INFO_SKIP_FETCH_OBJECT explicitly to avoid lazy fetching
during the lookup.
* Cover filtered --unshallow and --deepen fetches, and a later fetch
after unshallowing a filtered clone.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2333%2Fkairosci%2Fattilio%2Fpack-objects-missing-promisor-v5
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2333/kairosci/attilio/pack-objects-missing-promisor-v5
Pull-Request: https://github.com/gitgitgadget/git/pull/2333
Range-diff vs v4:
1: b2112b07dd ! 1: 1129e6a3a6 pack-objects: handle missing promisor objects
@@ Commit message
pack-objects: handle missing promisor objects
During a filtered fetch in a partial clone, index-pack --promisor
- re-packs local links from the incoming pack into promisor packs. It
+ repacks local links from the incoming pack into promisor packs. It
invokes pack-objects with --exclude-promisor-objects-best-effort to
skip links already stored in promisor packs. After a filtered
--unshallow or --deepen, this walk can encounter a promisor commit
@@ builtin/pack-objects.c: static int is_not_in_promisor_pack_obj(struct object *ob
- BUG("should_include_obj should only be called on existing objects");
+ if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info,
+ OBJECT_INFO_SKIP_FETCH_OBJECT)) {
-+ /* Missing; assume it is a promisor object. */
++ /*
++ * This is the best-effort pass that repacks local links from an
++ * incoming promisor pack. A missing object cannot be packed, so
++ * skip it. If it was not promised, its data was already absent;
++ * later access still needs a remote to provide it.
++ */
+ return 0;
+ }
return source_info.source->type != ODB_SOURCE_PACKED || !source_info.u.packed.pack->pack_promisor;
builtin/pack-objects.c | 12 +++++++--
t/t5616-partial-clone.sh | 55 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 87c3102e62..713d6d970b 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -5135,8 +5135,16 @@ static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)
.source_infop = &source_info,
};
- if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))
- BUG("should_include_obj should only be called on existing objects");
+ if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info,
+ OBJECT_INFO_SKIP_FETCH_OBJECT)) {
+ /*
+ * This is the best-effort pass that repacks local links from an
+ * incoming promisor pack. A missing object cannot be packed, so
+ * skip it. If it was not promised, its data was already absent;
+ * later access still needs a remote to provide it.
+ */
+ return 0;
+ }
return source_info.source->type != ODB_SOURCE_PACKED || !source_info.u.packed.pack->pack_promisor;
}
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index 9636652362..44ce9a1ee8 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -790,6 +790,61 @@ test_expect_success 'merge does not lazy-fetch locally written objects' '
done &&
test_cmp server/only-in-C client/only-in-C
'
+for opt in --unshallow --deepen=1
+do
+ test_expect_success "filtered fetch $opt of a moved ref repacks local links" '
+ test_when_finished "rm -rf source target" &&
+
+ git init source &&
+ test_commit_bulk -C source 4 &&
+ git -C source config uploadpack.allowFilter true &&
+ git -C source config uploadpack.allowAnySHA1InWant true &&
+ COMMIT=$(git -C source rev-parse main~1) &&
+
+ git init target &&
+ git -C target remote add origin "file://$(pwd)/source" &&
+ git -C target fetch --no-tags --depth=1 origin "+$COMMIT:refs/remotes/origin/main" &&
+
+ # The fetched pack has the new tip whose parent is the local shallow
+ # tip, so index-pack repacks it into a promisor pack. That process
+ # inherits the shallow file and walks into promisor commits whose
+ # trees do not exist.
+ git -C target fetch --no-tags --filter=tree:0 "$opt" origin \
+ +refs/heads/main:refs/remotes/origin/main &&
+ git -C target rev-parse --verify refs/remotes/origin/main >actual &&
+ git -C source rev-parse --verify refs/heads/main >expect &&
+ test_cmp expect actual &&
+ git -C target fsck
+ '
+done
+
+test_expect_success 'repacking local links tolerates missing trees of promisor commits' '
+ test_when_finished "rm -rf source target" &&
+
+ git init source &&
+ test_commit_bulk -C source 4 &&
+ git -C source config uploadpack.allowFilter true &&
+ git -C source config uploadpack.allowAnySHA1InWant true &&
+ COMMIT=$(git -C source rev-parse main~1) &&
+
+ # Fetch a single commit as a non-promisor object, then unshallow it
+ # with a filter that omits trees. The commits below the former
+ # shallow boundary are now promisor objects whose trees are missing.
+ git init target &&
+ git -C target remote add origin "file://$(pwd)/source" &&
+ git -C target fetch --no-tags --depth=1 origin "+$COMMIT:refs/remotes/origin/main" &&
+ git -C target fetch --no-tags --filter=tree:0 --unshallow origin \
+ "+$COMMIT:refs/remotes/origin/main" &&
+ test_path_is_missing target/.git/shallow &&
+
+ # Fetching a descendant of the local non-promisor commit causes
+ # index-pack to repack that commit into a promisor pack. The revision
+ # walk must not die when it reaches the missing trees of promisor commits.
+ git -C target fetch --no-tags --filter=tree:0 origin \
+ +refs/heads/main:refs/remotes/origin/main &&
+ git -C target rev-parse --verify refs/remotes/origin/main &&
+ git -C target fsck
+'
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd
base-commit: acba8bf9753134d9bde89f94369f775838a8c5fe
--
gitgitgadget
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v3] pack-objects: handle missing promisor objects
2026-11-25 23:11 ` [PATCH v3] " Alessio Attilio via GitGitGadget
@ 2026-11-26 1:10 ` Junio C Hamano
2026-11-26 10:48 ` ATTILIO ALESSIO
0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2026-11-26 1:10 UTC (permalink / raw)
To: Alessio Attilio via GitGitGadget; +Cc: git, Alessio Attilio
"Alessio Attilio via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Alessio Attilio <attilio.alessio@protonmail.com>
>
> Objects missing from a partial clone are expected to be absent.
> When checking whether an object is in a promisor pack, do not BUG()
> if its object info cannot be read. Such an object cannot be included
> in the pack, so skip it.
>
> Pass OBJECT_INFO_SKIP_FETCH_OBJECT explicitly so the lookup does not
> trigger a lazy fetch.
>
> Test filtered --unshallow and --deepen fetches, as well as a subsequent
> fetch that repacks links to promisor commits with missing trees.
>
> Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
> ---
> pack-objects: handle missing promisor objects
>
> Changes since v1:
>
> * Pass OBJECT_INFO_SKIP_FETCH_OBJECT explicitly to avoid lazy fetching
> during the lookup.
> * Cover filtered --unshallow and --deepen fetches, and a later fetch
> after unshallowing a filtered clone.
Here is what Documentation/SubmittingPatches::[[patch-flow]] says:
It is often beneficial to allow some time for reviewers to provide
feedback before sending a new version, rather than sending an updated
series immediately after receiving a review. This helps collect broader
input, gives reviewers in different time zones a fair chance to comment,
and avoids unnecessary churn from many rapid iterations. Waiting also
encourages you to polish each version before sending it, so reviewers
can focus on substantial issues rather than typos or other small
mistakes.
It is not considered good manners to send a new iteration before
first finishing the discussion on the reviews you received on your
previous iteration. You respond to reviews, saying "I will fix this
point", "I think this one is fine as-is because...", and so forth,
wait for responses to your response, and eventually come to an
agreement with those in the discussion, so both sides know what the
next iteration should look like before you start working on it.
Only after finishing all of that do you prepare and send a new
iteration.
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] pack-objects: handle missing promisor objects
2026-11-26 1:10 ` Junio C Hamano
@ 2026-11-26 10:48 ` ATTILIO ALESSIO
0 siblings, 0 replies; 8+ messages in thread
From: ATTILIO ALESSIO @ 2026-11-26 10:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Alessio Attilio via GitGitGadget, git
[-- Attachment #1.1: Type: text/plain, Size: 1199 bytes --]
Junio C Hamano gitster@pobox.com writes:
> It is not considered good manners to send a new iteration before
> first finishing the discussion on the reviews you received on your
> previous iteration. You respond to reviews, saying “I will fix this
> point”, “I think this one is fine as-is because...”, and so forth,
> wait for responses to your response, and eventually come to an
> agreement with those in the discussion, so both sides know what the
> next iteration should look like before you start working on it.
>
> Only after finishing all of that do you prepare and send a new
> iteration.
Understood, and thank you for pointing me to that section of
Documentation/SubmittingPatches. I apologize for rushing out v5
before replying to your v4 review and allowing time for others to
weigh in.
Going forward, I will make sure to respond to review comments on the
thread first and wait for consensus before sending a new iteration.
Since v5 is already on the list with the updated commit message and
in-code comment addressing your v4 feedback, I will leave it as-is
for now and wait for any further comments from you and other
reviewers.
Thanks,
Alessio
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 323 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-26 10:49 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 19:40 [PATCH] pack-objects: handle missing promisor objects Alessio Attilio via GitGitGadget
2026-11-25 19:49 ` [PATCH v2] " Alessio Attilio via GitGitGadget
2026-11-25 22:47 ` Junio C Hamano
2026-11-25 23:11 ` [PATCH v3] " Alessio Attilio via GitGitGadget
2026-11-26 1:10 ` Junio C Hamano
2026-11-26 10:48 ` ATTILIO ALESSIO
2026-11-25 23:22 ` [PATCH v4] " Alessio Attilio via GitGitGadget
2026-11-25 23:42 ` [PATCH v5] " Alessio Attilio via GitGitGadget
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox