Module: Git::Commands::CatFile Private

Defined in:
lib/git/commands/cat_file.rb,
lib/git/commands/cat_file/raw.rb,
lib/git/commands/cat_file/batch.rb,
lib/git/commands/cat_file/filtered.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Commands for reading git object store content via git cat-file

This module contains command classes split by invocation protocol:

  • Raw — single object as a CLI argument; raw content, type, size, or existence check (-e, -t, -s, -p, <type>)
  • Filtered — single object as a CLI argument; content after .gitattributes filter processing (--textconv, --filters)
  • Batch — objects fed via stdin; all batch streaming modes (--batch, --batch-check, --batch-command)

Examples:

Check whether an object exists

cmd = Git::Commands::CatFile::Raw.new(lib)
result = cmd.call('HEAD', e: true)
result.status.exitstatus  # => 0 (exists) or 1 (not found)

Pretty-print a single object

cmd = Git::Commands::CatFile::Raw.new(lib)
result = cmd.call('HEAD', p: true)
result.stdout
# => "tree abc1234...\nauthor ...\n\nCommit message\n"

Fetch content after working-tree filters

cmd = Git::Commands::CatFile::Filtered.new(lib)
result = cmd.call('HEAD:README.md', filters: true)
result.stdout

Fetch metadata for several objects via batch

cmd = Git::Commands::CatFile::Batch.new(lib)
result = cmd.call('HEAD', 'v1.0', batch_check: true)
result.stdout
# => "abc1234... commit 250\nabc5678... tag 143\n"

See Also:

Defined Under Namespace

Classes: Batch, Filtered, Raw