This new environment variable will be used to perform git commands without involving any external odb mechanism.
This makes it possible for example to create new blobs that will not be sent to an external odb even if the external odb supports "put_*" instructions. Signed-off-by: Christian Couder <chrisc...@tuxfamily.org> --- cache.h | 9 +++++++++ environment.c | 4 ++++ external-odb.c | 3 +-- sha1_file.c | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cache.h b/cache.h index 2ac7d63e5c..4aa0129cf8 100644 --- a/cache.h +++ b/cache.h @@ -413,6 +413,7 @@ static inline enum object_type object_type(unsigned int mode) #define CEILING_DIRECTORIES_ENVIRONMENT "GIT_CEILING_DIRECTORIES" #define NO_REPLACE_OBJECTS_ENVIRONMENT "GIT_NO_REPLACE_OBJECTS" #define GIT_REPLACE_REF_BASE_ENVIRONMENT "GIT_REPLACE_REF_BASE" +#define NO_EXTERNAL_ODB_ENVIRONMENT "GIT_NO_EXTERNAL_ODB" #define GITATTRIBUTES_FILE ".gitattributes" #define INFOATTRIBUTES_FILE "info/attributes" #define ATTRIBUTE_MACRO_PREFIX "[attr]" @@ -799,6 +800,14 @@ void reset_shared_repository(void); extern int check_replace_refs; extern char *git_replace_ref_base; +/* + * Do external odbs need to be used this run? This variable is + * initialized to true unless $GIT_NO_EXTERNAL_ODB is set, but it + * maybe set to false by some commands that do not want external + * odbs to be active. + */ +extern int use_external_odb; + extern int fsync_object_files; extern int core_preload_index; extern int core_apply_sparse_checkout; diff --git a/environment.c b/environment.c index d6dd64662c..92f682cb9b 100644 --- a/environment.c +++ b/environment.c @@ -50,6 +50,7 @@ const char *excludes_file; enum auto_crlf auto_crlf = AUTO_CRLF_FALSE; int check_replace_refs = 1; char *git_replace_ref_base; +int use_external_odb = 1; enum eol core_eol = EOL_UNSET; int global_conv_flags_eol = CONV_EOL_RNDTRP_WARN; unsigned whitespace_rule_cfg = WS_DEFAULT_RULE; @@ -119,6 +120,7 @@ const char * const local_repo_env[] = { INDEX_ENVIRONMENT, NO_REPLACE_OBJECTS_ENVIRONMENT, GIT_REPLACE_REF_BASE_ENVIRONMENT, + NO_EXTERNAL_ODB_ENVIRONMENT, GIT_PREFIX_ENVIRONMENT, GIT_SUPER_PREFIX_ENVIRONMENT, GIT_SHALLOW_FILE_ENVIRONMENT, @@ -158,6 +160,8 @@ void setup_git_env(void) free(git_replace_ref_base); git_replace_ref_base = xstrdup(replace_ref_base ? replace_ref_base : "refs/replace/"); + if (getenv(NO_EXTERNAL_ODB_ENVIRONMENT)) + use_external_odb = 0; free(git_namespace); git_namespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT)); shallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT); diff --git a/external-odb.c b/external-odb.c index f3ea491333..390958dbfe 100644 --- a/external-odb.c +++ b/external-odb.c @@ -43,7 +43,7 @@ static void external_odb_init(void) { static int initialized; - if (initialized) + if (initialized || !use_external_odb) return; initialized = 1; @@ -69,4 +69,3 @@ int external_odb_has_object(const unsigned char *sha1) return 1; return 0; } - diff --git a/sha1_file.c b/sha1_file.c index 3f00fc716e..f2e078e840 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -669,6 +669,9 @@ void prepare_external_alt_odb(void) static int linked_external; const char *path; + if (!use_external_odb) + return; + if (linked_external) return; -- 2.17.0.rc0.37.g8f476fabe9