Re: [PATCH 1/9] pack-objects: allow `--filter` without `--stdout`
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Jul 5, 2023, 06:16 UTC
- Message-ID
- <CAP8UFD2=7AJfw4hyhFttqDOFQ+1TxRq5JpUNEpKsGk4b3VJ+HQ@mail.gmail.com>
- In-Reply-To
- <ZJLVzaQKBrgCARAG@nand.local>
On Wed, Jun 21, 2023 at 12:49 PM Taylor Blau <me@ttaylorr.com> wrote:
Show 23 quoted lines
> > On Wed, Jun 14, 2023 at 09:25:33PM +0200, Christian Couder wrote: > > 9535ce7337 (pack-objects: add list-objects filtering, 2017-11-21) > > taught `git pack-objects` to use `--filter`, but required the use of > > `--stdout` since a partial clone mechanism was not yet in place to > > handle missing objects. Since then, changes like 9e27beaa23 > > (promisor-remote: implement promisor_remote_get_direct(), 2019-06-25) > > and others added support to dynamically fetch objects that were missing. > > > > Even without a promisor remote, filtering out objects can also be useful > > if we can put the filtered out objects in a separate pack, and in this > > case it also makes sense for pack-objects to write the packfile directly > > to an actual file rather than on stdout. > > > > Remove the `--stdout` requirement when using `--filter`, so that in a > > follow-up commit, repack can pass `--filter` to pack-objects to omit > > certain objects from the resulting packfile. > > Makes sense. > > Is there any situation in which using --stdout with --filter would be a > potential foot-gun? I am not as familiar with the partial clone > mechanism as others CC'd, so I have no idea one way or the other.
This patch allows `--filter` without `--stdout`, so `--stdout` with `--filter` was already allowed before this patch and is still allowed after it.
Besides, using `--stdout` or not using it is just a convenience. It doesn't change much what users can do with `git pack-objects`.
Show 5 quoted lines
> If it is unsafe in certain situations (or, at the very least, could > produce surprising behavior), it may be worthwhile to only allow > `--filter=<filter> --stdout` with some kind of > `--filter-to-stdout-is-ok` flag to indicate that the caller knows what > they are doing.
`git pack-objects` with `--filter` can be unsafe in some cases if users do stupid things with packfiles afterwards, but allowing it to run without --stdout doesn't significantly change that. In any case by itself it doesn't delete any data. It just creates a pack containing fewer objects.
Anyway I added a small test that checks that --filter can be used without --stdout.