Commit dd15c615 by Edward Thomson

shallow: remove feature flag

The opt mechanism isn't _really_ meant to be for feature flags, and it's
weird to feature flag shallow / unshallow at all.
parent 190a4c55
...@@ -224,8 +224,7 @@ typedef enum { ...@@ -224,8 +224,7 @@ typedef enum {
GIT_OPT_GET_OWNER_VALIDATION, GIT_OPT_GET_OWNER_VALIDATION,
GIT_OPT_SET_OWNER_VALIDATION, GIT_OPT_SET_OWNER_VALIDATION,
GIT_OPT_GET_HOMEDIR, GIT_OPT_GET_HOMEDIR,
GIT_OPT_SET_HOMEDIR, GIT_OPT_SET_HOMEDIR
GIT_OPT_ENABLE_SHALLOW
} git_libgit2_opt_t; } git_libgit2_opt_t;
/** /**
...@@ -462,9 +461,6 @@ typedef enum { ...@@ -462,9 +461,6 @@ typedef enum {
* > { "!noop", "newext" } indicates that the caller does not want * > { "!noop", "newext" } indicates that the caller does not want
* > to support repositories with the `noop` extension but does want * > to support repositories with the `noop` extension but does want
* > to support repositories with the `newext` extension. * > to support repositories with the `newext` extension.
*
* opts(GIT_OPT_ENABLE_SHALLOW, int enabled)
* > Enable or disable shallow clone support completely.
* *
* opts(GIT_OPT_GET_OWNER_VALIDATION, int *enabled) * opts(GIT_OPT_GET_OWNER_VALIDATION, int *enabled)
* > Gets the owner validation setting for repository * > Gets the owner validation setting for repository
......
...@@ -553,14 +553,11 @@ int git_commit__parse_ext( ...@@ -553,14 +553,11 @@ int git_commit__parse_ext(
git_repository *repo = git_object_owner((git_object *)commit); git_repository *repo = git_object_owner((git_object *)commit);
git_commit_graft *graft; git_commit_graft *graft;
int error; int error;
if ((error = commit_parse(commit, git_odb_object_data(odb_obj), if ((error = commit_parse(commit, git_odb_object_data(odb_obj),
git_odb_object_size(odb_obj), parse_opts)) < 0) git_odb_object_size(odb_obj), parse_opts)) < 0)
return error; return error;
if (!git_shallow__enabled)
return 0;
/* Perform necessary grafts */ /* Perform necessary grafts */
if (git_grafts_get(&graft, repo->grafts, git_odb_object_id(odb_obj)) != 0 && if (git_grafts_get(&graft, repo->grafts, git_odb_object_id(odb_obj)) != 0 &&
git_grafts_get(&graft, repo->shallow_grafts, git_odb_object_id(odb_obj)) != 0) git_grafts_get(&graft, repo->shallow_grafts, git_odb_object_id(odb_obj)) != 0)
......
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
#include "oidarray.h" #include "oidarray.h"
#include "parse.h" #include "parse.h"
bool git_shallow__enabled = false;
struct git_grafts { struct git_grafts {
/* Map of `git_commit_graft`s */ /* Map of `git_commit_graft`s */
git_oidmap *commits; git_oidmap *commits;
...@@ -97,13 +95,13 @@ int git_grafts_refresh(git_grafts *grafts) ...@@ -97,13 +95,13 @@ int git_grafts_refresh(git_grafts *grafts)
if (!grafts->path) if (!grafts->path)
return 0; return 0;
if ((error = git_futils_readbuffer_updated(&contents, grafts->path, if ((error = git_futils_readbuffer_updated(&contents, grafts->path,
(grafts->path_checksum).id, &updated)) < 0) { (grafts->path_checksum).id, &updated)) < 0) {
if (error == GIT_ENOTFOUND) { if (error == GIT_ENOTFOUND) {
git_grafts_clear(grafts); git_grafts_clear(grafts);
error = 0; error = 0;
} }
goto cleanup; goto cleanup;
} }
......
...@@ -19,8 +19,6 @@ typedef struct { ...@@ -19,8 +19,6 @@ typedef struct {
typedef struct git_grafts git_grafts; typedef struct git_grafts git_grafts;
extern bool git_shallow__enabled;
int git_grafts_new(git_grafts **out); int git_grafts_new(git_grafts **out);
int git_grafts_from_file(git_grafts **out, const char *path); int git_grafts_from_file(git_grafts **out, const char *path);
void git_grafts_free(git_grafts *grafts); void git_grafts_free(git_grafts *grafts);
......
...@@ -436,10 +436,6 @@ int git_libgit2_opts(int key, ...) ...@@ -436,10 +436,6 @@ int git_libgit2_opts(int key, ...)
error = git_sysdir_set(GIT_SYSDIR_HOME, va_arg(ap, const char *)); error = git_sysdir_set(GIT_SYSDIR_HOME, va_arg(ap, const char *));
break; break;
case GIT_OPT_ENABLE_SHALLOW:
git_shallow__enabled = (va_arg(ap, int) != 0);
break;
default: default:
git_error_set(GIT_ERROR_INVALID, "invalid option key"); git_error_set(GIT_ERROR_INVALID, "invalid option key");
error = -1; error = -1;
......
...@@ -1099,7 +1099,7 @@ int git_repository_open_ext( ...@@ -1099,7 +1099,7 @@ int git_repository_open_ext(
if (error < 0) if (error < 0)
goto cleanup; goto cleanup;
if (git_shallow__enabled && (error = load_grafts(repo)) < 0) if ((error = load_grafts(repo)) < 0)
goto cleanup; goto cleanup;
if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0) { if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0) {
......
...@@ -4,12 +4,10 @@ ...@@ -4,12 +4,10 @@
void test_clone_shallow__initialize(void) void test_clone_shallow__initialize(void)
{ {
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SHALLOW, 1));
} }
void test_clone_shallow__cleanup(void) void test_clone_shallow__cleanup(void)
{ {
git_libgit2_opts(GIT_OPT_ENABLE_SHALLOW, 0);
} }
static int remote_single_branch(git_remote **out, git_repository *repo, const char *name, const char *url, void *payload) static int remote_single_branch(git_remote **out, git_repository *repo, const char *name, const char *url, void *payload)
......
...@@ -7,13 +7,11 @@ static git_repository *g_repo; ...@@ -7,13 +7,11 @@ static git_repository *g_repo;
void test_grafts_basic__initialize(void) void test_grafts_basic__initialize(void)
{ {
git_libgit2_opts(GIT_OPT_ENABLE_SHALLOW, 1);
g_repo = cl_git_sandbox_init("grafted.git"); g_repo = cl_git_sandbox_init("grafted.git");
} }
void test_grafts_basic__cleanup(void) void test_grafts_basic__cleanup(void)
{ {
git_libgit2_opts(GIT_OPT_ENABLE_SHALLOW, 0);
cl_git_sandbox_cleanup(); cl_git_sandbox_cleanup();
} }
......
...@@ -7,25 +7,13 @@ ...@@ -7,25 +7,13 @@
static git_repository *g_repo; static git_repository *g_repo;
static git_oid g_shallow_oid; static git_oid g_shallow_oid;
void test_grafts_shallow__set_feature_flag(void)
{
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SHALLOW, 1));
}
void test_grafts_shallow__unset_feature_flag(void)
{
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SHALLOW, 0));
}
void test_grafts_shallow__initialize(void) void test_grafts_shallow__initialize(void)
{ {
git_libgit2_opts(GIT_OPT_ENABLE_SHALLOW, 1);
cl_git_pass(git_oid__fromstr(&g_shallow_oid, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644", GIT_OID_SHA1)); cl_git_pass(git_oid__fromstr(&g_shallow_oid, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644", GIT_OID_SHA1));
} }
void test_grafts_shallow__cleanup(void) void test_grafts_shallow__cleanup(void)
{ {
git_libgit2_opts(GIT_OPT_ENABLE_SHALLOW, 0);
cl_git_sandbox_cleanup(); cl_git_sandbox_cleanup();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment