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

Re: recognize loose local objects during repack

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 10, 2008, 21:03 UTC
Message-ID
<7vtzaf47ld.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<2390436.1226296705080.JavaMail.teamon@b307.teamon.com>
drafnel@gmail.com writes:
> This was developed on top of the previous repack/pack-objects series.
Thanks.  Looked alright from a cursory reading.

By the way, I've been meaning to suggest that we should straighten out the semantics of "unpacked" vs "incremental".

What the latter means is quite clear. We are creating a new packfile to bundle loose ones into one, and after the new packfile is installed we can remove the loose objects.

But what --unpacked means often confuses people, primarily because it is a performance heuristics that makes certain assumptions on how the objects are packed.

Namely, "unpacked" is about discovery process of objects to be packed. Without the option, we enumerate all objects that are reachable from the commits in the given range, excluding the trees and blobs that should exist in commits that are excluded (e.g, if you say "--objects A..B", we exclude trees and blobs referenced by commit A).

With the option, we also omit commits that are packed. What's funny is that their trees and blobs are omitted, even if they are loose ;-)

This is typically not an issue, because you do not say "pack only this commit object, without its trees or blobs" when repacking, and because you must have all the trees and blobs necessary for a commit available when you pack a commit; for these reasons, the trees and blobs are typically packed together with the commit. It is not an issue that the rev-list with --unpacked option does not list loose trees and blobs that belong to a packed commit for this reason.

You could however arrange so that a commit itself is packed but some of the tree and blob objects it refers to are loose, in which case these loose objects may not ever get repacked incrementally.

In an empty directory, try this:
        git init &&
        echo 0 >file && git add file && git commit -m initial &&
        P=$(git rev-list HEAD | git pack-objects pack) &&
        mv pack-$P.* .git/objects/pack/ &&
        git prune && git count-objects -v
        git repack && git count-objects -v

It packs only the commit object (and prunes it), leaving a tree and a blob loose. The repack won't find anything to pack.

This is not so bad in the sense that it will never corrupt your repository, but it is confusing. Admittedly, not peeking into a commit that is packed is a reasonable good heuristics for performance reasons.

Interestingly enough, the object listing machinery do traverse into parents of packed commits when --unpacked is given. So if you pack a commit and arrange to keep its parents unpacked, they are subject to the incremental repacking. In other words, the performance heuristics may not be buying us very much --- we are traversing the history down to the root commits regardless.

Previous: drafnel@gmail.comNext: Brandon Casey
Message 23 of 61 in “getting list of objects for packing”
  1. Brandon CaseyOct 31, 2008
  2. Nicolas PitreOct 31, 2008
  3. Brandon CaseyOct 31, 2008
  4. Junio C HamanoOct 31, 2008
  5. Brandon CaseyOct 31, 2008
  6. Jakub NarebskiOct 31, 2008
  7. Brandon CaseyNov 1, 2008
  8. t7700: demonstrate mishandling of objects in packs with a .keep filedrafnel@gmail.com, Nov 2, 2008
  9. 1/3 packed_git: convert pack_local flag into generic bit maskdrafnel@gmail.com, Nov 2, 2008
  10. Shawn O. PearceNov 3, 2008
  11. Brandon CaseyNov 3, 2008
  12. 1/3 t7700: demonstrate mishandling of objects in packs with a .keep fileBrandon Casey, Nov 3, 2008
  13. 2/3 packed_git: convert pack_local flag into a bitfield and add pack_keepBrandon Casey, Nov 3, 2008
  14. 3/3 pack-objects: honor '.keep' filesBrandon Casey, Nov 3, 2008
  15. Shawn O. PearceNov 3, 2008
  16. Brandon CaseyNov 5, 2008
  17. Brandon CaseyNov 6, 2008
  18. Junio C HamanoNov 7, 2008
  19. Brandon CaseyNov 7, 2008
  20. Andreas EricssonNov 7, 2008
  21. Shawn O. PearceNov 7, 2008
  22. recognize loose local objects during repackdrafnel@gmail.com, Nov 10, 2008
  23. Junio C HamanoNov 10, 2008
  24. 1/4 pack-objects: new option --honor-pack-keepBrandon Casey, Nov 7, 2008
  25. 2/4 repack: don't repack local objects in packs with .keep fileBrandon Casey, Nov 7, 2008
  26. 3/4 repack: do not fall back to incremental repacking with [-a|-A]Brandon Casey, Nov 7, 2008
  27. 4/4 builtin-gc.c: use new pack_keep bitfield to detect .keep file existenceBrandon Casey, Nov 7, 2008
  28. Andreas EricssonNov 7, 2008
  29. Andreas EricssonNov 7, 2008
  30. t7700: demonstrate mishandling of objects in packs with a .keep fileBrandon Casey, Nov 3, 2008
  31. Andreas EricssonNov 4, 2008
  32. Brandon CaseyNov 4, 2008
  33. Junio C HamanoNov 4, 2008
  34. Brandon CaseyNov 4, 2008
  35. Andreas EricssonNov 4, 2008
  36. Junio C HamanoNov 4, 2008
  37. Jeff KingNov 12, 2008
  38. Junio C HamanoNov 12, 2008
  39. Jeff KingNov 12, 2008
  40. Brandon CaseyNov 12, 2008
  41. repack and .keep seriesBrandon Casey, Nov 12, 2008
  42. 1/6 t7700: demonstrate mishandling of objects in packs with a .keep fileBrandon Casey, Nov 12, 2008
  43. 2/6 packed_git: convert pack_local flag into a bitfield and add pack_keepBrandon Casey, Nov 12, 2008
  44. 3/6 pack-objects: new option --honor-pack-keepBrandon Casey, Nov 12, 2008
  45. 4/6 repack: don't repack local objects in packs with .keep fileBrandon Casey, Nov 12, 2008
  46. 5/6 repack: do not fall back to incremental repacking with [-a|-A]Brandon Casey, Nov 12, 2008
  47. 6/6 builtin-gc.c: use new pack_keep bitfield to detect .keep file existenceBrandon Casey, Nov 12, 2008
  48. t7700: test that 'repack -a' packs alternate packed objectsBrandon Casey, Nov 13, 2008
  49. Junio C HamanoNov 12, 2008
  50. Junio C HamanoNov 12, 2008
  51. Andreas EricssonNov 3, 2008
  52. Brandon CaseyNov 3, 2008
  53. Andreas EricssonNov 3, 2008
  54. Brandon CaseyNov 3, 2008
  55. Andreas EricssonNov 4, 2008
  56. 2/3 packed_git: add new PACK_KEEP flag and haspackkeep() access macrodrafnel@gmail.com, Nov 2, 2008
  57. 3/3 pack-objects: honor '.keep' filesdrafnel@gmail.com, Nov 2, 2008
  58. Shawn O. PearceNov 3, 2008
  59. 1/3 t7700: demonstrate mishandling of loose objects in an alternate ODBdrafnel@gmail.com, Nov 10, 2008
  60. 2/3 sha1_file.c: split has_loose_object() into local and non-local counterpartsdrafnel@gmail.com, Nov 10, 2008
  61. 3/3 pack-objects: extend --local to mean ignore non-local loose objects toodrafnel@gmail.com, Nov 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.