Merge branch 'ps/pack-concat-wo-backfill' into jch

"git pack-objects --stdin-packs" with "--exclude-promisor-objects"
fetched objects that are promised, which was not wanted.  This has
been fixed.

* ps/pack-concat-wo-backfill:
  builtin/pack-objects: don't fetch objects when merging packs
This commit is contained in:
Junio C Hamano
2026-02-23 14:25:42 -08:00
2 changed files with 28 additions and 0 deletions

View File

@@ -3924,8 +3924,16 @@ static void add_unreachable_loose_objects(struct rev_info *revs);
static void read_stdin_packs(enum stdin_packs_mode mode, int rev_list_unpacked)
{
int prev_fetch_if_missing = fetch_if_missing;
struct rev_info revs;
/*
* The revision walk may hit objects that are promised, only. As the
* walk is best-effort though we don't want to perform backfill fetches
* for them.
*/
fetch_if_missing = 0;
repo_init_revisions(the_repository, &revs, NULL);
/*
* Use a revision walk to fill in the namehash of objects in the include
@@ -3961,6 +3969,8 @@ static void read_stdin_packs(enum stdin_packs_mode mode, int rev_list_unpacked)
stdin_packs_found_nr);
trace2_data_intmax("pack-objects", the_repository, "stdin_packs_hints",
stdin_packs_hints_nr);
fetch_if_missing = prev_fetch_if_missing;
}
static void add_cruft_object_entry(const struct object_id *oid, enum object_type type,

View File

@@ -358,6 +358,24 @@ test_expect_success '--stdin-packs with promisors' '
)
'
test_expect_success '--stdin-packs does not perform backfill fetch' '
test_when_finished "rm -rf remote client" &&
git init remote &&
test_commit_bulk -C remote 10 &&
git -C remote config set --local uploadpack.allowfilter 1 &&
git -C remote config set --local uploadpack.allowanysha1inwant 1 &&
git clone --filter=tree:0 "file://$(pwd)/remote" client &&
(
cd client &&
ls .git/objects/pack/*.promisor | sed "s|.*/||; s/\.promisor$/.pack/" >packs &&
test_line_count -gt 1 packs &&
GIT_TRACE2_EVENT="$(pwd)/event.log" git pack-objects --stdin-packs pack <packs &&
test_grep ! "\"event\":\"child_start\"" event.log
)
'
stdin_packs__follow_with_only () {
rm -fr stdin_packs__follow_with_only &&
git init stdin_packs__follow_with_only &&