Skip to content

Commit a271b05

Browse files
committed
Merge branch 'ps/cat-file-filter-batch'
"git cat-file --batch" and friends learned to allow "--filter=" to omit certain objects, just like the transport layer does. * ps/cat-file-filter-batch: builtin/cat-file: use bitmaps to efficiently filter by object type builtin/cat-file: deduplicate logic to iterate over all objects pack-bitmap: introduce function to check whether a pack is bitmapped pack-bitmap: add function to iterate over filtered bitmapped objects pack-bitmap: allow passing payloads to `show_reachable_fn()` builtin/cat-file: support "object:type=" objects filter builtin/cat-file: support "blob:limit=" objects filter builtin/cat-file: support "blob:none" objects filter builtin/cat-file: wire up an option to filter objects builtin/cat-file: introduce function to report object status builtin/cat-file: rename variable that tracks usage
2 parents 9bdd7ec + 8002e8e commit a271b05

File tree

8 files changed

+411
-82
lines changed

8 files changed

+411
-82
lines changed

Documentation/git-cat-file.adoc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,25 @@ OPTIONS
8181
end-of-line conversion, etc). In this case, `<object>` has to be of
8282
the form `<tree-ish>:<path>`, or `:<path>`.
8383

84+
--filter=<filter-spec>::
85+
--no-filter::
86+
Omit objects from the list of printed objects. This can only be used in
87+
combination with one of the batched modes. Excluded objects that have
88+
been explicitly requested via any of the batch modes that read objects
89+
via standard input (`--batch`, `--batch-check`) will be reported as
90+
"filtered". Excluded objects in `--batch-all-objects` mode will not be
91+
printed at all. The '<filter-spec>' may be one of the following:
92+
+
93+
The form '--filter=blob:none' omits all blobs.
94+
+
95+
The form '--filter=blob:limit=<n>[kmg]' omits blobs of size at least n
96+
bytes or units. n may be zero. The suffixes k, m, and g can be used to name
97+
units in KiB, MiB, or GiB. For example, 'blob:limit=1k' is the same as
98+
'blob:limit=1024'.
99+
+
100+
The form '--filter=object:type=(tag|commit|tree|blob)' omits all objects which
101+
are not of the requested type.
102+
84103
--path=<path>::
85104
For use with `--textconv` or `--filters`, to allow specifying an object
86105
name and a path separately, e.g. when it is difficult to figure out
@@ -340,6 +359,13 @@ the repository, then `cat-file` will ignore any custom format and print:
340359
<object> SP missing LF
341360
------------
342361

362+
If a name is specified on stdin that is filtered out via `--filter=`,
363+
then `cat-file` will ignore any custom format and print:
364+
365+
------------
366+
<object> SP excluded LF
367+
------------
368+
343369
If a name is specified that might refer to more than one object (an ambiguous short sha), then `cat-file` will ignore any custom format and print:
344370

345371
------------

0 commit comments

Comments
 (0)