Skip to content

pack-objects: handle missing promisor objects - #2333

Open
kairosci wants to merge 1 commit into
gitgitgadget:masterfrom
kairosci:attilio/pack-objects-missing-promisor
Open

kairosci wants to merge 1 commit into
gitgitgadget:masterfrom
kairosci:attilio/pack-objects-missing-promisor

Conversation

@kairosci

@kairosci kairosci commented Nov 25, 2026 •

Copy link
Copy Markdown

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.

@kairosci

Copy link
Copy Markdown
Author

/preview

@kairosci

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Preview email sent as pull.2333.git.1795635580079.gitgitgadget@gmail.com

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Submitted as pull.2333.git.1795635624820.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2333/kairosci/attilio/pack-objects-missing-promisor-v1

To fetch this version to local tag pr-2333/kairosci/attilio/pack-objects-missing-promisor-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2333/kairosci/attilio/pack-objects-missing-promisor-v1

@kairosci
kairosci force-pushed the attilio/pack-objects-missing-promisor branch from 16a9cac to a7e378c Compare November 25, 2026 19:48
@kairosci

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Submitted as pull.2333.v2.git.1795636170423.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2333/kairosci/attilio/pack-objects-missing-promisor-v2

To fetch this version to local tag pr-2333/kairosci/attilio/pack-objects-missing-promisor-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2333/kairosci/attilio/pack-objects-missing-promisor-v2

@kairosci kairosci changed the title pack-objects: handle missing promisor objects partial clone: handle missing promisor objects and CI setup Nov 25, 2026
@kairosci

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Preview email sent as pull.2333.v3.git.1795642405.gitgitgadget@gmail.com

@kairosci
kairosci force-pushed the attilio/pack-objects-missing-promisor branch from a11b64e to a7e378c Compare November 25, 2026 21:51
@kairosci kairosci changed the title partial clone: handle missing promisor objects and CI setup pack-objects: handle missing promisor objects Nov 25, 2026
@kairosci
kairosci force-pushed the attilio/pack-objects-missing-promisor branch 2 times, most recently from 18f9af7 to cbe2fc4 Compare November 25, 2026 22:28
@kairosci

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Preview email sent as pull.2333.v3.git.1795648178440.gitgitgadget@gmail.com

@kairosci

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Submitted as pull.2333.v3.git.1795648282594.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2333/kairosci/attilio/pack-objects-missing-promisor-v3

To fetch this version to local tag pr-2333/kairosci/attilio/pack-objects-missing-promisor-v3:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2333/kairosci/attilio/pack-objects-missing-promisor-v3

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"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.

@kairosci
kairosci force-pushed the attilio/pack-objects-missing-promisor branch from cbe2fc4 to b2112b0 Compare November 25, 2026 23:19
@kairosci

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Preview email sent as pull.2333.v4.git.1795648883945.gitgitgadget@gmail.com

@kairosci

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Submitted as pull.2333.v4.git.1795648951606.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2333/kairosci/attilio/pack-objects-missing-promisor-v4

To fetch this version to local tag pr-2333/kairosci/attilio/pack-objects-missing-promisor-v4:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2333/kairosci/attilio/pack-objects-missing-promisor-v4

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>
@kairosci
kairosci force-pushed the attilio/pack-objects-missing-promisor branch from b2112b0 to 1129e6a Compare November 25, 2026 23:39
@kairosci

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Preview email sent as pull.2333.v5.git.1795650080643.gitgitgadget@gmail.com

@kairosci

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Nov 25, 2026

Copy link
Copy Markdown

Submitted as pull.2333.v5.git.1795650160536.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2333/kairosci/attilio/pack-objects-missing-promisor-v5

To fetch this version to local tag pr-2333/kairosci/attilio/pack-objects-missing-promisor-v5:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2333/kairosci/attilio/pack-objects-missing-promisor-v5

@gitgitgadget

gitgitgadget Bot commented Nov 26, 2026

Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"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.

@gitgitgadget

gitgitgadget Bot commented Nov 26, 2026

Copy link
Copy Markdown

ATTILIO ALESSIO wrote on the Git mailing list (how to reply to this email):

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant