From: Michael J Gruber <git@drmicha.warpmail.net>
To: Thomas Rast <trast@student.ethz.ch>
Cc: git@vger.kernel.org
Subject: Re: Running git-archive recursively over submodules
Date: Tue, 16 Feb 2010 08:38:08 +0100 [thread overview]
Message-ID: <4B7A4B60.3090401@drmicha.warpmail.net> (raw)
In-Reply-To: <201002152156.17132.trast@student.ethz.ch>
Thomas Rast venit, vidit, dixit 15.02.2010 21:56:
> I'm posting this for posterity. It came out of an IRC discussion last
> night. Google "git archive submodules" currently finds two scripts
> for the same task:
>
> * http://kerneltrap.org/mailarchive/git/2008/3/29/1294614
> Can pack arbitrary revisions, but seems to be highly specific to the
> poster's setup.
>
> * http://wiki.github.com/meitar/git-archive-all.sh/
> Appears to work with normal repos (I haven't really tested) but only
> packs HEAD.
>
> Both have in common that they run git-archive in each submodule, and
> then merge the resulting tars.
>
> The script below follows a different approach, based on the idea that
> all the objects are already there, you just need to help git find
> them. This of course assumes that you have the submodules checked out
> (or at least cloned). It builds an index that contains a flattened
> version of the repository and all submodules. This works for any
> revision you specify. The downside is that this does not respect
> .gitattributes.
>
> The same trick can be used for other commands, so if people find this
> useful it could be added to git-submodule.
>
> Warning: Error detection and such are left as an exercise to the user.
>
> -- 8< --
> #!/bin/sh
>
> export revision="$1"
>
> export GIT_INDEX_FILE=".git/tmpindex"
> rm -f "$GIT_INDEX_FILE"
>
> git read-tree $revision
>
> export up="$(pwd)"
>
> read_one_level () {
> export GIT_ALTERNATE_OBJECT_DIRECTORIES="$GIT_ALTERNATE_OBJECT_DIRECTORIES":$(
> git submodule foreach 'echo "$up/$path/.git/objects"' |
> grep -E -v '^(Entering|No submodule mapping found)' |
> tr '\n' : |
> sed 's/:$//'
> )
>
> git submodule foreach '
> cd "$up"
> subcommit=$(git rev-parse :"$path")
> git rm --cached "$path"
> git read-tree -i --prefix="$path/" $subcommit
> ' >/dev/null
> }
>
> while git ls-files -s | grep -q ^160000; do
> read_one_level
> done
Am I blind, not seeing a recursion, or is there simply none? I reckon
you're reading the super project and one level of submodules into the
temporary index - which is fine for most purposes, of course. I would
say this is iterating over the submodules of the super project.
> git archive --format=tar $(git write-tree)
>
> rm -f "$GIT_INDEX_FILE"
> -- >8 --
>
next prev parent reply other threads:[~2010-02-16 7:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-15 20:56 Running git-archive recursively over submodules Thomas Rast
2010-02-16 7:38 ` Michael J Gruber [this message]
2010-02-16 10:01 ` Thomas Rast
2010-02-16 10:49 ` Michael J Gruber
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B7A4B60.3090401@drmicha.warpmail.net \
--to=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=trast@student.ethz.ch \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).