Class: Amp::Core::Repositories::Git::Index::IndexEntry
- Inherits:
-
Struct
- Object
- Struct
- Amp::Core::Repositories::Git::Index::IndexEntry
- Defined in:
- lib/amp-git/repo_format/index.rb
Overview
The format of each index entry is as follows:
create_time, 32-bits # in seconds, least-significant bits if rollover
create_time_nanoseconds, 32-bits
modify_time, 32-bits # in seconds, least-significant bits if rollover
modify_time_nanoseconds, 32-bits
device, 32-bits # device id
inode, 32-bits # inode from the filesystem
mode, 32-bits # permissions/mode from the FS
uid, 32-bits # user ID from the FS
gid, 32-bits # group ID from the FS
size, 32-bits # filesize, least-significant-bits, from FS
hash_id, 20 bytes # sha-1 hash of the data
assume_valid, 1 bit # flag for whether this file should be assumed to be unchanged
update_needed, 1 bit # flag saying the file needs to be refreshed
stage, 2 bits # two flags used for merging
filename_size, 12 bits # the size of the upcoming filename in bytes
filename, N bytes # the name of the file in the index
padding, N bytes # null padding. At least 1 byte, enough to make the block's size a
multiple of 8 bytes
This class is a big effing struct for this.
Constant Summary collapse
- ENTRY_HEADER_FORMAT =
"NNNNNNNNNNa20n"
- ENTRY_HEADER_SIZE =
62
Instance Attribute Summary collapse
-
#assume_valid ⇒ Object
Returns the value of attribute assume_valid.
-
#ctime ⇒ Object
Returns the value of attribute ctime.
-
#ctime_ns ⇒ Object
Returns the value of attribute ctime_ns.
-
#dev ⇒ Object
Returns the value of attribute dev.
-
#gid ⇒ Object
Returns the value of attribute gid.
-
#hash_id ⇒ Object
Returns the value of attribute hash_id.
-
#inode ⇒ Object
Returns the value of attribute inode.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#mtime ⇒ Object
Returns the value of attribute mtime.
-
#mtime_ns ⇒ Object
Returns the value of attribute mtime_ns.
-
#name ⇒ Object
Returns the value of attribute name.
-
#size ⇒ Object
Returns the value of attribute size.
-
#stage ⇒ Object
Returns the value of attribute stage.
-
#uid ⇒ Object
Returns the value of attribute uid.
-
#update_needed ⇒ Object
Returns the value of attribute update_needed.
Instance Method Summary collapse
-
#initialize(*args) ⇒ IndexEntry
constructor
A new instance of IndexEntry.
Constructor Details
#initialize(*args) ⇒ IndexEntry
Returns a new instance of IndexEntry.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/amp-git/repo_format/index.rb', line 88 def initialize(*args) if args.size > 0 && args[0].kind_of?(IO) fp = args.first header = fp.read(ENTRY_HEADER_SIZE).unpack(ENTRY_HEADER_FORMAT) self.ctime, self.ctime_ns, self.mtime, self.mtime_ns, self.dev, self.inode, self.mode, self.uid, self.gid, self.size, self.hash_id, flags = header self.hash_id = NodeId.from_bin(self.hash_id) self.assume_valid = flags & 0x8000 > 0 self.update_needed = flags & 0x4000 > 0 self.stage = (flags & 0x3000) >> 12 namesize = flags & 0x0FFF self.name = fp.read(namesize) mod = (ENTRY_HEADER_SIZE + namesize) & 0x7 padding_len = mod == 0 ? 8 : 8 - mod fp.read(padding_len) else super end end |
Instance Attribute Details
#assume_valid ⇒ Object
Returns the value of attribute assume_valid
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def assume_valid @assume_valid end |
#ctime ⇒ Object
Returns the value of attribute ctime
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def ctime @ctime end |
#ctime_ns ⇒ Object
Returns the value of attribute ctime_ns
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def ctime_ns @ctime_ns end |
#dev ⇒ Object
Returns the value of attribute dev
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def dev @dev end |
#gid ⇒ Object
Returns the value of attribute gid
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def gid @gid end |
#hash_id ⇒ Object
Returns the value of attribute hash_id
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def hash_id @hash_id end |
#inode ⇒ Object
Returns the value of attribute inode
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def inode @inode end |
#mode ⇒ Object
Returns the value of attribute mode
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def mode @mode end |
#mtime ⇒ Object
Returns the value of attribute mtime
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def mtime @mtime end |
#mtime_ns ⇒ Object
Returns the value of attribute mtime_ns
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def mtime_ns @mtime_ns end |
#name ⇒ Object
Returns the value of attribute name
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def name @name end |
#size ⇒ Object
Returns the value of attribute size
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def size @size end |
#stage ⇒ Object
Returns the value of attribute stage
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def stage @stage end |
#uid ⇒ Object
Returns the value of attribute uid
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def uid @uid end |
#update_needed ⇒ Object
Returns the value of attribute update_needed
84 85 86 |
# File 'lib/amp-git/repo_format/index.rb', line 84 def update_needed @update_needed end |