You have now (May 2021, seven years later) a much more precise filtering mechanism with Git 2.32 (Q2 2021): "git rev-list
"(man) learns the --filter=object:type=<type>
option, which can be used to exclude objects of the given kind from the packfile generated by pack-objects.
See commit 9cf68b2, commit 169a15e, commit 7ab6aaf, commit b0c42a5 (19 Apr 2021), commit 9a2a4f9 (12 Apr 2021), and commit 628d81b, commit b2025da, commit a812789 (09 Apr 2021) by Patrick Steinhardt (pks-t
).
(Merged by Junio C Hamano -- gitster
-- in commit 8585d6c, 07 May 2021)
list-objects
: implement object type filter
Signed-off-by: Patrick Steinhardt
While it already is possible to filter objects by some criteria in git-rev-list
, it is not yet possible to filter out only a specific type of objects.
This makes some filters less useful.
The blob:limit
filter for example filters blobs such that only those which are smaller than the given limit are returned.
But it is unfit to ask only for these smallish blobs, given that git-rev-list
will continue to print tags, commits and trees.
Now that we have the infrastructure in place to also filter tags and commits, we can improve this situation by implementing a new filter which selects objects based on their type.
Above query can thus trivially be implemented with the following command:
$ git rev-list --objects --filter=object:type=blob \
--filter=blob:limit=200
Furthermore, this filter allows to optimize for certain other cases: if for example only tags or commits have been selected, there is no need to walk down trees.
The new filter is not yet supported in bitmaps.
This is going to be implemented in a subsequent commit.
git config
now includes in its man page:
blob:limit
, object:type
, tree
, sparse:oid
, or combine
.
If using combined filters, both combine
and all of the nested
filter kinds must be allowed. Defaults to uploadpackfilter.allow
.
rev-list-options
now includes in its man page:
The form '--filter=object:type=(tag|commit|tree|blob)
' omits all objects
which are not of the requested type.
And:
rev-list
: allow filtering of provided items
Signed-off-by: Patrick Steinhardt
When providing an object filter, it is currently impossible to also filter provided items.
E.g.
when executing git rev-list
(man) HEAD , the commit this reference points to will be treated as user-provided and is thus excluded from the filtering mechanism.
This makes it harder than necessary to properly use the new --filter=object:type
filter given that even if the user wants to only see blobs, he'll still see commits of provided references.
Improve this by introducing a new --filter-provided-objects
option to the git-rev-parse(1) command.
If given, then all user-provided references will be subject to filtering.
rev-list-options
now includes in its man page:
--filter-provided-objects
Filter the list of explicitly provided objects, which would otherwise
always be printed even if they did not match any of the filters. Only
useful with --filter=
.