From: Junio C Hamano <junkio@cox.net>
To: Ben Lau <benlau@ust.hk>
Cc: git@vger.kernel.org
Subject: Re: Clone a repository with only the objects needed for a single tag
Date: Wed, 02 Nov 2005 01:20:42 -0800 [thread overview]
Message-ID: <7voe53v21h.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <43687869.7060104@ust.hk> (Ben Lau's message of "Wed, 02 Nov 2005 16:27:21 +0800")
Ben Lau <benlau@ust.hk> writes:
> However, it has a problem when involves the gitk/git-log.
That's why I said anything that requires you to have a complete
history would not work.
The shallow repository is by definition a *broken* repository;
the refs are supposed to mean the repository has everything
reachable from them, and many tools rely on that assumption, but
the shallow setup deliberately breaks that assumption, so you
need to be aware of what operations you can and cannot do
without having the full history. Although using grafts to
cauterize somewhat helps as you discovered, you are operating in
"do it at your own risk" territory.
Having said that, here are the things that *should* work without
having full history (not many):
. git diff between your index, working tree, and commits
your shallow setup happens to have.
. git commit on top of any of the tip of branches your
shallow copy started out with, including git am and git
applymbox.
. git fetch/pull over commit walker from a remote
repository.
. git push to send the work done in the shallow repository
back into your mothership repository (running git pull on
the mothership to fetch from the shallow copy probably
would not work, unless you use commit walkers).
. git whatchanged, git log, and gitk to view the work
you did in your shallow repository.
Creating packs in the mothership repository is certainly
possible. You could instead do this:
$ git-shallow-pack --all ;# in mothership
$ mkdir -p /var/tmp/shallow
$ tar cf - .git/HEAD .git/refs/ |
(cd /var/tmp/shallow; git-init-db; tar xf -)
$ mv pack-* /var/tmp/shallow/.git/objects/pack
If you want a bit deeper history, instead of giving '--all' to
git-shallow-pack, you could probably say something silly like
this:
$ (git-rev-parse --all; git-rev-list --max-count=20 HEAD) |
xargs git-shallow-pack
The shallow-pack script I sent earlier is probably not very
useful in practice. To polish it to be somewhat more useful, it
would probably need the following enhancements, at least:
. Instead of taking 'git-rev-parse' arguments, take the
names of refs;
. Instead of packing the objects contained in the
commits and trees the named refs reference, include
all blobs/trees/commits between the given refs and
their common ancestor to create a pack;
. Create a tarball that contains:
(1) the pack file created by the above procedure,
stored in .git/objects/pack/.;
(2) .git/refs/ to be used in the shallow copy; this
should include only the refs given to the command
to create the above pack.
(3) .git/info/grafts to cauterize the common ancestor
commit and side branches merged into the lines you
are taking (computing the latter may be somewhat
expensive).
Then the command can be run in the mothership repository like
this:
$ cd linux-2.6
$ git-shallow-pack v2.6.14 v2.6.14-rc2 master
to produce a tarball, which can be taken to another location.
When extracted, it would contain all commits between the three
named refs, and you could view the history across them.
prev parent reply other threads:[~2005-11-02 9:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-02 2:02 Clone a repository with only the objects needed for a single tag Ben Lau
2005-11-02 7:01 ` Junio C Hamano
2005-11-02 8:27 ` Ben Lau
2005-11-02 8:49 ` Andreas Ericsson
2005-11-02 9:10 ` Ben Lau
2005-11-02 9:20 ` Junio C Hamano [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=7voe53v21h.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=benlau@ust.hk \
--cc=git@vger.kernel.org \
/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).