Re: What's so special about objects/17/ ?
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Oct 7, 2018, 18:35 UTC
- Message-ID
- <f64b5c5d-ef72-a347-bd0f-7b1669a8c10d@kdbg.org>
- In-Reply-To
- <87k1mta9x5.fsf@evledraar.gmail.com>
Am 07.10.18 um 20:28 schrieb Ævar Arnfjörð Bjarmason:
Show 11 quoted lines
> In 2007 Junio wrote
> (https://public-inbox.org/git/7vr6lcj2zi.fsf@gitster.siamese.dyndns.org/):
>
> +static int need_to_gc(void)
> +{
> + /*
> + * Quickly check if a "gc" is needed, by estimating how
> + * many loose objects there are. Because SHA-1 is evenly
> + * distributed, we can check only one and get a reasonable
> + * estimate.
> + */Show 5 quoted lines
> 1. We still have this check of objects/17/ in builtin/gc.c today. Why > objects/17/ and not e.g. objects/00/ to go with other 000* magic such > as the 0000000000000000000000000000000000000000 SHA-1? Statistically > it doesn't matter, but 17 seems like an odd thing to pick at random > out of 00..ff, does it have any significance?
The reason is explained in the comment. And, BTW, you do know about this one: https://xkcd.com/221/ don't you? (TLDR: the title is "Random Number")
Show 7 quoted lines
> 2. It seems overly paranoid to be checking that the files in > .git/objects/17/ look like a SHA-1. If we have stuff not generated by > git in .git/objects/??/ we probably have bigger problems than > prematurely triggering auto gc, can this just be removed as > redundant. Was this some check e.g. expecting that this would need to > deal with tempfiles in these directories that we created at the time > (but no longer do?)?
It's not about that there are SHA-1s in there, it's about how many there are.
-- Hannes