summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-02-14 16:55:18 +0000
committerGitHub <noreply@github.com>2019-02-14 16:55:18 +0000
commit48005936a7a6be2fb8a0ae4fa91dd220e1067ac7 (patch)
treee4ad5c461b2c52f5c880f6677b5f599dd4d86a90 /src
parentb88378278bded7abe7d8ed9b7dbf32702dc4c4f0 (diff)
parent004a339874ef697c781cd4cbe2437c0d95daef8a (diff)
downloadlibgit2-48005936a7a6be2fb8a0ae4fa91dd220e1067ac7.tar.gz
Merge pull request #4965 from hackworks/eliminate-check-for-keep-file
Allow bypassing check for '.keep' file
Diffstat (limited to 'src')
-rw-r--r--src/pack.c11
-rw-r--r--src/settings.c5
2 files changed, 13 insertions, 3 deletions
diff --git a/src/pack.c b/src/pack.c
index ef360a90b..cdd7e9e60 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -16,6 +16,9 @@
#include <zlib.h>
+/* Option to bypass checking existence of '.keep' files */
+bool git_disable_pack_keep_file_checks = false;
+
static int packfile_open(struct git_pack_file *p);
static git_off_t nth_packed_object_offset(const struct git_pack_file *p, uint32_t n);
static int packfile_unpack_compressed(
@@ -1141,9 +1144,11 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
if (git__suffixcmp(path, ".idx") == 0) {
size_t root_len = path_len - strlen(".idx");
- memcpy(p->pack_name + root_len, ".keep", sizeof(".keep"));
- if (git_path_exists(p->pack_name) == true)
- p->pack_keep = 1;
+ if (!git_disable_pack_keep_file_checks) {
+ memcpy(p->pack_name + root_len, ".keep", sizeof(".keep"));
+ if (git_path_exists(p->pack_name) == true)
+ p->pack_keep = 1;
+ }
memcpy(p->pack_name + root_len, ".pack", sizeof(".pack"));
}
diff --git a/src/settings.c b/src/settings.c
index 95cbd89e4..28d10eabb 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -57,6 +57,7 @@ int git_libgit2_features(void)
extern size_t git_mwindow__window_size;
extern size_t git_mwindow__mapped_limit;
extern size_t git_indexer__max_objects;
+extern bool git_disable_pack_keep_file_checks;
static int config_level_to_sysdir(int config_level)
{
@@ -279,6 +280,10 @@ int git_libgit2_opts(int key, ...)
*(va_arg(ap, size_t *)) = git_indexer__max_objects;
break;
+ case GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS:
+ git_disable_pack_keep_file_checks = (va_arg(ap, int) != 0);
+ break;
+
default:
git_error_set(GIT_ERROR_INVALID, "invalid option key");
error = -1;