@@ -275,6 +275,7 @@ static VALUE rb_git_diff_patch_lines(int argc, VALUE *argv, VALUE self)
275
275
276
276
return INT2FIX (lines );
277
277
}
278
+
278
279
/*
279
280
* call-seq:
280
281
* patch.bytesize(options = {}) -> int
@@ -332,16 +333,16 @@ static int patch_print_cb(
332
333
const git_diff_line * line ,
333
334
void * payload )
334
335
{
335
- VALUE rb_str = (VALUE )payload ;
336
+ VALUE rb_buffer = (VALUE )payload ;
336
337
337
338
switch (line -> origin ) {
338
339
case GIT_DIFF_LINE_CONTEXT :
339
340
case GIT_DIFF_LINE_ADDITION :
340
341
case GIT_DIFF_LINE_DELETION :
341
- rb_str_cat ( rb_str , & line -> origin , 1 );
342
+ rb_ary_push ( rb_buffer , rb_str_new ( & line -> origin , 1 ) );
342
343
}
343
344
344
- rb_str_cat ( rb_str , line -> content , line -> content_len );
345
+ rb_ary_push ( rb_buffer , rb_str_new ( line -> content , line -> content_len ) );
345
346
346
347
return GIT_OK ;
347
348
}
@@ -352,16 +353,15 @@ static int patch_print_header_cb(
352
353
const git_diff_line * line ,
353
354
void * payload )
354
355
{
355
- VALUE rb_str = (VALUE )payload ;
356
+ VALUE rb_buffer = (VALUE )payload ;
356
357
357
358
if (line -> origin == GIT_DIFF_LINE_FILE_HDR ) {
358
- rb_str_cat ( rb_str , line -> content , line -> content_len );
359
+ rb_ary_push ( rb_buffer , rb_str_new ( line -> content , line -> content_len ) );
359
360
}
360
361
361
362
return GIT_OK ;
362
363
}
363
364
364
-
365
365
/*
366
366
* call-seq:
367
367
* patch.to_s -> str
@@ -371,12 +371,12 @@ static int patch_print_header_cb(
371
371
static VALUE rb_git_diff_patch_to_s (VALUE self )
372
372
{
373
373
git_patch * patch ;
374
- VALUE rb_str = rb_str_new ( NULL , 0 );
374
+ VALUE rb_buffer = rb_ary_new ( );
375
375
Data_Get_Struct (self , git_patch , patch );
376
376
377
- rugged_exception_check (git_patch_print (patch , patch_print_cb , (void * )rb_str ));
377
+ rugged_exception_check (git_patch_print (patch , patch_print_cb , (void * )rb_buffer ));
378
378
379
- return rb_str ;
379
+ return rb_ary_join ( rb_buffer , Qnil ) ;
380
380
}
381
381
382
382
/*
@@ -388,12 +388,12 @@ static VALUE rb_git_diff_patch_to_s(VALUE self)
388
388
static VALUE rb_git_diff_patch_header (VALUE self )
389
389
{
390
390
git_patch * patch ;
391
- VALUE rb_str = rb_str_new ( NULL , 0 );
391
+ VALUE rb_buffer = rb_ary_new ( );
392
392
Data_Get_Struct (self , git_patch , patch );
393
393
394
- rugged_exception_check (git_patch_print (patch , patch_print_header_cb , (void * )rb_str ));
394
+ rugged_exception_check (git_patch_print (patch , patch_print_header_cb , (void * )rb_buffer ));
395
395
396
- return rb_str ;
396
+ return rb_ary_join ( rb_buffer , Qnil ) ;
397
397
}
398
398
399
399
0 commit comments