@@ -1511,58 +1511,26 @@ static int rugged__status_cb(const char *path, unsigned int flags, void *payload
1511
1511
return GIT_OK ;
1512
1512
}
1513
1513
1514
- /*
1515
- * call-seq:
1516
- * repo.status { |file, status_data| block }
1517
- * repo.status(path) -> status_data
1518
- *
1519
- * Returns the status for one or more files in the working directory
1520
- * of the repository. This is equivalent to the +git status+ command.
1521
- *
1522
- * The returned +status_data+ is always an array containing one or more
1523
- * status flags as Ruby symbols. Possible flags are:
1524
- *
1525
- * - +:index_new+: the file is new in the index
1526
- * - +:index_modified+: the file has been modified in the index
1527
- * - +:index_deleted+: the file has been deleted from the index
1528
- * - +:worktree_new+: the file is new in the working directory
1529
- * - +:worktree_modified+: the file has been modified in the working directory
1530
- * - +:worktree_deleted+: the file has been deleted from the working directory
1531
- *
1532
- * If a +block+ is given, status information will be gathered for every
1533
- * single file on the working dir. The +block+ will be called with the
1534
- * status data for each file.
1535
- *
1536
- * repo.status { |file, status_data| puts "#{file} has status: #{status_data.inspect}" }
1537
- *
1538
- * results in, for example:
1539
- *
1540
- * src/diff.c has status: [:index_new, :worktree_new]
1541
- * README has status: [:worktree_modified]
1542
- *
1543
- * If a +path+ is given instead, the function will return the +status_data+ for
1544
- * the file pointed to by path, or raise an exception if the path doesn't exist.
1545
- *
1546
- * +path+ must be relative to the repository's working directory.
1547
- *
1548
- * repo.status('src/diff.c') #=> [:index_new, :worktree_new]
1549
- */
1550
- static VALUE rb_git_repo_status (int argc , VALUE * argv , VALUE self )
1514
+ static VALUE rb_git_repo_file_status (VALUE self , VALUE rb_path )
1551
1515
{
1516
+ unsigned int flags ;
1552
1517
int error ;
1553
- VALUE rb_path ;
1554
1518
git_repository * repo ;
1555
1519
1556
1520
Data_Get_Struct (self , git_repository , repo );
1521
+ Check_Type (rb_path , T_STRING );
1522
+ error = git_status_file (& flags , repo , StringValueCStr (rb_path ));
1523
+ rugged_exception_check (error );
1557
1524
1558
- if (rb_scan_args (argc , argv , "01" , & rb_path ) == 1 ) {
1559
- unsigned int flags ;
1560
- Check_Type (rb_path , T_STRING );
1561
- error = git_status_file (& flags , repo , StringValueCStr (rb_path ));
1562
- rugged_exception_check (error );
1525
+ return flags_to_rb (flags );
1526
+ }
1563
1527
1564
- return flags_to_rb (flags );
1565
- }
1528
+ static VALUE rb_git_repo_file_each_status (VALUE self )
1529
+ {
1530
+ int error ;
1531
+ git_repository * repo ;
1532
+
1533
+ Data_Get_Struct (self , git_repository , repo );
1566
1534
1567
1535
if (!rb_block_given_p ())
1568
1536
rb_raise (rb_eRuntimeError ,
@@ -2605,7 +2573,8 @@ void Init_rugged_repo(void)
2605
2573
rb_define_method (rb_cRuggedRepo , "path" , rb_git_repo_path , 0 );
2606
2574
rb_define_method (rb_cRuggedRepo , "workdir" , rb_git_repo_workdir , 0 );
2607
2575
rb_define_method (rb_cRuggedRepo , "workdir=" , rb_git_repo_set_workdir , 1 );
2608
- rb_define_method (rb_cRuggedRepo , "status" , rb_git_repo_status , -1 );
2576
+ rb_define_private_method (rb_cRuggedRepo , "file_status" , rb_git_repo_file_status , 1 );
2577
+ rb_define_private_method (rb_cRuggedRepo , "each_status" , rb_git_repo_file_each_status , 0 );
2609
2578
2610
2579
rb_define_method (rb_cRuggedRepo , "index" , rb_git_repo_get_index , 0 );
2611
2580
rb_define_method (rb_cRuggedRepo , "index=" , rb_git_repo_set_index , 1 );
0 commit comments