class GitObjectBrowser::Models::IndexEntry
Attributes
assume_valid_flag[R]
cnano[R]
ctime[R]
dev[R]
extended_flag[R]
gid[R]
ino[R]
intent_to_add[R]
mnano[R]
mtime[R]
name_length[R]
object_type[R]
path[R]
sha1[R]
size[R]
skip_worktree[R]
stage[R]
uid[R]
unix_permission[R]
version[R]
Public Class Methods
new(input, version, last_path = nil)
click to toggle source
Calls superclass method
GitObjectBrowser::Models::Bindata::new
# File lib/git-object-browser/models/index_entry.rb, line 14 def initialize(input, version, last_path = nil) super(input) @version = version @last_path = last_path parse end
Public Instance Methods
parse()
click to toggle source
# File lib/git-object-browser/models/index_entry.rb, line 21 def parse @ctime = int # 4 @cnano = int # 8 @mtime = int # 12 @mnano = int # 16 @dev = int # 20 @ino = int # 24 parse_mode # 28 @uid = int # 32 @gid = int # 36 @size = int # 40 @sha1 = hex(20) # 60 parse_flags # 62 (+2) parse_path end
to_hash()
click to toggle source
# File lib/git-object-browser/models/index_entry.rb, line 103 def to_hash return { :ctime => @ctime, :cnano => @cnano, :mtime => @mtime, :mnano => @mnano, :dev => @dev, :ino => @ino, :object_type => @object_type, :unix_permission => @unix_permission, :uid => @uid, :gid => @gid, :size => @size, :sha1 => @sha1, :path => @path, :assume_valid_flag => @assume_valid_flag, :extended_flag => @extended_flag, :stage => @stage, :skip_worktree => @skip_worktree, :intent_to_add => @intent_to_add, :name_length => @name_length, } end
Private Instance Methods
parse_chop_size()
click to toggle source
# File lib/git-object-browser/models/index_entry.rb, line 89 def parse_chop_size value = -1 value_size = 0 begin b = byte value_size += 1 continue = b & 0b10000000 low_value = b & 0b01111111 value = ((value + 1) << 7) | low_value end while continue != 0 return [value, value_size] end
parse_flags()
click to toggle source
# File lib/git-object-browser/models/index_entry.rb, line 45 def parse_flags flags = binstr(2) @assume_valid_flag = flags[0..0].to_i @extended_flag = flags[1..1].to_i @stage = flags[2..3] @name_length = ["0000" + flags[4..15]].pack("B*").unpack("n")[0] if @version > 2 && @extended_flag == 1 extended = binstr(2) reserved = extended[0..0] @skip_worktree = extended[1..1] @intent_to_add = extended[2..2] end end
parse_mode()
click to toggle source
# File lib/git-object-browser/models/index_entry.rb, line 37 def parse_mode mode = binstr(4) @object_type = mode[16..19] unused = mode[20..22] @unix_permission = sprintf('%o', mode[23..31].to_i(2)) end
parse_path()
click to toggle source
# File lib/git-object-browser/models/index_entry.rb, line 60 def parse_path if @version == 2 || @version == 3 parse_path_v2 elsif @version == 4 parse_path_v4 end end
parse_path_v2()
click to toggle source
path: 2 + 8 * n bytes (nul pannding)
# File lib/git-object-browser/models/index_entry.rb, line 70 def parse_path_v2 token = raw(@extended_flag == 1 ? 8 : 2) @path = "" begin @path += token.unpack("Z*").first break if token.unpack("C*").last == 0 end while(token = raw(8)) end
parse_path_v4()
click to toggle source
# File lib/git-object-browser/models/index_entry.rb, line 80 def parse_path_v4 (chop_size, _) = parse_chop_size() @path = find_char("\0") if chop_size > 0 @path = @last_path[0 .. chop_size * -1 - 1] + @path end end