@@ -984,7 +984,7 @@ static VALUE rb_git_repo_revert_commit(int argc, VALUE *argv, VALUE self)
984984 * :hunk_callback ::
985985 * While applying the patch, this callback will be executed per hunk.
986986 * 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+ .
988988 *
989989 */
990990static 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)
993993 git_diff * diff ;
994994 git_repository * repo ;
995995 git_apply_options opts = GIT_APPLY_OPTIONS_INIT ;
996- git_apply_location_t location = GIT_APPLY_LOCATION_WORKDIR ;
996+ git_apply_location_t location ;
997997 struct rugged_apply_cb_payload payload = { Qnil , Qnil , 0 };
998998 int error ;
999999
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+
10001007 rb_scan_args (argc , argv , "11" , & rb_diff , & rb_options );
10011008
10021009 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)
10081015 rugged_parse_apply_options (& opts , & location , rb_options , & payload );
10091016 }
10101017
1011- Data_Get_Struct (self , git_repository , repo );
10121018 Data_Get_Struct (rb_diff , git_diff , diff );
10131019
10141020 error = git_apply (repo , diff , location , & opts );
0 commit comments