On Sat, Jul 14, 2018 at 8:00 AM Peter Humphrey <pe...@prh.myzen.co.uk> wrote:
>
> That's all I need for the portage tree, unless removing everything at lower
> depths will remove the change records.

If you clone with a depth of one you'll see the current state of the
tree, and a commit message from the CI bot, and that is it.  You'll
have zero change history for anything.

If you clone with a dept of 10 you'll see one or two CI bot messages,
and then the last 8 or so actual changes to the tree.  You'll also
have access to what the tree looked like when each of those changes
was made.

Note that git uses COW and compression, so the cost of increasing your
depth isn't very high.  A depth of 1 costs you about 670M, and a depth
of 236000 costs you 1.5G.  I'd expect the cost to be roughly linear
between these.

>
> Is there something in git to do that purging? If not, perhaps a simple monthly
> script to delete /usr/portage/* - but not packages or distfiles, which are on
> separate partitions here - would do the trick.

That delete would certainly work, though it would cost you a full sync
(which would go back to your depth setting).  I'd suggest moving
distfiles outside of the repo if you're going to do that (really, it
shouldn't be inside anyway), just to make it easier.

git has no facilities to do this automatically, probably because it
isn't something Linus does and git is very much his thing.  However, I
found that this works for me:

git rev-parse HEAD >! .git/shallow
git reflog expire --expire=all --all
git gc --prune=now

(This is a combination of:
https://stackoverflow.com/a/34829535              (which doesn't work)
and
https://stackoverflow.com/a/46004595               (which is incomplete))

It runs in about 14s for me in a tmpfs.

Another option would be to a local shallow clone and swap the repositories.

You'll find tons of guides online for throwing out history that
involve rebasing.  You do NOT want to do this here.  These will change
the hash of the HEAD, which means that the next git pull won't be a
fast-forward, and it will be a mess in general.  You just want to
discard local history, not rewrite the repository to say that there
never was any history.

Also note that the first line in this little script depends somewhat
on git internals and may or may not work in the distant future.

In any case, I suggest trying it.  If it somehow eats your repo for
breakfast just delete it and the next sync will re-fetch.





--
Rich

Reply via email to