git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: does a successful 'git gc' imply 'git fsck'

From
Sitaram Chamarty <sitaramc@gmail.com>
Date
Dec 2, 2012, 08:46 UTC
Message-ID
<CAMK1S_gUB6tpNQTLGTPPAvQ87+mX2HGiN1xpA7KoH33MX9tFBw@mail.gmail.com>
In-Reply-To
<CAJo=hJvHeA4g1fJZXm9VxpdvMFoHeEJW_r5YtXTDACEp09Xm_Q@mail.gmail.com>
On Sun, Dec 2, 2012 at 9:58 AM, Shawn Pearce <spearce@spearce.org> wrote:
Show 16 quoted lines
> On Sat, Dec 1, 2012 at 6:31 PM, Sitaram Chamarty <sitaramc@gmail.com> wrote:
>> Background: I have a situation where I have to fix up a few hundred
>> repos in terms of 'git gc' (the auto gc seems to have failed in many
>> cases; they have far more than 6700 loose objects).  I also found some
>> corrupted objects in some cases that prevent the gc from completing.
>>
>> I am running "git gc" followed by "git fsck".  The majority of the
>> repos I have worked through so far appear to be fine, but in the
>> larger repos (upwards of 2-3 GB) the git fsck is taking almost 5 times
>> longer than the 'gc'.
>>
>> If I could assume that a successful 'git gc' means an fsck is not
>> needed, I'd save a lot of time.  Hence my question.
>
> Not really. For example fsck verifies that every blob when
> decompressed and fully inflated matches its SHA-1. gc only checks

OK that makes sense. After I posted I happened to check using strace and kinda guessed this from what I saw, but it's nice to have confirmation.

Show 7 quoted lines
> connectivity of the commit and tree graph by making sure every object
> was accounted for. But when creating the output pack it only verifies
> a CRC-32 was correct when copying the bits from the source to the
> destination, it does not verify that the data decompresses and matches
> the SHA-1 it should match.
>
> So it depends on what level of check you need to feel safe.
Yup; thanks.

All the repos my internal client manages are mirrored in multiple places, and they set (or were at least told to set, heh!) receive.fsckObjects so the lesser check is fine in most cases.

-- 
Sitaram
Previous: Shawn PearceNext: Junio C Hamano
Message 3 of 7 in “does a successful 'git gc' imply 'git fsck'”
  1. Sitaram ChamartyDec 2, 2012
  2. Shawn PearceDec 2, 2012
  3. Sitaram ChamartyDec 2, 2012
  4. Junio C HamanoDec 2, 2012
  5. Sitaram ChamartyDec 3, 2012
  6. Matthieu MoyDec 3, 2012
  7. Junio C HamanoDec 3, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.