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

Re: fsck --full is Ok, but clones are not, "missing commits"?!

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Apr 17, 2008, 06:18 UTC
Message-ID
<4806EBBF.9060906@viscovery.net>
In-Reply-To
<20080416161742.GC3133@dpotapov.dyndns.org>
Dmitry Potapov schrieb:
Show 12 quoted lines
> On Wed, Apr 16, 2008 at 04:56:08PM +0200, Johannes Sixt wrote:
>> Actually, no. The trouble is that *all* tools obey grafts. Hence,
>> git-repack -f -d -a will remove the hidden objects. But a subsequent fsck
>> won't notice, because it *also* obeys the grafts. git prune will remove
>> hidden objects only as long as they are loose; if they are already packed,
>> then only a repack -f will remove them.
> 
> I use git 1.5.5 and I have a script that creates are repo with a hidden
> commit and then it cleans the reflog cleaned (as it would be happen after
> expiration of gc.reflogExpire). Then I run 'git-repack -f -d -a' and the
> hidden commit still presents, but when I run 'git prune' then the hidden
> object disappear. You can try it for yourself. Here is the script, I used:
And the reason for this is...
Show 32 quoted lines
> 
> ===
> #!/bin/sh
> 
> set -e
> 
> mkdir t5
> cd t5
> git init
> 
> echo 1 > foo
> git add foo
> git commit -m 'add foo'
> R1=$(git rev-parse HEAD)
> 
> echo 2 >> foo
> git commit -m 'edit foo' -a
> R2=$(git rev-parse HEAD)
> 
> echo 3 >> foo
> git commit -m 'edit foo again' -a
> R3=$(git rev-parse HEAD)
> 
> set -x
> git log
> echo "$R3 $R1" > .git/info/grafts
> git log
> git-fsck --unreachable
> : > .git/logs/HEAD
> : > .git/logs/refs/heads/master
> git-fsck --unreachable
> git gc

... at this point the hidden commit still exists as loose objects (because the repack inside gc didn't see the commit), and therefore...

> git-fsck --unreachable
> 
> 
> git-repack -f -d -a
... this does not make a difference at all.
> git-fsck --unreachable
> 
> git prune

Here you remove the loose objects (because prune doesn't see the commit, either), and by doing so you corrupt the repository.

> git-fsck --unreachable
> ===

A repack -a -d makes a difference if info/grafts is installed *after* the first repack/gc.

-- Hannes
Previous: Jakub Narebski
Message 10 of 10 in “Re: Re: Re: fsck --full is Ok, but clones are not, "missing commits"?!”
  1. Brian FosterApr 16, 2008
  2. Dmitry PotapovApr 16, 2008
  3. Petr BaudisApr 16, 2008
  4. Dmitry PotapovApr 16, 2008
  5. Johannes SixtApr 16, 2008
  6. Dmitry PotapovApr 16, 2008
  7. Johannes SixtApr 16, 2008
  8. Dmitry PotapovApr 16, 2008
  9. Jakub NarebskiApr 16, 2008
  10. Johannes SixtApr 17, 2008

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.