lib/grit/git-ruby/git_object.rb in mojombo-grit-0.9.4 vs lib/grit/git-ruby/git_object.rb in mojombo-grit-1.1.1

- old
+ new

@@ -113,11 +113,11 @@ S_IFGITLINK = 0160000 attr_accessor :mode, :name, :sha1 def initialize(mode, filename, sha1o) @mode = 0 mode.each_byte do |i| - @mode = (@mode << 3) | (i-'0'[0]) + @mode = (@mode << 3) | (i-'0'.getord(0)) end @name = filename @sha1 = sha1o if ![S_IFLNK, S_IFDIR, S_IFREG, S_IFGITLINK].include?(@mode & S_IFMT) raise RuntimeError, "unknown type for directory entry" @@ -177,11 +177,17 @@ end def self.read_bytes_until(io, char) string = '' - while ((next_char = io.getc.chr) != char) && !io.eof - string += next_char + if RUBY_VERSION > '1.9' + while ((next_char = io.getc) != char) && !io.eof + string += next_char + end + else + while ((next_char = io.getc.chr) != char) && !io.eof + string += next_char + end end string end