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

Re: fsck option to remove corrupt objects - why/why not?

From
Johan Herland <johan@herland.net>
Date
Oct 16, 2014, 12:48 UTC
Message-ID
<CALKQrgdQt0gJ0Dy4M5i-aitiJNeYjHWC8UAY37O7=591MpsR5g@mail.gmail.com>
In-Reply-To
<20141016122533.GA8451@peff.net>
On Thu, Oct 16, 2014 at 2:25 PM, Jeff King <peff@peff.net> wrote:
Show 21 quoted lines
> On Thu, Oct 16, 2014 at 11:04:04AM +0200, Johan Herland wrote:
>> I simply copied the packfile containing the good copy into the
>> corrupted repo, and then ran a "git gc", which "happened" to use the
>> good copy of the corrupted object and complete successfully (instead
>> of barfing on the bad copy). The GC then removed the old
>> (now-obsolete) packfiles, and thus the corruption was gone.
>>
>> However, exactly _why_ git happened to prefer the good copy in my
>> copied packfile instead of the bad copy in the existing packfile, I do
>> not know. I suspect some amount of pure luck was involved.
>
> I'm not sure that it is luck, but more like 8eca0b4 (implement some
> resilience against pack corruptions, 2008-06-23) working as intended[1].
> Generally, git should be able to warn about corrupted objects and look
> in other packs for them (both for regular operations, and for
> repacking).
>
> -Peff
>
> [1] That's just one of the many commits dealing with this. Try running
>     "git log --author=Nicolas.Pitre --grep=corrupt" for more. :)

Indeed, from reading the logs, it seems what I assumed was a lucky strike, was actually carefully designed behavior. With that in mind, I'm no longer so sure that fsck actually needs an option to remove corrupt objects. Instead, it's probably better to leave the corrupt object in place until a good copy can be located and copied into the repo, at which point Nicolas' brilliant work will make sure a simple repack takes care of fixing the corruption.

That said, we should consider documenting this strategy for fixing corruptions:
 - Locate the a good copy of the affected objects in another repo
 - Copy relevant pack file or loose object into this repo
 - Run "git gc"
 - Profit!
...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Previous: Jeff KingNext: Junio C Hamano
Message 4 of 6 in “fsck option to remove corrupt objects - why/why not?”
  1. Ben AvelingOct 16, 2014
  2. Johan HerlandOct 16, 2014
  3. Jeff KingOct 16, 2014
  4. Johan HerlandOct 16, 2014
  5. Junio C HamanoOct 16, 2014
  6. Matthieu MoyOct 16, 2014

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.