Subject: Re: Bringing a bit more sanity to $GIT_DIR/objects/info/alternates?

From: Junio C Hamano <[email-masked]>
Date: Mon, 06 Aug 2012 14:55:35 -0700

Junio C Hamano <[email-masked]> writes:

>  - When you have one object store and a repository that does not yet
>    borrow from it, you may want to make the repository borrow from
>    the object store.  Obviously you can run "echo" like the sample
>    script in the previous item above, but it is not obvious how to
>    perform the logical next step of shrinking $GIT_DIR/objects of
>    the repository that now borrows the objects.
>
>    I think "git repack -a -d" is the way to do this, but if you
>    compare this command to "git repack -a -d -f" we saw previously
>    in this message, it is not surprising that the users would be
>    confused---it is not obvious at all.
>
>    Some ideas:
>
>    - (obvious: give a canned subcommand to do this)

The analysis of this item is wrong, I think.  "git repack -a -d -l"
should be the way to do so.

The message looks wrong when it turns out that there is no need to
have any object in the borrowing repository, though.  We only see
"Nothing new to pack" (which technically is correct), and the
command exits successfully.  You can peek .git/objects/ to find out
that all the objects the borrower used to have its own copy are now
gone (because they are available at the alternate), but the message
gives a false impression that we thought about doing something,
found nothing new to be packed, and gave up without doing anything.

But that is not what is happening.  We traversed the connectivity,
found that all the objects necessary for our history are housed in
our alternates, gave "Nothing new to pack" (because we do not have
to have any object on our own), and then removed all the object
files and packs in our repository.