From: Stefan Beller <sbeller@google.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Andrew J <andj2223@gmail.com>,
"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Strangeness with git-add and nested repositories
Date: Thu, 28 Apr 2016 09:54:23 -0700 [thread overview]
Message-ID: <CAGZ79ka0WB58HyHYXAkaMYKccWD-NwSxhRUGHvq1TrA_ix+Hxw@mail.gmail.com> (raw)
In-Reply-To: <xmqq1t5p7kmp.fsf@gitster.mtv.corp.google.com>
On Thu, Apr 28, 2016 at 9:39 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Stefan Beller <sbeller@google.com> writes:
>
>> I think (pure speculation), that it the error is in the context
>> (repository) switching logic.
>> What happens if you alter the order, i.e. give testfile first and then
>> the files in the nested
>> repos?
>>
>> git add -- file path/to/subdir/file
>>
>> should do internally IMHO:
>>
>> git add file
>> git -C path-to-subdir add file
>
> My undertanding of what _should_ happen in the world order as
> currently defined (not necessarily implemented) is:
>
> * "git add -- A B" must work the same way as "git add -- B A" and
> "git add -- A; git add -- B"
I agree.
>
> * "git add -- path/to/subdir/file", when any of path/, path/to/,
> path/to/subdir/ is a Git repository that is different from the
> current Git repository, must fail.
I agree that this is the current expectation for the world order.
However I would like to propose to change that eventually.
(Once the submodule groups are there and we can treat
submodules as a special form of narrow checkout, we want to
have the feature of adding across submodules and even committing
across submodules/repos, I would think)
>
> IOW, if 'path' is a repository (whether it is known as a submodule
> to the repository whose working tree contains it, or it is an
> untracked directory from the containing repository's point of view),
> the index of the containing repository cannot get path/$anything in
> it. If you managed to do so, you found a bug [*1*].
>
> path/.git/index can of course have "to/subdir/file" in it, and from
> that point of view, "git -C path/to/subdir add file" may one day
> become an improved world order. It is just we haven't discussed
> that possibility or reached concensus that it is a good idea.
>
>
> [Footnote]
>
> *1* Of course, some of the bugs in this class may fundamentally be
> unfixable and would fall into the same category as "doctor, it
> hurts when I do this--don't do it then". For example, you may
> treat path/ as the top of the working tree of another repository
> whose git-dir is not at path/.git by arranging GIT_WORK_TREE and
> GIT_DIR environment variables, but you may do so only when you
> actually are accessing the contents of path/ as its own project.
> And when you are using the enclosing project (whose .git/ would
> sit next to path/), there is no way for "git add path/to/file"
> to know that everything under "path/" does not belong to the
> current repository and instead it is part of the project rooted
> at path/, which is an obvious example of "fundamentally
> unfixable" case.
>
next prev parent reply other threads:[~2016-04-28 16:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-27 8:31 Strangeness with git-add and nested repositories Andrew J
2016-04-27 16:08 ` Stefan Beller
2016-04-28 6:10 ` Andrew J
2016-04-28 16:35 ` Stefan Beller
2016-04-28 16:39 ` Junio C Hamano
2016-04-28 16:48 ` Junio C Hamano
2016-04-29 2:11 ` Andrew J
2016-04-28 16:54 ` Stefan Beller [this message]
2016-04-29 2:51 ` Junio C Hamano
2016-04-29 2:54 ` Junio C Hamano
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=CAGZ79ka0WB58HyHYXAkaMYKccWD-NwSxhRUGHvq1TrA_ix+Hxw@mail.gmail.com \
--to=sbeller@google.com \
--cc=andj2223@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).