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

WARNING: THIS PATCH CAN BREAK YOUR REPO, was Re: [PATCH 2/3] Only repack active packs by skipping over kept packs.

From
Nicolas Pitre <nico@cam.org>
Date
Oct 30, 2006, 19:07 UTC
Message-ID
<Pine.LNX.4.64.0610301332440.11384@xanadu.home>
In-Reply-To
<20061029093754.GD3847@spearce.org>
On Sun, 29 Oct 2006, Shawn Pearce wrote:
> During `git repack -a -d` only repack objects which are loose or
> which reside in an active (a non-kept) pack.  This allows the user
> to keep large packs as-is without continuous repacking and can be
> very helpful on large repositories.
Something is really broken here.
Here's how to destroy your GIT's git repository.
WARNING: MAKE A COPY BEFORE TRYING THIS!  I'm serious.

First, let's make a single pack just to make things simpler and reproducible:

$ git-repack -a -f -d $ git-prune $ git-fsck-objects --full

So far everything should be fine. It's still time to make a backup copy of your .git directory if you've not done so.

Now let's create a second pack containing a subset of the existing one.
$ git-rev-list --objects v1.4.3..v1.4.3.3 | \
  git-pack-objects --stdout | \
  git-index-pack --stdin -v --keep
$ git-fsck-objects --full

At this point the repository is still fine, but the --keep to git-index-pack above will have created a file called .git/objects/pack/pack-aceb4c6394c586abaf65d76dd6cf088f50a5b806.keep and that is the source of all the trouble to come. You still can remove that file if you don't have a backup yet.

If you still want to give it the coup de grace, just do:
$ git-repack -a -d

And now you've just lost a large amount of objects. To see the extent of the dammage, just do:

$ git-fsck-objects

So... what is the --unpacked=<pack>.pack switch supposed to mean? It is not documented anywhere and it certainly doesn't produce the expected result with a repack.

Previous: Shawn PearceNext: Shawn Pearce
Message 2 of 17 in “Only repack active packs by skipping over kept packs.”
  1. 2/3 Only repack active packs by skipping over kept packs.Shawn Pearce, Oct 29, 2006
  2. WARNING: THIS PATCH CAN BREAK YOUR REPO, was Re: [PATCH 2/3] Only repack active packs by skipping over kept packs.Nicolas Pitre, Oct 30, 2006
  3. Shawn PearceOct 30, 2006
  4. Shawn PearceOct 30, 2006
  5. Jan HarkesOct 30, 2006
  6. Jan HarkesOct 30, 2006
  7. Shawn PearceOct 30, 2006
  8. Junio C HamanoOct 30, 2006
  9. Junio C HamanoOct 30, 2006
  10. Jan HarkesOct 30, 2006
  11. Junio C HamanoOct 30, 2006
  12. Continue traversal when rev-list --unpacked finds a packed commit.Jan Harkes, Oct 31, 2006
  13. Junio C HamanoOct 31, 2006
  14. Jan HarkesOct 31, 2006
  15. Junio C HamanoOct 30, 2006
  16. Shawn PearceOct 30, 2006
  17. Junio C HamanoOct 30, 2006

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.