From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Stefan Beller <sbeller@google.com>,
"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: [RFC/PATCH] Disallow commands from within unpopulated submodules.
Date: Fri, 20 Jan 2017 16:48:13 -0500 [thread overview]
Message-ID: <20170120214812.hhyjj3ldhhbrohlw@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqq37gdxvbx.fsf@gitster.mtv.corp.google.com>
On Fri, Jan 20, 2017 at 01:41:54PM -0800, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> >> And in my current understanding of submodules the check in
> >> .gitmodules ought to be enough, too.
> >
> > Yeah, that probably makes sense. You can have a gitlink without a
> > .gitmodules file, but I don't quite know what that would mean in terms
> > of submodules (I guess it's not a submodule but "something else").
>
> That may be a lot better than reading the index unconditionally, but
> I'd rather not to see "git rev-parse" read ".gitmodules" at all. It
> would discourage scripted use of Git for no good reason.
Why is that? Just because it makes rev-parse seem more bloated?
I think Stefan's putting it into git.c is confusing the issue a bit.
This is fundamentally about figuring out which git repository we're in,
and that procedure is the right place to put the check.
IOW, when we call setup_git_repository() we are already walking up the
tree and looking at .git/HEAD, .git/config, etc to see if we are in a
valid git repository. It doesn't seem unreasonable to me to make this
part of that check. I.e.:
- if we we walked up from the working tree (so we have a non-NULL
prefix); and
- if there is a .gitmodules file; and
- if the .gitmodules file shows that we were inside what _should_ have
been a submodule; then
- complain and do not accept the outer repository as a valid repo.
That adds only an extra failed open() for people who do not use
submodules, and an extra config-file parse for people who do. And then
only when they are not in the top-level of the working tree (so scripts,
etc that cd_to_toplevel wouldn't pay per-invocation).
-Peff
next prev parent reply other threads:[~2017-01-20 21:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-19 19:30 [RFC/PATCH] Disallow commands from within unpopulated submodules Stefan Beller
2017-01-20 19:17 ` Jeff King
2017-01-20 19:33 ` Stefan Beller
2017-01-20 19:42 ` Jeff King
2017-01-20 19:53 ` Stefan Beller
2017-01-20 20:00 ` Jeff King
2017-01-20 20:07 ` Stefan Beller
2017-01-20 21:41 ` Junio C Hamano
2017-01-20 21:48 ` Jeff King [this message]
2017-01-20 21:58 ` Junio C Hamano
2017-01-20 22:01 ` Jeff King
2017-01-20 23:22 ` Stefan Beller
2017-01-21 12:55 ` Duy Nguyen
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=20170120214812.hhyjj3ldhhbrohlw@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sbeller@google.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.
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).