Module: Amp::Core::Repositories::Git::Index
- Defined in:
- lib/amp-git/repo_format/index.rb
Overview
Index
The Index is essentially a cache of the working directory. It tracks which files have been added to the staging area and which have not, and can be used to check if a file has been modified or not. It is a relatively complex binary format and there are two versions of it we also have to support.
Defined Under Namespace
Classes: AbstractIndex, IndexEntry, IndexParseError, IndexVersion1, IndexVersion2
Class Method Summary collapse
-
.parse(file, opener) ⇒ AbstractIndex
Parses the given file as an Index, and returns the appropriate subclass of Index.
Class Method Details
.parse(file, opener) ⇒ AbstractIndex
Parses the given file as an Index, and returns the appropriate subclass of Index. There are two versions that are supported and each needs to be able to handle status lookups and so on.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/amp-git/repo_format/index.rb', line 47 def self.parse(file, opener) opener.open(file, "r") do |fp| if fp.read(4) != "DIRC" raise IndexParseError.new("#{file} is not an index file.") end version = fp.read(4).unpack("N").first case version when 1 IndexVersion1.new(fp) when 2 IndexVersion2.new(fp) end end end |