Article View: linux.kernel.git
Article #50Re: [BUG] repack --drop-filtered --dry-run writes packs and honors -d in Git 2.56.0
From: "D. Ben Knoble"
Date: Wed, 07 Oct 2026 19:10
Date: Wed, 07 Oct 2026 19:10
202 lines
17696 bytes
17696 bytes
Cc: Siddharth Shrimali <r.siddharth.shrimali@gmail.com> who authored
the --drop-filtered code.
On Sun, Oct 4, 2026 at 7:47 PM Coy Geek <coygeek@gmail.com> wrote:
>
> fix(repack): --drop-filtered --dry-run writes packs and deletes old
> packs with -d
>
> ## Summary
>
> On Git 2.56.0, `git repack -a --filter=blob:limit=1m --drop-filtered
> --dry-run` prints the candidate blob but also writes a new promisor
> pack and its sidecar files. Adding explicit `-d` also removes the old
> redundant packs and their sidecar files. Both commands exit
> successfully despite the documented promise to list candidates without
> rebuilding packs or deleting anything.
>
> This makes the advertised preview mutate repository storage. The
> tested blob remains available after both commands; this report does
> not demonstrate loss of object content.
>
> ## Steps to reproduce
>
> The following Python 3 script was executed with Git 2.56.0 on macOS.
> It requires `git` on `PATH`, creates only disposable local
> repositories, disables ambient Git configuration and hooks, and uses a
> synthetic commit identity. It creates a 2,200,000-byte historical blob
> absent from the current index, makes a filtered clone through a local
> promisor remote, fetches that blob into a promisor pack, and snapshots
> the pack directory before each preview. Each variant uses its own
> fresh partial clone. The script removes its fixture after a successful
> run.
>
> ```python
> import hashlib
> import os
> from pathlib import Path
> import subprocess
> import shutil
> import tempfile
>
> work = Path(tempfile.mkdtemp(prefix='agent-work.', dir='/tmp'))
> env = {k: v for k, v in os.environ.items() if not k.startswith('GIT_')}
> env.update(GIT_CONFIG_NOSYSTEM='1', GIT_CONFIG_GLOBAL=os.devnull,
> LC_ALL='C', GIT_TERMINAL_PROMPT='0')
>
> def git(repo, *args):
> command = ['git', '-c', 'gc.auto=0', '-c', 'core.hooksPath=' + os.devnull,
> '-c', 'user.name=Fixture', '-c',
> 'user.email=fixture@example.invalid',
> '-C', str(repo), *args]
> return subprocess.run(command, env=env, check=True, text=True,
> stdout=subprocess.PIPE,
> stderr=subprocess.PIPE).stdout.strip()
>
> def inventory(repo):
> packdir = repo / '.git' / 'objects' / 'pack'
> return {p.name: hashlib.sha256(p.read_bytes()).hexdigest()
> for p in packdir.iterdir() if p.is_file()}
>
> print(git(work, '--version'))
> source = work / 'source'
> source.mkdir()
> git(source, 'init', '--template=', '-b', 'main')
> (source / 'large.bin').write_bytes(b'LARGE BLOB\n' * 200000)
> git(source, 'add', 'large.bin')
> git(source, 'commit', '-m', 'Add historical blob')
> blob = git(source, 'rev-parse', 'HEAD:large.bin')
> git(source, 'rm', 'large.bin')
> (source / 'tip.txt').write_text('tip\n')
> git(source, 'add', 'tip.txt')
> git(source, 'commit', '-m', 'Remove historical blob')
> remote = work / 'remote.git'
> git(work, 'clone', '--bare', str(source), str(remote))
> git(remote, 'config', 'uploadpack.allowFilter', 'true')
>
> for label, extra in [('dry-run', []), ('dry-run -d', ['-d'])]:
> repo = work / ('clone-delete' if extra else 'clone-preview')
> git(work, '-c', 'protocol.file.allow=always', 'clone', '--filter=blob:none',
> remote.as_uri(), str(repo))
> assert git(repo, 'cat-file', '-s', blob) == '2200000'
> before = inventory(repo)
> output = git(repo, 'repack', '-a', *extra, '--filter=blob:limit=1m',
> '--drop-filtered', '--dry-run')
> after = inventory(repo)
> added = sorted(after.keys() - before.keys())
> removed = sorted(before.keys() - after.keys())
> changed = sorted(k for k in before.keys() & after.keys() if
> before[k] != after[k])
> print(label + ': exit 0')
> print('candidate=' + output)
> print('pack directory: before=%d after=%d added=%d removed=%d changed=%d' %
> (len(before), len(after), len(added), len(removed), len(changed)))
> print('added extensions=' + ','.join(sorted(Path(k).suffix for k in added)))
> print('removed extensions=' + ','.join(sorted(Path(k).suffix for k
> in removed)))
> print('candidate size after=' + git(repo, 'cat-file', '-s', blob))
> shutil.rmtree(work)
> ```
>
> ## Expected behavior
>
> The Git 2.56.0 `git-repack` manual says `--dry-run` should "List the
> objects that would be dropped, one object ID per line, without
> rebuilding any pack or deleting anything."
>
> For both commands, Git should print the candidate blob and leave the
> existing pack files and their contents unchanged. Explicit `-d` should
> not cause deletion during this dry run. The fixture satisfies the
> documented prerequisites: `-a`, a supported `blob:limit` filter, a
> configured promisor remote, no operation in progress, and a candidate
> absent from the current index.
>
> ## Actual behavior
>
> The executed script produced this output. The counts include regular
> files in `objects/pack`, and `changed` compares SHA-256 content hashes
> for names present before and after.
>
> ```text
> git version 2.56.0
> dry-run: exit 0
> candidate=faed553c77de798540bd1edc898e174bf4436b28
> pack directory: before=12 after=16 added=4 removed=0 changed=0
> added extensions=.idx,.pack,.promisor,.rev
> removed extensions=
> candidate size after=2200000
> dry-run -d: exit 0
> candidate=faed553c77de798540bd1edc898e174bf4436b28
> pack directory: before=12 after=4 added=4 removed=12 changed=0
> added extensions=.idx,.pack,.promisor,.rev
> removed extensions=.idx,.idx,.idx,.pack,.pack,.pack,.promisor,.promisor,.promisor,.rev,.rev,.rev
> candidate size after=2200000
> ```
>
> The ordinary preview added four files, one each with `.pack`, `.idx`,
> `.promisor`, and `.rev` extensions. The preview with explicit `-d`
> added the same four types and deleted the 12 previous pack and sidecar
> files. Both invocations printed the expected candidate object ID and
> exited 0. A subsequent `cat-file -s` still reported the blob's
> original size in both clones.
>
> This report records one successful invocation of each variant in the
> final script execution. A preceding fixture execution reproduced the
> same counts. These observations establish the Git 2.56.0 behavior;
> current development Git was not built or executed for this report.
>
> ## Evidence
>
> - Expected source: Git 2.56.0 [Documentation/git-repack.adoc, the
> `--dry-run` option](https://github.com/git/git/blob/v2.56.0/Documentation/git-repack.adoc#L217-L220),
> which promises no pack rebuilding or deletion.
> - Failure source: The inline script and its captured output in Actual
> behavior. The before/after pack inventories show four added files for
> both variants and 12 deleted files when explicit `-d` is present.
> - Evidence provenance: observed
> - Local verification: reproduced
> - Reproduction completeness: complete
>
> The primary violation evidence is execution of the inline fixture with
> Git 2.56.0. Both commands exited 0 with the pack-directory changes
> shown above. The manual and source links provide the contract and
> supporting static evidence.
>
> The release source at [builtin/repack.c, lines
> 356-394](https://github.com/git/git/blob/v2.56.0/builtin/repack.c#L356-L394)
> guards the implicit `delete_redundant` setting with `!dry_run`, then
> prints candidates when `dry_run` is set. Execution continues beyond
> that block. This is a source breadcrumb consistent with the observed
> results, rather than a required implementation change.
>
> The original implementation discussion also describes dry run as
> leaving the repository unchanged: [v5
> 1/6](https://lore.kernel.org/git/20260813200830.84348-2-r.siddharth.shrimali@gmail.com/)
> and [v5 5/6](https://lore.kernel.org/git/20260813200830.84348-6-r.siddharth.shrimali@gmail.com/).
>
> ## Restoration check
>
> Run the same fixture after a fix. Both preview variants should still
> print the candidate object ID and exit successfully, with `added=0
> removed=0 changed=0` and equal before/after pack-directory counts.
> Retaining the candidate output distinguishes a working preview from
> simply skipping the operation. The cached blob should remain
> available. Use the ordinary command and the explicit `-d` variant as
> separate checks of the same no-write contract.
>
--
D. Ben Knoble
Technical Details
Message-ID:
<CALnO6CCmv7PmxW2HTfvD8i6-PCVqMWgasyU9PYhPLXGj1sz=Hg@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-71399-linux-kernel-git=dewy.ruReferences:
<CACgTecOm+=vbf50tZNXhcYvRi1ZTsQwbjVoJAbQqs2CmXdJCxg@mail.gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-71399-linux-kernel-git=dewy.ru
From: ben.knoble@gmail.com ("D. Ben Knoble")
Newsgroups: linux.kernel.git
Subject: Re: [BUG] repack --drop-filtered --dry-run writes packs and honors -d
in Git 2.56.0
Date: Wed, 7 Oct 2026 15:10:24 -0400
Organization: Usenet Network
Message-ID: <CALnO6CCmv7PmxW2HTfvD8i6-PCVqMWgasyU9PYhPLXGj1sz=Hg@mail.gmail.com>
References: <CACgTecOm+=vbf50tZNXhcYvRi1ZTsQwbjVoJAbQqs2CmXdJCxg@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="717611"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:QS4ccOrT+ft4ebXVR0IYBHw0QYQ= sha256:JvWtb60500veL+S5VIWlUUU733Fd/NHeOF5uc4o5LyE=
sha1:l7YQMYRRuA2pt+iJhTnu3yUN88I= sha256:y0YVBPqox4FK4gSjKxxa49csIke0sEFqVYI2055NWW0=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 935D410F210; Wed, 7 Oct 2026 22:10:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.749
X-Spam-Status: No, score=-0.749 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id PD-2Vyb6Wg5R;
Wed, 7 Oct 2026 22:10:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-71399-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 9341A10F1FB; Wed, 7 Oct 2026 22:10:45 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by tor.lore.kernel.org (Postfix) with ESMTP id A6A562B589; Wed, 7 Oct 2026 19:10:42 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 474664E2F07;
Wed, 7 Oct 2026 19:10:39 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jiRk/ygw"
X-Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBF544DEC14
for <git@vger.kernel.org>; Wed, 7 Oct 2026 19:10:36 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.215.181
X-ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1791400238; cv=pass; b=cnOfqWpVOxsP/2F80YjTMzUsaSNp/ZZwrrSmCmuRMmwwE4gbXRqAeOoMykuXjgbrhqJkQ7vgyBaXhSIv5mM1Xw90TxTjDEkL8tBPt8CaxDsoQih7shrN2VuUSQkw6tFLPmxSJ1q8H0aozrTXRPrQ8XgNMYqcrMHbGRw3nl2HVaU=
X-ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1791400238; c=relaxed/simple;
bh=zTic5X9J06YRWatWbY5AxBM81r2DfMwmsQP1Cr+zOXk=;
h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:
To:Cc:Content-Type; b=V2tml6GCv+h7R0DjuaHkaYtyHQgof3x8GnKu5Uf75GEatSwiXkrH1XJUasMTo3R6mLy5rRPe22nDOXB7CcdBWQTVfvhIPUknxc1iCANiHNDVBPNvFPFNQJJKZWL1YW4EHSrMbYqxHnCgeOUbLw/KEvZk/kwwm+c4aZVxOhXCu/k=
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jiRk/ygw; arc=pass smtp.client-ip=209.85.215.181
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-ccce6d9abfeso1523610a12.1
for <git@vger.kernel.org>; Wed, 07 Oct 2026 12:10:36 -0700 (PDT)
X-ARC-Seal: i=1; a=rsa-sha256; t=1791400236; cv=none;
d=google.com; s=arc-20260327;
b=seNJoB2DGkiwdGbnhI148rWGIBBmt1F7TdDYr7G6/VunKtnXW6X15/sE4NIdYlx/Ec
725DBQArbY+JoozgBKUSBd1H0xh42rve4RsnFF1LsXtK5HtM/JC77E5c7tcilivuizYh
g5pGkObTQOCZYQjZUeUFWekBV5sLQ9+/DqkZiKHVPuAqJod8bR09GpODrXe3Av3VyzgR
8ONTLRzChWjdwlDvIe5JmvrUhLwlyUWQ/4gbCYsifw6uYbgboJ7oXF1DnY+Ja7ZZ7q1T
zV5X5uBlkvPd4durlueRcaiQNTjpUfTW4UFe3maoPnlUJFxZtf+mNby0nUXfQsHqLMTZ
8g5A==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
h=content-transfer-encoding:cc:to:subject:message-id:date:from
:in-reply-to:references:mime-version:dkim-signature;
bh=nkKTm6grm6J/H9QzFMzEJtWwmg5VuxdMl+XIuQvd/kY=;
fh=KbndeiWJYoVjvD6HEdLyPEPLhgfD9tU9i/2CRzekWMU=;
b=EJrpzoG/jZjRfPMzuHBjTpgPr7Zf8w5NltgBjs+gj05OqO25WYS/vBa+pE0D+1y2+O
/J54tZE154gPtuvvxkKVBs9u82T6AN+kVW+YwAnWGlremramEZ46E+AC3ir9+EzBltAV
zD5oU4z+qr6De7oDcnzBuFfGMIhn/f7HKacl0jO0zOz24I+wmRD9BqTzRY8HK0Ul5exp
ltdnN5P7fmDp8KsCMSd8u2H3i15RTc21E+2ottKPfNx+dqkYugB+aaSBdRmA8BkqF6A7
6PLk24tv80idgDzQXmlWs6B2bmscRnDWi7BG6IGi/9DMte/bm0AZLfUf22e/CPnTQC8n
IVeA==;
darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1791400236; x=1792005036; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=nkKTm6grm6J/H9QzFMzEJtWwmg5VuxdMl+XIuQvd/kY=;
b=jiRk/ygwjlevuOKQbKRBgjD3MbJPlP5H1S56/Cpm1chulIWB2QGHEPNGl8EWP3ibUt
CogUtSDDLSLEfkqG/HQncTxan15BVnehrfDk50ObYZbd97El9XbtPt/NHKqJ+Qkwgt4i
Ky2Gf4aSlGWf1SxcbEaufD+VZRHUHatkdaWUPLRorl4Q/fv+MUEnzvOR+qCogHZMaexE
XDgS96dWc2tfCxD8tUW4d4uHHRq4okvtA8Q6yWSY95v9r7O1Jo6nqKNkud2HB/0ORQU8
GV+Hz/B9JICkfJl/ltUEHNsaBay5mnbpff2xK+Yuf9bpFoAdnv00vUnMg/gKB5yb9b1c
RJ1w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1791400236; x=1792005036;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=nkKTm6grm6J/H9QzFMzEJtWwmg5VuxdMl+XIuQvd/kY=;
b=aKpuIJlnQZmPpxbHwqb81QJx1Dq8jpn8Yf91crGTNwfbbcoyMgmZx08m8j4H0yYz0G
Nxa/J5FtEH9LSTEOBX8DIlXwbXfPovc81zTiUetiO0BVaWraL5f0p2Z13YRYGas1Xm/3
SgHPMl5/ao1ybk1Ay9enwFGfoBCIpYa0f3iw3KQooyQb0F/UpgGfx9Aj0VFNloWMA+zh
Un/6jrSUeg+8F8/QOK6Lxbri0il5PGQhbG+TOahj/D+HFWwbRZQ4hGa15dxHdfiGiD3v
QrdtohmIK10LlGf8yY0OFoDb4Y6tRp3FbvPHZuQlWtSUk426VHkLzV4YNb4WacyNu1MR
fJtw==
X-Gm-Message-State: AFuF++n0j399hotJUkFE2EocvJiJwtTbHiMdwes95Y9avWQDj3BP61MN
mYHm5golyMHKKzJS3MKRuQh2HqALJdtDAjSOGkstVlPz/JsOkcvPNbJr+3JSJjSn3yd1YzeOix7
SKwJumygCOvCP5Z1dpIdBaEIglCXlwsI=
X-Gm-Gg: AYBFou1/UiS6Dbc3ymBKGf+atjUy6hQHRk7i7MVZ5ptQw3c5j0JEw4rRI+18+F+Ym7q
wI9DjFlVgXLgRKd55ujrTs0KJ++os2/vwlWAC7rhnkqgZ5oKOuvBbllbF85ay2t4w4Mtveu7oT8
hdaNg1IhpzKOkJoln+vW/HcBGrynTNAImfZG8+VBhC+LS5vVaZ0jSPmQ1Dr7gRMC/ul+ntCrLui
0o3WdZjGbY+KUaywPksJdojqw0wh4QAjhNjo3ULXOTYhWyC4oFPrt47DGROLEaCfKrH2Me43amQ
TNBQ8QDl9n6aImtqwoyrJhcQS9Bjsbz4vF5eisNQ5treyR8wgP2gWrTbo9RgMZC0wRyT+Vb0sl1
c9BZqR4dOy3oFmDQ5v4D39VrFuFKsmUSsjcNufyk93RFQHyQmcty1XSNXo7D5YiRmE6X0qYyHsH
AfdVHaPlFXd48KZtcm+Ixl+cx+9GvbIw==
X-Received: by 2002:a05:6a21:110:b0:3de:61f6:4207 with SMTP id
adf61e73a8af0-3e13412d7a7mr2385878637.51.1791400236189; Wed, 07 Oct 2026
12:10:36 -0700 (PDT)
X-Precedence: bulk
X-Mailing-List: git@vger.kernel.org
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-In-Reply-To: <CACgTecOm+=vbf50tZNXhcYvRi1ZTsQwbjVoJAbQqs2CmXdJCxg@mail.gmail.com>
X-Gm-Features: AclHuK9k6eXvgnagToggcCf-6tacTTopNhYCqgfJEEVy4OqnyaRUIVq0D8UyWvY
X-Cc: git@vger.kernel.org, Siddharth Shrimali <r.siddharth.shrimali@gmail.com>