From 822d9dd51f8f2567766c38b719d9d6d5bdc1cfa0 Mon Sep 17 00:00:00 2001 From: Ben Straub Date: Wed, 11 Jul 2012 09:50:12 -0700 Subject: [PATCH] Remove duplicate of git_repository_head_tree. --- src/checkout.c | 25 +------------------------ tests-clar/clone/clone.c | 13 +++++++------ 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/checkout.c b/src/checkout.c index 58ae7f281..b9b5bc1f9 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -23,29 +23,6 @@ GIT_BEGIN_DECL -static int get_head_tree(git_tree **out, git_repository *repo) -{ - int retcode = GIT_ERROR; - git_reference *head = NULL; - - /* Dereference HEAD all the way to an OID ref */ - if (!git_reference_lookup_resolved(&head, repo, GIT_HEAD_FILE, -1)) { - /* The OID should be a commit */ - git_object *commit; - if (!git_object_lookup(&commit, repo, - git_reference_oid(head), GIT_OBJ_COMMIT)) { - /* Get the tree */ - if (!git_commit_tree(out, (git_commit*)commit)) { - retcode = 0; - } - git_object_free(commit); - } - git_reference_free(head); - } - - return retcode; -} - typedef struct tree_walk_data { git_indexer_stats *stats; @@ -160,7 +137,7 @@ int git_checkout_force(git_repository *repo, git_indexer_stats *stats) /* TODO: stats->total is never calculated. */ - if (!get_head_tree(&tree, repo)) { + if (!git_repository_head_tree(&tree, repo)) { /* Checkout the files */ if (!git_tree_walk(tree, checkout_walker, GIT_TREEWALK_POST, &payload)) { retcode = 0; diff --git a/tests-clar/clone/clone.c b/tests-clar/clone/clone.c index 78202d7e6..b0c8479b4 100644 --- a/tests-clar/clone/clone.c +++ b/tests-clar/clone/clone.c @@ -3,6 +3,9 @@ #include "git2/clone.h" #include "repository.h" +#define DO_LIVE_NETWORK_TESTS 0 + + static git_repository *g_repo; void test_clone_clone__initialize(void) @@ -74,7 +77,7 @@ void test_clone_clone__local(void) git_buf src = GIT_BUF_INIT; build_local_file_url(&src, cl_fixture("testrepo.git")); -#if 0 +#if DO_LIVE_NETWORK_TESTS cl_git_pass(git_clone(&g_repo, git_buf_cstr(&src), "./local", NULL)); git_repository_free(g_repo); git_futils_rmdir_r("./local", GIT_DIRREMOVAL_FILES_AND_DIRS); @@ -88,7 +91,7 @@ void test_clone_clone__local(void) void test_clone_clone__network_full(void) { -#if 0 +#if DO_LIVE_NETWORK_TESTS git_remote *origin; cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/node-gitteh", "./attr", NULL)); @@ -100,7 +103,7 @@ void test_clone_clone__network_full(void) void test_clone_clone__network_bare(void) { -#if 0 +#if DO_LIVE_NETWORK_TESTS git_remote *origin; cl_git_pass(git_clone_bare(&g_repo, "http://github.com/libgit2/node-gitteh", "attr", NULL)); @@ -113,9 +116,7 @@ void test_clone_clone__network_bare(void) void test_clone_clone__already_exists(void) { -#if 0 - int bar; - +#if DO_LIVE_NETWORK_TESTS /* Should pass with existing-but-empty dir */ p_mkdir("./foo", GIT_DIR_MODE); cl_git_pass(git_clone(&g_repo,