git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: sergio <sergio.callegari@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: git gc does not discard objects found in alternate unless the?alternate storage is packed
Date: Mon, 11 Aug 2008 07:33:08 -0700	[thread overview]
Message-ID: <20080811143308.GA26363@spearce.org> (raw)
In-Reply-To: <loom.20080811T101110-879@post.gmane.org>

sergio <sergio.callegari@gmail.com> wrote:
> Shawn O. Pearce <spearce <at> spearce.org> writes:
> > Sergio <sergio.callegari <at> gmail.com> wrote:
> > >
> > > Is it the intended behaviour?
> > 
> > This is the current (intended) behavior.  We have never pruned an
> > object from a repository unless the object is packed in the shared
> > alternate repository.  See git-prune-packed's man page.  The prune
> > logic for loose objects only deletes objects which are in packs,
> > and it doesn't care where that pack came from.
> 
> Many thanks for the explanation.
> Two more questions:
> 1) Is there a way to prune objects that are anyway available at the alternate
> without touching the alternate (to repack it)?

No, no such function exists today in Git.  Why?  Because nobody has
coded it.  We needed git-prune-packed for local repository usage
once git-repack has finished its main work of running pack-objects
to produce a new pack file.  This extended nicely into also pruning
loose objects which are also available from a shared database,
as the code was actually identical.

> 2) Would there be any contraindication in doing so? (namely, is the current
> behaviour of git gc a mere consequence of the prune-packed logic or a behaviour
> purposely introduced for safety?)

Well, yes and no.

The first part of the answer is that yes, one could delete the
object from the clone if it is available loose in the alternate.
The object can still be read through the alternate, so there is no
data loss, and thus it really is just a matter of someone writing
the necessary code to implement this prune function.

The second part of the answer is that no, doing this deletion may
make it less safe to use the alternate as an alternate.  The reason
is that objects which are contained in pack files are likely to
be reachable in the alternate, and thus won't disappear during a
later git-prune invocation, as they are needed by that alternate.

This assumption is based upon the fact that an object only goes
into a pack file if it is reachable in that repository, as the
packing code uses reachability to determine what to pack.

Relying upon a loose object may cause breakage later on if the
alternate doesn't actually need that object and prunes it away,
and the clone doesn't have it either.

However, this pack based assumption can fail anyway if the
alternate repository rewinds a branch and repacks.  The object you
were relying on in the alternate may now be ejected into a loose
object, or discarded altogether, and the clone will (eventually)
break anyway when the object(s) it needs goes missing.

So it is sort-of a safety measure, but its a crude one at best.
And it only works about some X% of the time, where X is well
under 100.  :-)

-- 
Shawn.

      reply	other threads:[~2008-08-11 14:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-10 21:07 git gc does not discard objects found in alternate unless the alternate storage is packed Sergio
2008-08-11  2:54 ` Shawn O. Pearce
2008-08-11 10:16   ` sergio
2008-08-11 14:33     ` Shawn O. Pearce [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080811143308.GA26363@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=sergio.callegari@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).