From b4978cf3301fcd39ad695b78d7a4cf2c9b58c6d3 Mon Sep 17 00:00:00 2001 From: Arthur Schreiber Date: Tue, 13 Oct 2015 22:14:27 +0200 Subject: [PATCH] Remove all of the old backend code. --- ext/rugged/rugged.c | 1 - ext/rugged/rugged.h | 7 --- ext/rugged/rugged_backend.c | 34 ------------ ext/rugged/rugged_repo.c | 108 ++---------------------------------- 4 files changed, 4 insertions(+), 146 deletions(-) delete mode 100644 ext/rugged/rugged_backend.c diff --git a/ext/rugged/rugged.c b/ext/rugged/rugged.c index faaf734aa..ebe5eec1e 100644 --- a/ext/rugged/rugged.c +++ b/ext/rugged/rugged.c @@ -481,7 +481,6 @@ void Init_rugged(void) Init_rugged_diff_line(); Init_rugged_blame(); Init_rugged_cred(); - Init_rugged_backend(); Init_rugged_refdb(); Init_rugged_refdb_backend(); diff --git a/ext/rugged/rugged.h b/ext/rugged/rugged.h index bad8e71b9..4ef0db1a3 100644 --- a/ext/rugged/rugged.h +++ b/ext/rugged/rugged.h @@ -79,7 +79,6 @@ void Init_rugged_diff_hunk(void); void Init_rugged_diff_line(void); void Init_rugged_blame(void); void Init_rugged_cred(void); -void Init_rugged_backend(void); void Init_rugged_refdb(void); void Init_rugged_refdb_backend(void); void Init_rugged_refdb_backend_fs(void); @@ -191,10 +190,4 @@ static inline VALUE rugged_create_oid(const git_oid *oid) return rb_str_new(out, 40); } - -typedef struct _rugged_backend { - int (* odb_backend)(git_odb_backend **backend_out, struct _rugged_backend *backend, const char* path); - int (* refdb_backend)(git_refdb_backend **backend_out, struct _rugged_backend *backend, const char* path); -} rugged_backend; - #endif diff --git a/ext/rugged/rugged_backend.c b/ext/rugged/rugged_backend.c deleted file mode 100644 index b4bb391cd..000000000 --- a/ext/rugged/rugged_backend.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2014 GitHub, Inc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "rugged.h" - -extern VALUE rb_mRugged; - -VALUE rb_cRuggedBackend; - -void Init_rugged_backend(void) -{ - rb_cRuggedBackend = rb_define_class_under(rb_mRugged, "Backend", rb_cObject); -} diff --git a/ext/rugged/rugged_repo.c b/ext/rugged/rugged_repo.c index 7e7393482..5da32eb60 100644 --- a/ext/rugged/rugged_repo.c +++ b/ext/rugged/rugged_repo.c @@ -23,22 +23,16 @@ */ #include "rugged.h" -#include -#include -#include -#include extern VALUE rb_mRugged; extern VALUE rb_eRuggedError; extern VALUE rb_cRuggedIndex; extern VALUE rb_cRuggedConfig; -extern VALUE rb_cRuggedBackend; extern VALUE rb_cRuggedRemote; extern VALUE rb_cRuggedCommit; extern VALUE rb_cRuggedTag; extern VALUE rb_cRuggedTree; extern VALUE rb_cRuggedReference; -extern VALUE rb_cRuggedBackend; extern VALUE rb_cRuggedOdb; extern VALUE rb_cRuggedRefdb; @@ -189,74 +183,6 @@ static void load_alternates(git_repository *repo, VALUE rb_alternates) rugged_exception_check(error); } -static void rugged_repo_new_with_backend(git_repository **repo, VALUE rb_path, VALUE rb_backend) -{ - char *path; - - git_odb *odb = NULL; - git_odb_backend *odb_backend = NULL; - git_refdb *refdb = NULL; - git_refdb_backend *refdb_backend = NULL; - git_reference *head = NULL; - rugged_backend *backend; - - int error = 0; - - Check_Type(rb_path, T_STRING); - path = StringValueCStr(rb_path); - - if (rb_obj_is_kind_of(rb_backend, rb_cRuggedBackend) == Qfalse) { - rb_raise(rb_eRuggedError, "Backend must be an instance of Rugged::Backend"); - } - - Data_Get_Struct(rb_backend, rugged_backend, backend); - - error = git_odb_new(&odb); - if (error) goto cleanup; - - error = backend->odb_backend(&odb_backend, backend, path); - if (error) goto cleanup; - - error = git_odb_add_backend(odb, odb_backend, 1); - if (error) goto cleanup; - - error = git_repository_wrap_odb(repo, odb); - if (error) goto cleanup; - - error = git_refdb_new(&refdb, *repo); - if (error) goto cleanup; - - error = backend->refdb_backend(&refdb_backend, backend, path); - if (error) goto cleanup; - - error = git_refdb_set_backend(refdb, refdb_backend); - if (error) goto cleanup; - - git_repository_set_refdb(*repo, refdb); - - error = git_reference_lookup(&head, *repo, "HEAD"); - - if (error == GIT_ENOTFOUND) { - giterr_clear(); - error = git_reference_symbolic_create(&head, *repo, "HEAD", "refs/heads/master", 0, NULL); - } - - if (!error) { - git_reference_free(head); - return; - } - -cleanup: - git_repository_free(*repo); - git_odb_free(odb); - git_refdb_free(refdb); - - if (odb_backend != NULL) odb_backend->free(odb_backend); - if (refdb_backend != NULL) refdb_backend->free(refdb_backend); - - rugged_exception_check(error); -} - /* * call-seq: * Repository.bare(path[, alternates]) -> repository OR @@ -276,8 +202,6 @@ static void rugged_repo_new_with_backend(git_repository **repo, VALUE rb_path, V * * The following options can be passed in the +options+ Hash: * - * :backend :: - * A Rugged::Backend instance * :alternates :: * A list of alternate object folders. * 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) rb_alternates = rb_options; if (!NIL_P(rb_options) && TYPE(rb_options) == T_HASH) { - /* Check for `:backend` */ - VALUE rb_backend = rb_hash_aref(rb_options, CSTR2SYM("backend")); - - if (!NIL_P(rb_backend)) { - rugged_repo_new_with_backend(&repo, rb_path, rb_backend); - } - /* Check for `:alternates` */ rb_alternates = rb_hash_aref(rb_options, CSTR2SYM("alternates")); } @@ -377,36 +294,19 @@ static VALUE rb_git_repo_new(int argc, VALUE *argv, VALUE klass) * of +path+. Non-bare repositories are created in a +.git+ folder and * use +path+ as working directory. * - * The following options can be passed in the +options+ Hash: - * - * :backend :: - * A Rugged::Backend instance - * - * * Rugged::Repository.init_at('repository', :bare) #=> # */ static VALUE rb_git_repo_init_at(int argc, VALUE *argv, VALUE klass) { git_repository *repo = NULL; - VALUE rb_path, rb_is_bare, rb_options; + VALUE rb_path, rb_is_bare; int error; - rb_scan_args(argc, argv, "11:", &rb_path, &rb_is_bare, &rb_options); + rb_scan_args(argc, argv, "11", &rb_path, &rb_is_bare); Check_Type(rb_path, T_STRING); - if (!NIL_P(rb_options)) { - /* Check for `:backend` */ - VALUE rb_backend = rb_hash_aref(rb_options, CSTR2SYM("backend")); - - if (rb_backend && !NIL_P(rb_backend)) { - rugged_repo_new_with_backend(&repo, rb_path, rb_backend); - } - } - - if(!repo) { - error = git_repository_init(&repo, StringValueCStr(rb_path), RTEST(rb_is_bare)); - rugged_exception_check(error); - } + error = git_repository_init(&repo, StringValueCStr(rb_path), RTEST(rb_is_bare)); + rugged_exception_check(error); return rugged_repo_new(klass, repo); }