Skip to content

Commit 6cfcabf

Browse files
chriscoolgitster
authored andcommitted
pack-objects: allow --filter without --stdout
9535ce7 (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 9e27bea (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. Signed-off-by: John Cai <[email protected]> Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bcb6cae commit 6cfcabf

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

Documentation/git-pack-objects.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle.
296296
nevertheless.
297297

298298
--filter=<filter-spec>::
299-
Requires `--stdout`. Omits certain objects (usually blobs) from
300-
the resulting packfile. See linkgit:git-rev-list[1] for valid
299+
Omits certain objects (usually blobs) from the resulting
300+
packfile. See linkgit:git-rev-list[1] for valid
301301
`<filter-spec>` forms.
302302

303303
--no-filter::

builtin/pack-objects.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4402,12 +4402,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
44024402
if (!rev_list_all || !rev_list_reflog || !rev_list_index)
44034403
unpack_unreachable_expiration = 0;
44044404

4405-
if (filter_options.choice) {
4406-
if (!pack_to_stdout)
4407-
die(_("cannot use --filter without --stdout"));
4408-
if (stdin_packs)
4409-
die(_("cannot use --filter with --stdin-packs"));
4410-
}
4405+
if (stdin_packs && filter_options.choice)
4406+
die(_("cannot use --filter with --stdin-packs"));
44114407

44124408
if (stdin_packs && use_internal_rev_list)
44134409
die(_("cannot use internal rev list with --stdin-packs"));

t/t5317-pack-objects-filter-objects.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ test_expect_success 'verify blob:none packfile has no blobs' '
5353
! grep blob verify_result
5454
'
5555

56+
test_expect_success 'verify blob:none packfile without --stdout' '
57+
git -C r1 pack-objects --revs --filter=blob:none mypackname >packhash <<-EOF &&
58+
HEAD
59+
EOF
60+
git -C r1 verify-pack -v "mypackname-$(cat packhash).pack" >verify_result &&
61+
! grep blob verify_result
62+
'
63+
5664
test_expect_success 'verify normal and blob:none packfiles have same commits/trees' '
5765
git -C r1 verify-pack -v ../all.pack >verify_result &&
5866
grep -E "commit|tree" verify_result |

0 commit comments

Comments
 (0)