Create a gist now

Instantly share code, notes, and snippets.

*** ./lib/grit/index.rb.org 2013-10-22 12:56:48.654590275 +0900
--- ./lib/grit/index.rb 2013-10-23 13:17:49.316559983 +0900
***************
*** 173,179 ****
k = obj.name
k += '/' if (obj.class == Grit::Tree)
tmode = obj.mode.to_i.to_s ## remove zero-padding
! tree_contents[k] = "%s %s\0%s" % [tmode, obj.name, sha]
end if now_tree
# overwrite with new tree contents
--- 173,179 ----
k = obj.name
k += '/' if (obj.class == Grit::Tree)
tmode = obj.mode.to_i.to_s ## remove zero-padding
! tree_contents[k] = "%s %s\0%s" % [tmode, obj.name, sha.force_encoding("utf-8")]
end if now_tree
# overwrite with new tree contents
***************
*** 182,210 ****
when Array
sha, mode = v
if sha.size == 40 # must be a sha
! sha = [sha].pack("H*")
! mode = mode.to_i.to_s # leading 0s not allowed
! k = k.split('/').last # slashes not allowed
str = "%s %s\0%s" % [mode, k, sha]
tree_contents[k] = str
end
when String
sha = write_blob(v)
! sha = [sha].pack("H*")
! str = "%s %s\0%s" % ['100644', k, sha]
tree_contents[k] = str
when Hash
ctree = now_tree/k if now_tree
sha = write_tree(v, ctree)
! sha = [sha].pack("H*")
! str = "%s %s\0%s" % ['40000', k, sha]
tree_contents[k + '/'] = str
when false
tree_contents.delete(k)
end
end
! tr = tree_contents.sort.map { |k, v| v }.join('')
@last_tree_size = tr.size
self.repo.git.put_raw_object(tr, 'tree')
end
--- 182,210 ----
when Array
sha, mode = v
if sha.size == 40 # must be a sha
! sha = [sha].pack("H*").force_encoding('utf-8')
! mode = mode.to_i.to_s.force_encoding('utf-8') # leading 0s not allowed
! k = k.split('/').last.force_encoding('utf-8') # slashes not allowed
str = "%s %s\0%s" % [mode, k, sha]
tree_contents[k] = str
end
when String
sha = write_blob(v)
! sha = [sha].pack("H*").force_encoding('utf-8')
! str = "%s %s\0%s" % ['100644'.force_encoding('utf-8'), k, sha]
tree_contents[k] = str
when Hash
ctree = now_tree/k if now_tree
sha = write_tree(v, ctree)
! sha = [sha].pack("H*").force_encoding('utf-8')
! str = "%s %s\0%s" % ['40000'.force_encoding('utf-8'), k, sha]
tree_contents[k + '/'] = str
when false
tree_contents.delete(k)
end
end
! tr = tree_contents.sort.map { |k, v| v.force_encoding("utf-8") }.join('')
@last_tree_size = tr.size
self.repo.git.put_raw_object(tr, 'tree')
end
*** ./lib/grit/git.rb.org Thu Feb 27 01:44:37 2014
--- ./lib/grit/git.rb Thu Feb 27 02:22:01 2014
***************
*** 351,359 ****
if raise_errors && !status.success?
raise CommandFailed.new(argv.join(' '), status.exitstatus, process.err)
elsif process_info
! [status.exitstatus, process.out, process.err]
else
! process.out
end
rescue TimeoutExceeded, MaximumOutputExceeded
raise GitTimeout, argv.join(' ')
--- 352,360 ----
if raise_errors && !status.success?
raise CommandFailed.new(argv.join(' '), status.exitstatus, process.err)
elsif process_info
! [status.exitstatus, process.out.force_encoding('utf-8'), process.err]
else
! process.out.force_encoding('utf-8')
end
rescue TimeoutExceeded, MaximumOutputExceeded
raise GitTimeout, argv.join(' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment