Skip to content

Commit 89afd77

Browse files
author
Dawa Ometto
committed
Set default apply location to index for bare repo's
1 parent 8573fa7 commit 89afd77

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

ext/rugged/rugged.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ VALUE rb_merge_file_result_fromC(const git_merge_file_result *results);
8585

8686
void rugged_parse_diff_options(git_diff_options *opts, VALUE rb_options);
8787
void rugged_parse_merge_options(git_merge_options *opts, VALUE rb_options);
88-
8988
void rugged_parse_checkout_options(git_checkout_options *opts, VALUE rb_options);
9089
void rugged_parse_merge_file_options(git_merge_file_options *opts, VALUE rb_options);
9190

ext/rugged/rugged_repo.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
990990
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)
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

Comments
 (0)