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

Re: Recovering from repository corruption

From
Denis Bueno <dbueno@gmail.com>
Date
Jun 10, 2008, 19:38 UTC
Message-ID
<6dbd4d000806101238v2bb975abqd39916e45d4bf866@mail.gmail.com>
In-Reply-To
<m3abhtp42o.fsf@localhost.localdomain>
On Tue, Jun 10, 2008 at 13:55, Jakub Narebski <jnareb@gmail.com> wrote:
Show 41 quoted lines
> Assume that history looks like this
>
>    ...---.---a---*---b---.---...
>
> where by '*' is marked corruped commit (commit shich tree contains
> corrupted blobs).
>
> First, you can check the commit message for '*' using git-cat-file or
> git-show, you can get the difference between 'a' and 'b' using
> "git diff a b".  When you know how repaired commit 'X' should look
> like, do something like:
>
>  $ git checkout -b <temp-branch> 'a'
>  $ <edit edit edit>
>  $ git commit
>
> Then history would look like this
>
>    ...---.---a---*---b---.---...
>               \
>                \-X
>
> Now with grafts make 'b' be a child of 'X', i.e. modify parent of 'b'
> for history to look like below:
>
>    ...---.---a---*   b---.---...
>               \     /
>                \-X-/
>
> Examine history using git-log, git-show, check tree with git-ls-tree
> and examining files, use graphical history browser like gitk.
>
> Then if possible use git-filter-branch to make history recorded in
> grafts file permanent...
>
> HTH
> --
> Jakub Narebski
> Poland
> ShadeHawk on #git
>
Thanks for the help.
My situation was:
    ...---a---*---b---c---d---*---e---...
Following your example, I believe I got this to:
    ...---a---*   b---c---d---*   e---...
           \     /         \     /
            \-X-/           \---/

That is, I replaced the first problematic commit and deleted the second, since I forgot how I changed 'd' to get that commit. I put the following in .git/info/grafts:

    'b' X
    'e' 'd'
(which I gathered from here:
http://thread.gmane.org/gmane.comp.version-control.git/66398/focus=66402.
 I've never use grafts before.  A bit about them should be put in the
manual, if it's not there already. =])
Then I ran:
    git-filter-branch HEAD ^X ^'d'

Now "git log --raw --all" doesn't show any of the problematic SHA-1 hashes anymore!

However:
identity.fb[173] > git fsck --full
    error: 320bd6e82267b71dd2ca7043ea3f61dbbca16109: object corrupt or missing
    error: 4d0be2816d5eea5ae2b40990235e2225c1715927: object corrupt or missing
    missing blob 320bd6e82267b71dd2ca7043ea3f61dbbca16109
    missing blob 4d0be2816d5eea5ae2b40990235e2225c1715927
Shouldn't these be unreferenced now that I've run filter-branch?
-- 
                              Denis
Previous: Jakub NarebskiNext: Jakub Narebski
Message 3 of 31 in “Recovering from repository corruption”
  1. Denis BuenoJun 10, 2008
  2. Jakub NarebskiJun 10, 2008
  3. Denis BuenoJun 10, 2008
  4. Jakub NarebskiJun 10, 2008
  5. Denis BuenoJun 10, 2008
  6. Jakub NarebskiJun 10, 2008
  7. Denis BuenoJun 10, 2008
  8. Linus TorvaldsJun 10, 2008
  9. Denis BuenoJun 10, 2008
  10. Linus TorvaldsJun 10, 2008
  11. Denis BuenoJun 10, 2008
  12. Linus TorvaldsJun 10, 2008
  13. Denis BuenoJun 10, 2008
  14. TarmiganJun 10, 2008
  15. Denis BuenoJun 10, 2008
  16. Linus TorvaldsJun 10, 2008
  17. Linus TorvaldsJun 10, 2008
  18. Nicolas PitreJun 11, 2008
  19. Linus TorvaldsJun 11, 2008
  20. Nicolas PitreJun 11, 2008
  21. Denis BuenoJun 10, 2008
  22. Junio C HamanoJun 10, 2008
  23. To graft or not to graft... (Re: Recovering from repository corruption)Stephen R. van den Berg, Jun 11, 2008
  24. Jakub NarebskiJun 11, 2008
  25. Linus TorvaldsJun 11, 2008
  26. Johan HerlandJun 12, 2008
  27. Jeff KingJun 12, 2008
  28. Johan HerlandJun 12, 2008
  29. Stephen R. van den BergJun 12, 2008
  30. Nicolas PitreJun 10, 2008
  31. Denis BuenoJun 10, 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.