From: Junio C Hamano <gitster@pobox•com>
To: Jens Lehmann <Jens.Lehmann@web•de>
Cc: Lars Hjemli <hjemli@gmail•com>,
Jonathan Nieder <jrnieder@gmail•com>,
git@vger•kernel.org, Heiko Voigt <hvoigt@hvoigt•net>
Subject: Re: [PATCH v4 1/2] for-each-repo: new command used for multi-repo operations
Date: Sun, 03 Feb 2013 22:41:41 -0800 [thread overview]
Message-ID: <7vip6860nu.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <5106ECB6.9010801@web.de> (Jens Lehmann's message of "Mon, 28 Jan 2013 22:25:10 +0100")
Jens Lehmann <Jens.Lehmann@web•de> writes:
> Am 28.01.2013 21:34, schrieb Junio C Hamano:
> ...
>> I was imagining that "foreach --untracked" could go something like this:
>>
>> * If you are inside an existing git repository, read its index to
>> learn the gitlinks in the directory and its subdirectories.
>>
>> * Start from the current directory and recursively apply the
>> procedure in this step:
>>
>> * Scan the directory and iterate over the ones that has ".git" in
>> it:
>>
>> * If it is a gitlinked one, show it, but do not descend into it
>> unless --recursive is given (e.g. you start from /home/jens,
>> find /home/jens/proj/ directory that has /home/jens/proj/.git
>> in it. /home/jens/.git/index knows that it is a submodule of
>> the top-level superproject. "proj" is handled, and it is up
>> to the --recursive option if its submodules are handled).
>>
>> * If it is _not_ a gitlinked one, show it and descend into it
>> (e.g. /home/jens/ is not a repository or /home/jens/proj is
>> not a tracked submodule) to apply this procedure recursively.
>>
>> Of course, without --untracked, we have no need to iterate over the
>> readdir() return values; instead we just scan the index of the
>> top-level superproject.
>
> Thanks for explaining, that makes tons of sense.
There is a small thinko above, though, and I'd like to correct it
before anybody takes the above too seriously as _the_ outline of the
design and implements it to the letter.
The --recursive option should govern both a tracked submodule and an
untracked one. When asking to list both existing submodules and
directories that could become submodules, you should be able to say
$ git submodule foreach --untracked
to list the direct submodules and the directories with .git in them
that are not yet submodules of the top-level superproject, but the
latter is limited to those with no parent directories with .git in
them (other than the top-level of the working tree of the
superproject). With
$ git submodule foreach --untracked --recursive
you would see submodules and their submodules recursively, and also
directories with .git in them (i.e. candidates to become direct
submodules of the superproject) and the directories with .git in
them inside such submodule candidates (i.e. candidates to become
direct submodules of the directories that could become direct
submodules of the superproject) recursively.
If we set things up this way:
mkdir -p a/b c/d &&
for d in . a a/b c c/d
do
git init $d &&
( cd $d && git commit --allow-empty -m initial )
done &&
git add a &&
( cd a && git add b )
The expected results for various combinations are:
* "git submodule foreach" would visit 'a' and nothing else;
* "git submodule foreach --recursive" would visit 'a' and 'a/b';
* "git submodule foreach --untracked" would visit 'a' and 'c'; and
* "git submodule foreach --untracked --recursive" would visit all four.
next prev parent reply other threads:[~2013-02-04 6:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-27 12:46 [PATCH v4 0/2] for-each-repo: new command for multi-repo operations Lars Hjemli
2013-01-27 12:46 ` [PATCH v4 1/2] for-each-repo: new command used " Lars Hjemli
2013-01-27 19:04 ` Junio C Hamano
2013-01-27 19:42 ` John Keeping
2013-01-27 19:45 ` Junio C Hamano
2013-01-28 7:50 ` Lars Hjemli
2013-01-28 8:10 ` Jonathan Nieder
2013-01-28 17:11 ` Lars Hjemli
2013-01-28 18:35 ` Junio C Hamano
2013-01-28 17:45 ` Junio C Hamano
2013-01-28 18:35 ` Lars Hjemli
2013-01-28 18:51 ` Junio C Hamano
2013-01-28 19:42 ` Lars Hjemli
2013-01-28 20:12 ` Jens Lehmann
2013-01-28 20:34 ` Junio C Hamano
2013-01-28 21:25 ` Jens Lehmann
2013-02-04 6:41 ` Junio C Hamano [this message]
2013-01-27 12:46 ` [PATCH v4 2/2] git: rewrite `git -a` to become a git-for-each-repo command Lars Hjemli
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=7vip6860nu.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox$(echo .)com \
--cc=Jens.Lehmann@web$(echo .)de \
--cc=git@vger$(echo .)kernel.org \
--cc=hjemli@gmail$(echo .)com \
--cc=hvoigt@hvoigt$(echo .)net \
--cc=jrnieder@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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