From: Brandon Williams <bmwill@google.com>
To: paul@myitcv.io
Cc: gitster@pobox.com, git@vger.kernel.org, jacob.keller@gmail.com
Subject: Re: [PATCH 3/2] ls-files: only recurse on active submodules
Date: Fri, 12 May 2017 10:26:57 -0700 [thread overview]
Message-ID: <20170512172657.GA98586@google.com> (raw)
In-Reply-To: <20170512162109.49752-1-paul@myitcv.io>
On 05/12, paul@myitcv.io wrote:
> > ...
>
> I'm nowhere near up to speed with the entire history of this chain so
> please excuse me if I've missed some detail somewhere.
>
> As of b06d3643105c8758ed019125a4399cb7efdcce2c, the following command
> "hangs" at near 100% CPU in a repo of mine:
>
> git ls-files --recurse-submodules
>
> The "hang" appears to be an explosion of subprocesses (snipped the
> COMMAND detail from ps):
>
> git ls-files --recurse-submodules
> git --super-prefix=g/_vendor/src/github.com/ramya-rao-a/go-outline/ ls-files --recurse-submodules --
> git --super-prefix=g/_vendor/src/github.com/ramya-rao-a/go-outline/g/_vendor/src/github.com/ramya-rao-a/go-outline/ ls-files --recurse-submodules --
> ....
Yeah the way the recursion works as of 2.13 is that a new process is
spawned for each submodule. This really is kind of clunky and I'd like
to move to an implementation which doesn't require spawning a ton of
processes, so that's a goal of mine I'm trying to work towards. This is
still a relatively new feature so I expect there's still a lot of bugs to
iron out.
>
> In v2.11.0 I simply get a fatal error (this repo doesn't actually
> contain any submodules):
>
> fatal: can't use --super-prefix from a subdirectory
>
> I haven't yet been able to work out what's special about the
> subdirectory g/_vendor/src/github.com/ramya-rao-a/go-outline/
>
> Is this expected? (I'm guessing not)
>
> How can I help diagnose what's going on here?
Looking at this it appears to me that you have a submodule loop, either
directly or indirectly. That is if you have a repo 'a' which contains a
submodule 'b' and repo 'b' happens to contain 'a' as a submodule you'd
find yourself with an infinite loop. But that's what I'm guessing
based on that output you've shown me.
But you're saying that this repo doesn't actually contain submodules?
Hmm then I'm at a loss...unless!
The directory 'go-outline' is a place holder for a submodule so ls-files
spawns a process in that directory. But since its not populated, during
the gitdir discovery it falls back to the superproject's gitdir,
restarting the whole process and creating an infinite loop...
Welp that's a pretty terrible bug which stems from
missing a check to see if a submodule is initialized, and not explicitly
setting GIT_DIR=.git (theres cases where we don't want this but turns
out we probably should do that here). Let me know if this fixes the
problem:
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index a6c70dbe9..b0796fc10 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -206,7 +206,6 @@ static void show_gitlink(const struct cache_entry *ce)
char *dir;
prepare_submodule_repo_env(&cp.env_array);
- argv_array_push(&cp.env_array, GIT_DIR_ENVIRONMENT);
if (prefix_len)
argv_array_pushf(&cp.env_array, "%s=%s",
@@ -242,6 +241,7 @@ static void show_ce_entry(const char *tag, const struct cache_entry *ce)
die("git ls-files: internal error - cache entry not superset of prefix");
if (recurse_submodules && S_ISGITLINK(ce->ce_mode) &&
+ is_submodule_initialized(ce->name) &&
submodule_path_match(&pathspec, name.buf, ps_matched)) {
show_gitlink(ce);
} else if (match_pathspec(&pathspec, name.buf, name.len,
@@ -611,8 +611,10 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
if (require_work_tree && !is_inside_work_tree())
setup_work_tree();
- if (recurse_submodules)
+ if (recurse_submodules) {
+ gitmodules_config();
compile_submodule_options(argv, &dir, show_tag);
+ }
if (recurse_submodules &&
(show_stage || show_deleted || show_others || show_unmerged ||
--
Brandon Williams
next prev parent reply other threads:[~2017-05-12 17:27 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-12 0:39 [PATCH] ls-files: properly prepare submodule environment Jacob Keller
2017-04-12 16:58 ` Brandon Williams
2017-04-12 22:45 ` Jacob Keller
2017-04-13 17:12 ` [PATCH v2 1/2] ls-files: fix recurse-submodules with nested submodules Jacob Keller
2017-04-13 17:12 ` [PATCH v2 2/2] ls-files: fix path used when recursing into submodules Jacob Keller
2017-04-13 18:10 ` Brandon Williams
2017-04-13 18:15 ` Stefan Beller
2017-04-13 18:34 ` Jacob Keller
2017-04-18 2:03 ` Junio C Hamano
2017-04-18 7:42 ` Jacob Keller
2017-04-18 18:41 ` Stefan Beller
2017-04-13 18:03 ` [PATCH v2 1/2] ls-files: fix recurse-submodules with nested submodules Brandon Williams
2017-04-13 18:31 ` Jacob Keller
2017-04-13 18:35 ` Stefan Beller
2017-04-13 18:36 ` Brandon Williams
2017-04-13 18:57 ` [PATCH 3/2] ls-files: only recurse on active submodules Brandon Williams
2017-04-13 19:05 ` Stefan Beller
2017-04-13 19:12 ` Jacob Keller
2017-04-13 19:25 ` Stefan Beller
2017-04-13 19:30 ` Jacob Keller
2017-04-14 16:33 ` Jacob Keller
2017-04-14 17:02 ` Stefan Beller
2017-04-14 23:49 ` Jacob Keller
2017-04-19 1:03 ` Junio C Hamano
2017-05-12 16:21 ` paul
2017-05-12 17:26 ` Brandon Williams [this message]
2017-05-12 18:12 ` Paul Jolly
2017-05-12 18:19 ` Brandon Williams
2017-08-01 18:16 ` Paul Jolly
[not found] ` <CACoUkn7i76dEsQa3eoN+7WR8QmsD1pWsRQ0dvhkxzFN0sxTmRQ@mail.gmail.com>
2017-08-01 18:18 ` Brandon Williams
2017-08-01 18:19 ` Paul Jolly
2017-08-01 18:20 ` Brandon Williams
2017-08-01 18:41 ` 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=20170512172657.GA98586@google.com \
--to=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jacob.keller@gmail.com \
--cc=paul@myitcv.io \
/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).