@@ -33,7 +33,8 @@ Git.prototype.git = function(/* command, args, options, callback */)
33
33
var child = spawn ( "git" , gitargs , { cwd : options . cwd , env : options . env } ) ;
34
34
35
35
child . stderr . setEncoding ( 'utf8' ) ;
36
- child . stdout . setEncoding ( options . encoding ) ;
36
+ if ( options . encoding )
37
+ child . stdout . setEncoding ( options . encoding ) ;
37
38
38
39
if ( callback ) {
39
40
var called = false ;
@@ -219,3 +220,38 @@ Git.prototype.commit = function(/* message, options, callback */) {
219
220
] , callback ) ;
220
221
} ;
221
222
223
+ Git . prototype . _cat_file = function ( /* sha, type, options, callback */ ) {
224
+ var object , type = "-p" , options = { } , callback ;
225
+ var args = Array . prototype . slice . call ( arguments ) ;
226
+
227
+ object = args . shift ( ) ;
228
+ if ( typeof args [ 0 ] === "string" )
229
+ type = args . shift ( ) ;
230
+ if ( typeof args [ 0 ] === "object" )
231
+ options = args . shift ( ) ;
232
+
233
+ callback = args . shift ( ) ;
234
+
235
+ var bufs = [ ] ;
236
+
237
+ var child = this . git ( "cat-file" , type , object , { encoding : options . encoding } , callback ) ;
238
+ return child . stdout ;
239
+ } ;
240
+
241
+ Git . prototype . cat_file = function ( /* sha, type, options, callback */ ) {
242
+ var data = [ ] ;
243
+
244
+ var callback = arguments [ arguments . length - 1 ] ;
245
+ arguments [ arguments . length - 1 ] = function ( err ) {
246
+ callback ( err , err ? null : data . join ( "" ) ) ;
247
+ } ;
248
+
249
+ var stdout = this . _cat_file . apply ( this , arguments )
250
+
251
+ stdout . on ( 'data' , function ( d ) {
252
+ data . push ( d ) ;
253
+ } ) ;
254
+ }
255
+
256
+ module . exports = Git ;
257
+
0 commit comments