@@ -156,11 +156,6 @@ static VALUE rb_git_rebase_new(int argc, VALUE* argv, VALUE klass)
156
156
* The id of the commit being cherry-picked. Exists for all but
157
157
* +:exec+ operations.
158
158
*
159
- * :index ::
160
- * If the rebase is +:inmemory+ this is in the resulting merge
161
- * index. It can be used to resolve merge conflicts during the
162
- * rebase.
163
- *
164
159
* :exec ::
165
160
* If the operatin is +:exec+ this is what the user asked to be
166
161
* executed.
@@ -190,19 +185,36 @@ static VALUE rb_git_rebase_next(VALUE self)
190
185
rb_hash_aset (hash , CSTR2SYM ("id" ), val );
191
186
}
192
187
193
- if (operation -> index ) {
194
- val = Data_Wrap_Struct (rb_cRuggedIndex , NULL , NULL , operation -> index );
195
- rugged_set_owner (val , self );
196
- rb_hash_aset (hash , CSTR2SYM ("index" ), val );
197
- }
198
-
199
188
if (operation -> exec ) {
200
189
val = rb_str_new_utf8 (operation -> exec );
201
190
rb_hash_aset (hash , CSTR2SYM ("exec" ), val );
202
191
}
203
192
204
193
return hash ;
205
194
}
195
+ /*
196
+ * call-seq:
197
+ * Rebase.inmemory_index -> Index
198
+ *
199
+ * Gets the index produced by the last operation, which is the result
200
+ * of +next+ and which will be committed by the next invocation of
201
+ * +commit+. This is useful for resolving conflicts in an in-memory
202
+ * rebase before committing them.
203
+ *
204
+ * This is only applicable for in-memory rebases; for rebases within
205
+ * a working directory, the changes were applied to the repository's
206
+ * index.
207
+ */
208
+ static VALUE rb_git_rebase_inmemory_index (VALUE self )
209
+ {
210
+ git_rebase * rebase ;
211
+ git_index * index ;
212
+
213
+ Data_Get_Struct (self , git_rebase , rebase );
214
+ rugged_exception_check (git_rebase_inmemory_index (& index , rebase ));
215
+
216
+ return rugged_index_new (rb_cRuggedIndex , self , index );
217
+ }
206
218
207
219
/*
208
220
* call-seq:
@@ -328,6 +340,7 @@ void Init_rugged_rebase(void)
328
340
329
341
rb_define_singleton_method (rb_cRuggedRebase , "new" , rb_git_rebase_new , -1 );
330
342
rb_define_method (rb_cRuggedRebase , "next" , rb_git_rebase_next , 0 );
343
+ rb_define_method (rb_cRuggedRebase , "inmemory_index" , rb_git_rebase_inmemory_index , 0 );
331
344
rb_define_method (rb_cRuggedRebase , "commit" , rb_git_rebase_commit , -1 );
332
345
rb_define_method (rb_cRuggedRebase , "abort" , rb_git_rebase_abort , 0 );
333
346
rb_define_method (rb_cRuggedRebase , "finish" , rb_git_rebase_finish , 1 );
0 commit comments