Class: Git::Commands::CatFile::Batch Private
- Defined in:
- lib/git/commands/cat_file/batch.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
arguments block audited against https://git-scm.com/docs/git-cat-file/2.53.0
Queries one or more git objects via the batch stdin streaming protocol
Accepts object names (or commands) written to stdin. Three output modes are
available, selected by passing exactly one of batch:, batch_check:, or
batch_command: as a keyword argument:
batch: true(--batch) — for each named object, write a header line<sha> <type> <size>followed by the raw content bytes and a newline separator; missing objects are reported inline as<name> missingbatch_check: true(--batch-check) — for each named object, write one metadata line<sha> <type> <size>; missing objects as<name> missingbatch_command: true(--batch-command) — enter command-dispatch mode; stdin carries named verbs (contents <object>,info <object>,flush), allowing content and metadata requests to be interleaved in a single process
All three modes accept a format string instead of true to customise the
per-object output line (e.g. batch: "%(objectname) %(objecttype) %(objectsize)")
When batch_all_objects: true is given instead of object names, git enumerates
the entire object database itself and stdin is not read (incompatible with
batch_command:).
Missing objects never cause a non-zero exit — they are reported inline.
For single-object queries, use Raw. For filter-processed content, use Filtered.
Instance Method Summary collapse
-
#call(*objects)
private
Execute
git cat-filein batch stdin-streaming mode.
Methods inherited from Base
allow_exit_status, arguments, #initialize, requires_git_version, skip_version_validation
Constructor Details
This class inherits a constructor from Git::Commands::Base
Instance Method Details
#call(*objects, batch: true, **options) ⇒ Git::CommandLineResult #call(*objects, batch_check: true, **options) ⇒ Git::CommandLineResult #call(*objects, batch_command: true, **options) ⇒ Git::CommandLineResult #call(batch_all_objects: true, batch: true, **options) ⇒ Git::CommandLineResult #call(batch_all_objects: true, batch_check: true, **options) ⇒ Git::CommandLineResult
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Execute git cat-file in batch stdin-streaming mode.
Exactly one of batch:, batch_check:, or batch_command: must be selected.
Pass batch_all_objects: true instead of object names to enumerate the entire
object database without reading stdin.
312 313 314 315 316 317 318 319 320 |
# File 'lib/git/commands/cat_file/batch.rb', line 312 def call(*objects, **) bound = args_definition.bind(*objects, **) validate_version! # `-Z` puts git into NUL I/O mode: input objects must be NUL-terminated. # Without `-Z`, the standard newline delimiter is used. delimiter = bound.Z? ? "\0" : "\n" stdin = Array(bound.object).map { |o| "#{o}#{delimiter}" }.join with_stdin(stdin) { |reader| run_batch(bound, reader) } end |