Class: Amp::Core::Repositories::Git::Encoding::BinaryDelta::InsertHunk

Inherits:
Object
  • Object
show all
Defined in:
lib/amp-git/encoding/binary_delta.rb

Overview

A Hunk that performs an insert operation. One of two types of delta hunks in the git binary delta format.

Instance Method Summary collapse

Constructor Details

#initialize(opcode, fp) ⇒ InsertHunk

Creates a new insert hunk.

Parameters:

  • opcode (Fixnum)

    the opcode that identifies this hunk’s properties.

  • fp (IO, #read)

    the input stream we’re reading this delta from



117
118
119
# File 'lib/amp-git/encoding/binary_delta.rb', line 117

def initialize(opcode, fp)
  @data = fp.read(opcode & 0x7f)
end

Instance Method Details

#apply(output, input) ⇒ Object

Applies the Hunk with a given output buffer with an input string.

Parameters:

  • output (IO, #write)

    the output buffer we’re building up

  • input (String)

    the original data. ignored for InsertHunk.



126
127
128
# File 'lib/amp-git/encoding/binary_delta.rb', line 126

def apply(output, input)
  output.write @data
end