module Git::CommandLine
Namespace module for git command-line execution strategies
This module groups the classes responsible for invoking git subprocesses and handling their output. Choose a concrete class based on your buffering needs:
-
{Git::CommandLine::Capturing} β buffers stdout and stderr in memory. Use this for the vast majority of git commands whose output fits in memory.
-
{Git::CommandLine::Streaming} β streams stdout to a caller-supplied IO. Use this for commands (e.g. βcat-file -p <blob>`) whose output may be too large to buffer.
Both classes inherit from {Git::CommandLine::Base} and are used internally by {Git::ExecutionContext#command_capturing} and {Git::ExecutionContext#command_streaming}.
Results are returned as {Git::CommandLine::Result} objects (also accessible as {Git::CommandLine::Result} for backward compatibility).
@example Buffered command via Git::CommandLine::Capturing
cli = Git::CommandLine::Capturing.new( {}, '/usr/bin/git', [], Logger.new(nil) ) result = cli.run('version') result.stdout #=> "git version 2.39.1\n"
@example Streaming command via Git::CommandLine::Streaming
cli = Git::CommandLine::Streaming.new( {}, '/usr/bin/git', [], Logger.new(nil) ) File.open('/tmp/blob', 'wb') do |f| cli.run('cat-file', 'blob', sha, out: f) end
@api private