@@ -984,7 +984,7 @@ static VALUE rb_git_repo_revert_commit(int argc, VALUE *argv, VALUE self)
984
984
* :hunk_callback ::
985
985
* While applying the patch, this callback will be executed per hunk.
986
986
* The current +hunk+ will be passed to the block. The block's return value
987
- * determines further behavior, as per :delta_callback.
987
+ * determines further behavior, as per + :delta_callback+ .
988
988
*
989
989
*/
990
990
static VALUE rb_git_repo_apply (int argc , VALUE * argv , VALUE self )
@@ -993,10 +993,17 @@ static VALUE rb_git_repo_apply(int argc, VALUE *argv, VALUE self)
993
993
git_diff * diff ;
994
994
git_repository * repo ;
995
995
git_apply_options opts = GIT_APPLY_OPTIONS_INIT ;
996
- git_apply_location_t location = GIT_APPLY_LOCATION_WORKDIR ;
996
+ git_apply_location_t location ;
997
997
struct rugged_apply_cb_payload payload = { Qnil , Qnil , 0 };
998
998
int error ;
999
999
1000
+ Data_Get_Struct (self , git_repository , repo );
1001
+ if (git_repository_is_bare (repo )) {
1002
+ location = GIT_APPLY_LOCATION_INDEX ;
1003
+ } else {
1004
+ location = GIT_APPLY_LOCATION_WORKDIR ;
1005
+ }
1006
+
1000
1007
rb_scan_args (argc , argv , "11" , & rb_diff , & rb_options );
1001
1008
1002
1009
if (!rb_obj_is_kind_of (rb_diff , rb_cRuggedDiff )) {
@@ -1008,7 +1015,6 @@ static VALUE rb_git_repo_apply(int argc, VALUE *argv, VALUE self)
1008
1015
rugged_parse_apply_options (& opts , & location , rb_options , & payload );
1009
1016
}
1010
1017
1011
- Data_Get_Struct (self , git_repository , repo );
1012
1018
Data_Get_Struct (rb_diff , git_diff , diff );
1013
1019
1014
1020
error = git_apply (repo , diff , location , & opts );
0 commit comments