diff options
author | Peter Kaestle <peter.kaestle@nokia.com> | 2020-01-24 11:34:04 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-01-27 10:14:00 -0800 |
commit | 3b2885ec9ba0b1328858231c9f5095e7f85d9f23 (patch) | |
tree | 72fe6c18f213372acc827d00b2cffa58917da059 | |
parent | t7400: add a testcase for submodule status on empty dirs (diff) | |
download | tgif-3b2885ec9ba0b1328858231c9f5095e7f85d9f23.tar.xz |
submodule: fix status of initialized but not cloned submodules
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/submodule--helper.c | 12 | ||||
-rwxr-xr-x | t/t7400-submodule-basic.sh | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index ad8df0d471..ecec9378cb 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -781,6 +781,8 @@ 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'"), @@ -793,10 +795,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", "--", diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 5c9acb80af..86b424f634 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -377,7 +377,7 @@ test_expect_success 'init should register submodule url in .git/config' ' test_cmp expect url ' -test_expect_failure 'status should still be "missing" after initializing' ' +test_expect_success 'status should still be "missing" after initializing' ' rm -fr init && mkdir init && git submodule status >lines && |