Pretty awesome. And the select(2) based implementation will fix a
long-standing bug where the grit process will hang when a git
process writes more than PIPE_BUF bytes to stderr or when the input
written to the git process's stdin exceeds PIPE_BUF. The old popen3
based logic writes all of stdin, then reads all of stdout, then
reads all of stderr so everything except stdout had to come in under
PIPE_BUF. This hasn't been much of an issue but is critical to our
plans on using `git cat-file --batch' and writing a bunch of SHA1s
on stdin.
Also moving toward using a common spawn method interface that's a
compatible subset of the Process.spawn method built into Ruby >=
1.9.1. The hope is that most non-MRI platforms will eventually
support Process.spawn out of the box and the ones that don't have
backports.
Strings have changed significantly in Ruby 1.9. The main issues related
to Grit are encodings, and the [] method. The GitRuby implementation
currently uses code such as "buf[offset]" to access a byte (1 uint8_t byte in C)
of data. It would be nice to just use String#getbyte(offset), but this method is not
sensitive to the string encoding. The default encoding for Ruby strings
is UTF-8, and I can't figure out how to make sure that all of the encodings
are correct such that String#getbyte will return the right value.
In Ruby 1.8, String[offset] returns the integer code of the character at offset.
In Ruby 1.9, String[offset] returns the actual character at offset. To get the integer
value, we need to call String#ord, which returns the int code of the first char.
Thus, to get Ruby 1.8 behavior in Ruby 1.9, we would need to call String[offset].ord.
My solution for now is just to define a getord(offset) method in a version dependent
manner, and use this in place of String[offset]. It's somewhat hackish, but
I can't think of a better solution right now.