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

Re: How to stop sharing objects between repositories

From
Jeff King <peff@peff.net>
Date
Aug 17, 2009, 06:19 UTC
Message-ID
<20090817061916.GA27530@coredump.intra.peff.net>
In-Reply-To
<7vmy5z603d.fsf@alter.siamese.dyndns.org>
On Sun, Aug 16, 2009 at 12:16:22PM -0700, Junio C Hamano wrote:
Show 14 quoted lines
> After reading this, two points come to my mind.  They may or may not be
> issues.
> 
>  (1) Such a user does not necessarily know a casual "git repack -a" breaks
>      the dependency, defeating the -s option s/he deliberately used in
>      order to save disk space in the first place.  Perhaps we can reword
>      this further to kill two penguins with a single stone?
> 
> 	Note that the pack resulting from running `git repack -a` in the
> 	repository cloned with the `-s` option will include objects that
> 	are borrowed from the source repository.  It essentially breaks
> 	the dependency created by cloning with the `-s` option by copying
> 	the objects from the source repository.  To keep borrowing from
> 	the source repository to save disk space, do not use `repack -a`.

Good point, but I don't think this wording is quite right. You can also cause such an inefficiency by simply running "git repack", if the source has loose objects. In other words:

  1. "git repack -a" is sufficient to break dependency, as it copies
     both packed and loose objects
  2. "git repack" _may_ break the dependency, if there are no packs, as
     it copies only loose objects. It _may_ introduce inefficiency, but
     only if there are loose objects.
  3. "git repack -l" always keeps the dependency and current efficiency.
     As an aside, making this list makes me realize there is no easy
     "keep the dependency and increase efficiency". In other words, pack
     everything that is not available otherwise, and then prune the
     remaining packs.
Modified patch is below.
>      We should suggest an alternative immediately after this sentence,
>      e.g. "Instead, use `repack -l`" or something, but somebody should
>      check if it is a valid/viable alternative.

It does work. From a user's perspective, I think "-l" would probably be a more sane default. But I think it is off for historical reasons, and these days we try to steer users towards "git gc", anyway, which does use "-l" by default.

-- >8 --
Subject: [PATCH] docs: describe impact of repack on "clone -s"

The effects of repacking on a repository with alternates are a bit subtle. The two main things users will want are:

  1. Not to waste disk space by accidentally copying objects
     which could be shared.
  2. Copying all objects explicitly to break the dependency
     on the source repo.

This patch describes both under the "clone -s" documentation. It makes sense to put it there rather than in git-repack.txt for both cases. For (1), we are warning the user who is using "clone -s" about what _not_ to do, so we need to get their attention when reading about "clone -s". For (2), we are telling them how git-repack can be used to accomplish a task, but until they know that git-repack is the right tool, they have no reason to look at the repack documentation.

Signed-off-by: Jeff King <peff@peff.net>
---

The extra deleted lines in the patch below are just cleaning up some excess whitespace.

 Documentation/git-clone.txt |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index b14de6c..b25944f 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -72,8 +72,16 @@ These objects may be removed by normal git operations (such as 'git-commit')
 which automatically call `git gc --auto`. (See linkgit:git-gc[1].)
 If these objects are removed and were referenced by the cloned repository,
 then the cloned repository will become corrupt.
-
-
++
+Note that running `git repack` without the `-l` option in a repository
+cloned with `-s` will copy objects from the source repository into a
+pack in the cloned repository, removing the disk space savings of `clone
+-s`. It is safe, however, to run `git gc`, which uses the `-l` option by
+default.
++
+If you want to break the dependency of a repository cloned with `-s` on
+its source repository, you can simply run `git repack -a` to copy all
+objects from the source repository into a pack in the cloned repository.
 
 --reference <repository>::
 	If the reference repository is on the local machine
-- 
1.6.4.283.gec993
Previous: Jeff KingNext: Jeff King
Message 16 of 18 in “How to stop sharing objects between repositories”
  1. Jon JensenAug 16, 2009
  2. Johannes SchindelinAug 16, 2009
  3. Jeff KingAug 16, 2009
  4. Johannes SchindelinAug 16, 2009
  5. Daniel VilleneuveAug 16, 2009
  6. Johannes SchindelinAug 16, 2009
  7. Jeff KingAug 16, 2009
  8. Junio C HamanoAug 16, 2009
  9. Mike GalbraithAug 17, 2009
  10. Jeff KingAug 17, 2009
  11. Mike GalbraithAug 17, 2009
  12. Junio C HamanoAug 17, 2009
  13. Jeff KingAug 17, 2009
  14. Junio C HamanoAug 17, 2009
  15. Jeff KingAug 17, 2009
  16. Jeff KingAug 17, 2009
  17. Jeff KingAug 17, 2009
  18. Jeff KingAug 17, 2009

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.