Skip to content

Commit b4978cf

Browse files
Remove all of the old backend code.
1 parent fe7acc7 commit b4978cf

File tree

4 files changed

+4
-146
lines changed

4 files changed

+4
-146
lines changed

ext/rugged/rugged.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ void Init_rugged(void)
481481
Init_rugged_diff_line();
482482
Init_rugged_blame();
483483
Init_rugged_cred();
484-
Init_rugged_backend();
485484

486485
Init_rugged_refdb();
487486
Init_rugged_refdb_backend();

ext/rugged/rugged.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ void Init_rugged_diff_hunk(void);
7979
void Init_rugged_diff_line(void);
8080
void Init_rugged_blame(void);
8181
void Init_rugged_cred(void);
82-
void Init_rugged_backend(void);
8382
void Init_rugged_refdb(void);
8483
void Init_rugged_refdb_backend(void);
8584
void Init_rugged_refdb_backend_fs(void);
@@ -191,10 +190,4 @@ static inline VALUE rugged_create_oid(const git_oid *oid)
191190
return rb_str_new(out, 40);
192191
}
193192

194-
195-
typedef struct _rugged_backend {
196-
int (* odb_backend)(git_odb_backend **backend_out, struct _rugged_backend *backend, const char* path);
197-
int (* refdb_backend)(git_refdb_backend **backend_out, struct _rugged_backend *backend, const char* path);
198-
} rugged_backend;
199-
200193
#endif

ext/rugged/rugged_backend.c

Lines changed: 0 additions & 34 deletions
This file was deleted.

ext/rugged/rugged_repo.c

Lines changed: 4 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,16 @@
2323
*/
2424

2525
#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>
3026

3127
extern VALUE rb_mRugged;
3228
extern VALUE rb_eRuggedError;
3329
extern VALUE rb_cRuggedIndex;
3430
extern VALUE rb_cRuggedConfig;
35-
extern VALUE rb_cRuggedBackend;
3631
extern VALUE rb_cRuggedRemote;
3732
extern VALUE rb_cRuggedCommit;
3833
extern VALUE rb_cRuggedTag;
3934
extern VALUE rb_cRuggedTree;
4035
extern VALUE rb_cRuggedReference;
41-
extern VALUE rb_cRuggedBackend;
4236
extern VALUE rb_cRuggedOdb;
4337
extern VALUE rb_cRuggedRefdb;
4438

@@ -189,74 +183,6 @@ static void load_alternates(git_repository *repo, VALUE rb_alternates)
189183
rugged_exception_check(error);
190184
}
191185

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-
260186
/*
261187
* call-seq:
262188
* Repository.bare(path[, alternates]) -> repository OR
@@ -276,8 +202,6 @@ static void rugged_repo_new_with_backend(git_repository **repo, VALUE rb_path, V
276202
*
277203
* The following options can be passed in the +options+ Hash:
278204
*
279-
* :backend ::
280-
* A Rugged::Backend instance
281205
* :alternates ::
282206
* A list of alternate object folders.
283207
* 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)
294218
rb_alternates = rb_options;
295219

296220
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-
304221
/* Check for `:alternates` */
305222
rb_alternates = rb_hash_aref(rb_options, CSTR2SYM("alternates"));
306223
}
@@ -377,36 +294,19 @@ static VALUE rb_git_repo_new(int argc, VALUE *argv, VALUE klass)
377294
* of +path+. Non-bare repositories are created in a +.git+ folder and
378295
* use +path+ as working directory.
379296
*
380-
* The following options can be passed in the +options+ Hash:
381-
*
382-
* :backend ::
383-
* A Rugged::Backend instance
384-
*
385-
*
386297
* Rugged::Repository.init_at('repository', :bare) #=> #<Rugged::Repository:0x108849488>
387298
*/
388299
static VALUE rb_git_repo_init_at(int argc, VALUE *argv, VALUE klass)
389300
{
390301
git_repository *repo = NULL;
391-
VALUE rb_path, rb_is_bare, rb_options;
302+
VALUE rb_path, rb_is_bare;
392303
int error;
393304

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);
395306
Check_Type(rb_path, T_STRING);
396307

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);
410310

411311
return rugged_repo_new(klass, repo);
412312
}

0 commit comments

Comments
 (0)