From: Peter Kaestle <peter.kaestle@nokia.com>
To: git@vger.kernel.org, christian.couder@gmail.com,
sbeller@google.com, pc44800@gmail.com, gitster@pobox.com
Cc: Peter Kaestle <peter.kaestle@nokia.com>
Subject: [PATCH v2] Fix status of initialized but not cloned submodules
Date: Tue, 21 Jan 2020 11:12:12 +0100 [thread overview]
Message-ID: <1579601532-10694-1-git-send-email-peter.kaestle@nokia.com> (raw)
In-Reply-To: <23e3d410-5271-a919-aa03-9e776cf72f7c@nokia.com>
Original bash helper for "submodule status" was doing a check for
initialized but not cloned submodules and prefixed the status with
a minus sign in case no .git file or folder was found inside the
submodule directory.
This check was missed when the original port of the functionality
from bash to C was done.
Signed-off-by: Peter Kaestle <peter.kaestle@nokia.com>
---
builtin/submodule--helper.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index c72931e..c04241b 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -782,6 +782,9 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
struct argv_array diff_files_args = ARGV_ARRAY_INIT;
struct rev_info rev;
int diff_files_result;
+ struct strbuf buf = STRBUF_INIT;
+ const char *git_dir;
+
if (!submodule_from_path(the_repository, &null_oid, path))
die(_("no submodule mapping found in .gitmodules for path '%s'"),
@@ -794,10 +797,18 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
goto cleanup;
}
- if (!is_submodule_active(the_repository, path)) {
+ strbuf_addf(&buf, "%s/.git", path);
+ git_dir = read_gitfile(buf.buf);
+ if (!git_dir)
+ git_dir = buf.buf;
+
+ if (!is_submodule_active(the_repository, path) ||
+ !is_git_directory(git_dir)) {
print_status(flags, '-', path, ce_oid, displaypath);
+ strbuf_release(&buf);
goto cleanup;
}
+ strbuf_release(&buf);
argv_array_pushl(&diff_files_args, "diff-files",
"--ignore-submodules=dirty", "--quiet", "--",
--
2.6.2
next prev parent reply other threads:[~2020-01-21 10:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-14 14:02 [PATCH] Fix submodule status of dirs initialized but empty Peter Kästle
2020-01-21 10:12 ` Peter Kaestle [this message]
2020-01-23 21:12 ` [PATCH v2] Fix status of initialized but not cloned submodules Junio C Hamano
2020-01-24 10:34 ` [PATCH v3 1/2] Testcase for submodule status on empty dirs Peter Kaestle
2020-01-24 10:34 ` [PATCH v3 2/2] Fix status of initialized but not cloned submodules Peter Kaestle
2020-01-24 17:35 ` [PATCH v3 1/2] Testcase for submodule status on empty dirs Junio C Hamano
2020-01-27 9:06 ` [PATCH v4 1/2] t7400: add a testcase " Peter Kaestle
2020-01-27 9:06 ` [PATCH v4 2/2] Fix status of initialized but not cloned submodules Peter Kaestle
2020-01-27 18:15 ` [PATCH v4 1/2] t7400: add a testcase for submodule status on empty dirs Junio C Hamano
2020-01-28 8:16 ` Peter Kästle
2020-02-02 23:32 ` [PATCH] t7400: testcase for submodule status on unregistered inner git repos Peter Kaestle
2020-01-24 11:55 ` [PATCH v2] Fix status of initialized but not cloned submodules Peter Kästle
2020-01-24 17:16 ` Junio C Hamano
2020-01-27 8:52 ` Peter Kästle
2020-01-27 18:18 ` Junio C Hamano
2020-02-02 23:16 ` Peter Kästle
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=1579601532-10694-1-git-send-email-peter.kaestle@nokia.com \
--to=peter.kaestle@nokia.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pc44800@gmail.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.
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).