From: Brandon Williams <bmwill@google.com>
To: git@vger.kernel.org, jacob.keller@gmail.com
Cc: Brandon Williams <bmwill@google.com>
Subject: [PATCH 3/2] ls-files: only recurse on active submodules
Date: Thu, 13 Apr 2017 11:57:07 -0700 [thread overview]
Message-ID: <20170413185707.97746-1-bmwill@google.com> (raw)
In-Reply-To: <20170413171224.3537-1-jacob.e.keller@intel.com>
Add in a check to see if a submodule is active before attempting to
recurse. This prevents 'ls-files' from trying to operate on a submodule
which may not exist in the working directory.
Signed-off-by: Brandon Williams <bmwill@google.com>
---
After you mentioned possibly needing to check if a submodule is initialized, I
went back and noticed that there was indeed no check for it...So this patch
adds in the necessary check to see if a submodule is active or not before
attempting to recurse.
builtin/ls-files.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index d449e46db..10ddc0306 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -15,6 +15,7 @@
#include "string-list.h"
#include "pathspec.h"
#include "run-command.h"
+#include "submodule.h"
static int abbrev;
static int show_deleted;
@@ -235,7 +236,8 @@ 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) &&
- submodule_path_match(&pathspec, name.buf, ps_matched)) {
+ submodule_path_match(&pathspec, name.buf, ps_matched) &&
+ is_submodule_initialized(ce->name)) {
show_gitlink(ce);
} else if (match_pathspec(&pathspec, name.buf, name.len,
len, ps_matched,
@@ -604,8 +606,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 ||
--
2.12.2.762.g0e3151a226-goog
next prev parent reply other threads:[~2017-04-13 18:57 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 ` Brandon Williams [this message]
2017-04-13 19:05 ` [PATCH 3/2] ls-files: only recurse on active submodules 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
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=20170413185707.97746-1-bmwill@google.com \
--to=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=jacob.keller@gmail.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).