@@ -1502,15 +1502,6 @@ static VALUE flags_to_rb(unsigned int flags)
1502
1502
return rb_flags ;
1503
1503
}
1504
1504
1505
- static int rugged__status_cb (const char * path , unsigned int flags , void * payload )
1506
- {
1507
- rb_funcall ((VALUE )payload , rb_intern ("call" ), 2 ,
1508
- rb_str_new_utf8 (path ), flags_to_rb (flags )
1509
- );
1510
-
1511
- return GIT_OK ;
1512
- }
1513
-
1514
1505
static VALUE rb_git_repo_file_status (VALUE self , VALUE rb_path )
1515
1506
{
1516
1507
unsigned int flags ;
@@ -1527,8 +1518,10 @@ static VALUE rb_git_repo_file_status(VALUE self, VALUE rb_path)
1527
1518
1528
1519
static VALUE rb_git_repo_file_each_status (VALUE self )
1529
1520
{
1530
- int error ;
1521
+ int error , exception ;
1522
+ size_t i , nentries ;
1531
1523
git_repository * repo ;
1524
+ git_status_list * list ;
1532
1525
1533
1526
Data_Get_Struct (self , git_repository , repo );
1534
1527
@@ -1537,13 +1530,30 @@ static VALUE rb_git_repo_file_each_status(VALUE self)
1537
1530
"A block was expected for iterating through "
1538
1531
"the repository contents." );
1539
1532
1540
- error = git_status_foreach (
1541
- repo ,
1542
- & rugged__status_cb ,
1543
- (void * )rb_block_proc ()
1544
- );
1545
-
1533
+ error = git_status_list_new (& list , repo , NULL );
1546
1534
rugged_exception_check (error );
1535
+
1536
+ nentries = git_status_list_entrycount (list );
1537
+ for (i = 0 ; i < nentries ; i ++ ) {
1538
+ const git_status_entry * entry ;
1539
+ const char * path ;
1540
+ VALUE args ;
1541
+
1542
+ entry = git_status_byindex (list , i );
1543
+
1544
+ path = entry -> head_to_index ?
1545
+ entry -> head_to_index -> old_file .path :
1546
+ entry -> index_to_workdir -> old_file .path ;
1547
+ args = rb_ary_new3 (2 , rb_str_new_utf8 (path ), flags_to_rb (entry -> status ));
1548
+ rb_protect (rb_yield , args , & exception );
1549
+ if (exception != 0 )
1550
+ break ;
1551
+ }
1552
+ git_status_list_free (list );
1553
+
1554
+ if (exception != 0 )
1555
+ rb_jump_tag (exception );
1556
+
1547
1557
return Qnil ;
1548
1558
}
1549
1559
0 commit comments