From: "Kyle J. McKay" <mackyle@xxxxxxxxx>
Sent: Sunday, December 04, 2016 12:24 AM
The recent addition of pre-receive quarantining breaks nested
alternates that are already at the maximum alternates nesting depth.
In the file sha1_file.c in the function link_alt_odb_entries we have
this:
> if (depth > 5) {
> error("%s: ignoring alternate object stores, nesting too deep.",
> relative_base);
> return;
> }
When the incoming quarantine takes place the current objects directory
is demoted to an alternate thereby increasing its depth (and any
alternates it references) by one and causing any object store that was
previously at the maximum nesting depth to be ignored courtesy of the
above hard-coded maximum depth.
If the incoming push happens to need access to some of those objects
to perhaps "--fix-thin" its pack it will crash and burn.
Originally I was not going to include a patch to fix this, but simply
suggest that the expeditious fix is to just allow one additional
alternates nesting depth level during quarantine operations.
However, it was so simple, I have included the patch below :)
I have verified that where a push with Git v2.10.2 succeeds and a push
with Git v2.11.0 to the same repository fails because of this problem
that the below patch does indeed correct the issue and allow the push
to succeed.
Cheers,
Kyle
-- 8< --
Subject: [PATCH] receive-pack: increase max alternates depth during
quarantine
Ever since 722ff7f876 (receive-pack: quarantine objects until
pre-receive accepts, 2016-10-03, v2.11.0), Git has been quarantining
objects and packs received during an incoming push into a separate
objects directory and using the alternates mechanism to make them
available until they are either accepted and moved into the main
objects directory or rejected and discarded.
Is there a step here that after the accepted/rejected stage, it should then
decrement the limit back to its original value. The problem description
suggests that might be the case.
--
Philip
Unfortunately this has the side effect of increasing the alternates
nesting depth level by one for all pre-existing alternates.
If a repository is already at the maximum alternates nesting depth,
then this quarantining operation can temporarily push it over making
the incoming push fail.
To prevent the failure we simply increase the allowed alternates
nesting depth by one whenever a quarantine operation is in effect.
Signed-off-by: Kyle J. McKay <mackyle@xxxxxxxxx>
---
Notes:
Some alternates nesting depth background:
If base/fork0/fork1/fork2/fork3/fork4/fork5 represents
seven git repositories where base.git has no alternates,
fork0.git has base.git as an alternate, fork1.git has
fork0.git as an alternate and so on where fork5.git has
only fork4.git as an alternate, then fork5.git is at
the maximum allowed depth of 5. git fsck --strict --full
works without complaint on fork5.git.
However, in base/fork0/fork1/fork2/fork3/fork4/fork5/fork6,
an fsck --strict --full of fork6.git will generate complaints
and any objects/packs present in base.git will be ignored.
cache.h | 1 +
common-main.c | 3 +++
environment.c | 1 +
sha1_file.c | 2 +-
4 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/cache.h b/cache.h
index a50a61a1..25c17c29 100644
--- a/cache.h
+++ b/cache.h
@@ -676,6 +676,7 @@ extern size_t packed_git_limit;
extern size_t delta_base_cache_limit;
extern unsigned long big_file_threshold;
extern unsigned long pack_size_limit_cfg;
+extern int alt_odb_max_depth;
/*
* Accessors for the core.sharedrepository config which lazy-load the
value
diff --git a/common-main.c b/common-main.c
index c654f955..9f747491 100644
--- a/common-main.c
+++ b/common-main.c
@@ -37,5 +37,8 @@ int main(int argc, const char **argv)
restore_sigpipe_to_default();
+ if (getenv(GIT_QUARANTINE_ENVIRONMENT))
+ alt_odb_max_depth++;
+
return cmd_main(argc, argv);
}
diff --git a/environment.c b/environment.c
index 0935ec69..32e11f70 100644
--- a/environment.c
+++ b/environment.c
@@ -64,6 +64,7 @@ int merge_log_config = -1;
int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
unsigned long pack_size_limit_cfg;
enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
+int alt_odb_max_depth = 5;
#ifndef PROTECT_HFS_DEFAULT
#define PROTECT_HFS_DEFAULT 0
diff --git a/sha1_file.c b/sha1_file.c
index 9c86d192..15b8432e 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -337,7 +337,7 @@ static void link_alt_odb_entries(const char *alt, int
len, int sep,
int i;
struct strbuf objdirbuf = STRBUF_INIT;
- if (depth > 5) {
+ if (depth > alt_odb_max_depth) {
error("%s: ignoring alternate object stores, nesting too deep.",
relative_base);
return;
---