23
23
*/
24
24
25
25
#include "rugged.h"
26
- #include <git2/sys/repository.h>
27
- #include <git2/sys/odb_backend.h>
28
- #include <git2/sys/refdb_backend.h>
29
- #include <git2/refs.h>
30
26
31
27
extern VALUE rb_mRugged ;
32
28
extern VALUE rb_eRuggedError ;
33
29
extern VALUE rb_cRuggedIndex ;
34
30
extern VALUE rb_cRuggedConfig ;
35
- extern VALUE rb_cRuggedBackend ;
36
31
extern VALUE rb_cRuggedRemote ;
37
32
extern VALUE rb_cRuggedCommit ;
38
33
extern VALUE rb_cRuggedTag ;
39
34
extern VALUE rb_cRuggedTree ;
40
35
extern VALUE rb_cRuggedReference ;
41
- extern VALUE rb_cRuggedBackend ;
42
36
extern VALUE rb_cRuggedOdb ;
43
37
extern VALUE rb_cRuggedRefdb ;
44
38
@@ -189,74 +183,6 @@ static void load_alternates(git_repository *repo, VALUE rb_alternates)
189
183
rugged_exception_check (error );
190
184
}
191
185
192
- static void rugged_repo_new_with_backend (git_repository * * repo , VALUE rb_path , VALUE rb_backend )
193
- {
194
- char * path ;
195
-
196
- git_odb * odb = NULL ;
197
- git_odb_backend * odb_backend = NULL ;
198
- git_refdb * refdb = NULL ;
199
- git_refdb_backend * refdb_backend = NULL ;
200
- git_reference * head = NULL ;
201
- rugged_backend * backend ;
202
-
203
- int error = 0 ;
204
-
205
- Check_Type (rb_path , T_STRING );
206
- path = StringValueCStr (rb_path );
207
-
208
- if (rb_obj_is_kind_of (rb_backend , rb_cRuggedBackend ) == Qfalse ) {
209
- rb_raise (rb_eRuggedError , "Backend must be an instance of Rugged::Backend" );
210
- }
211
-
212
- Data_Get_Struct (rb_backend , rugged_backend , backend );
213
-
214
- error = git_odb_new (& odb );
215
- if (error ) goto cleanup ;
216
-
217
- error = backend -> odb_backend (& odb_backend , backend , path );
218
- if (error ) goto cleanup ;
219
-
220
- error = git_odb_add_backend (odb , odb_backend , 1 );
221
- if (error ) goto cleanup ;
222
-
223
- error = git_repository_wrap_odb (repo , odb );
224
- if (error ) goto cleanup ;
225
-
226
- error = git_refdb_new (& refdb , * repo );
227
- if (error ) goto cleanup ;
228
-
229
- error = backend -> refdb_backend (& refdb_backend , backend , path );
230
- if (error ) goto cleanup ;
231
-
232
- error = git_refdb_set_backend (refdb , refdb_backend );
233
- if (error ) goto cleanup ;
234
-
235
- git_repository_set_refdb (* repo , refdb );
236
-
237
- error = git_reference_lookup (& head , * repo , "HEAD" );
238
-
239
- if (error == GIT_ENOTFOUND ) {
240
- giterr_clear ();
241
- error = git_reference_symbolic_create (& head , * repo , "HEAD" , "refs/heads/master" , 0 , NULL );
242
- }
243
-
244
- if (!error ) {
245
- git_reference_free (head );
246
- return ;
247
- }
248
-
249
- cleanup :
250
- git_repository_free (* repo );
251
- git_odb_free (odb );
252
- git_refdb_free (refdb );
253
-
254
- if (odb_backend != NULL ) odb_backend -> free (odb_backend );
255
- if (refdb_backend != NULL ) refdb_backend -> free (refdb_backend );
256
-
257
- rugged_exception_check (error );
258
- }
259
-
260
186
/*
261
187
* call-seq:
262
188
* Repository.bare(path[, alternates]) -> repository OR
@@ -276,8 +202,6 @@ static void rugged_repo_new_with_backend(git_repository **repo, VALUE rb_path, V
276
202
*
277
203
* The following options can be passed in the +options+ Hash:
278
204
*
279
- * :backend ::
280
- * A Rugged::Backend instance
281
205
* :alternates ::
282
206
* A list of alternate object folders.
283
207
* Rugged::Repository.bare(path, :alternates => ['./other/repo/.git/objects'])
@@ -294,13 +218,6 @@ static VALUE rb_git_repo_open_bare(int argc, VALUE *argv, VALUE klass)
294
218
rb_alternates = rb_options ;
295
219
296
220
if (!NIL_P (rb_options ) && TYPE (rb_options ) == T_HASH ) {
297
- /* Check for `:backend` */
298
- VALUE rb_backend = rb_hash_aref (rb_options , CSTR2SYM ("backend" ));
299
-
300
- if (!NIL_P (rb_backend )) {
301
- rugged_repo_new_with_backend (& repo , rb_path , rb_backend );
302
- }
303
-
304
221
/* Check for `:alternates` */
305
222
rb_alternates = rb_hash_aref (rb_options , CSTR2SYM ("alternates" ));
306
223
}
@@ -377,36 +294,19 @@ static VALUE rb_git_repo_new(int argc, VALUE *argv, VALUE klass)
377
294
* of +path+. Non-bare repositories are created in a +.git+ folder and
378
295
* use +path+ as working directory.
379
296
*
380
- * The following options can be passed in the +options+ Hash:
381
- *
382
- * :backend ::
383
- * A Rugged::Backend instance
384
- *
385
- *
386
297
* Rugged::Repository.init_at('repository', :bare) #=> #<Rugged::Repository:0x108849488>
387
298
*/
388
299
static VALUE rb_git_repo_init_at (int argc , VALUE * argv , VALUE klass )
389
300
{
390
301
git_repository * repo = NULL ;
391
- VALUE rb_path , rb_is_bare , rb_options ;
302
+ VALUE rb_path , rb_is_bare ;
392
303
int error ;
393
304
394
- rb_scan_args (argc , argv , "11: " , & rb_path , & rb_is_bare , & rb_options );
305
+ rb_scan_args (argc , argv , "11" , & rb_path , & rb_is_bare );
395
306
Check_Type (rb_path , T_STRING );
396
307
397
- if (!NIL_P (rb_options )) {
398
- /* Check for `:backend` */
399
- VALUE rb_backend = rb_hash_aref (rb_options , CSTR2SYM ("backend" ));
400
-
401
- if (rb_backend && !NIL_P (rb_backend )) {
402
- rugged_repo_new_with_backend (& repo , rb_path , rb_backend );
403
- }
404
- }
405
-
406
- if (!repo ) {
407
- error = git_repository_init (& repo , StringValueCStr (rb_path ), RTEST (rb_is_bare ));
408
- rugged_exception_check (error );
409
- }
308
+ error = git_repository_init (& repo , StringValueCStr (rb_path ), RTEST (rb_is_bare ));
309
+ rugged_exception_check (error );
410
310
411
311
return rugged_repo_new (klass , repo );
412
312
}
0 commit comments