git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] Fix submodule status of dirs initialized but empty
@ 2020-01-14 14:02 Peter Kästle
  2020-01-21 10:12 ` [PATCH v2] Fix status of initialized but not cloned submodules Peter Kaestle
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Kästle @ 2020-01-14 14:02 UTC (permalink / raw)
  To: git, Christian Couder, Stefan Beller, Prathamesh Chavan,
	Junio C Hamano

Fix submodule status of dirs initialized but empty

Original bash helper for "submodule status" was doing a check for
initialized but not cloned submodules and prefixed them with "-" in case 
.git
was missing inside the submodule directory.
This check was skipped when originally porting the functionality
from bash to C.

Signed-off-by: Peter Kaestle <peter.kaestle@nokia.com>
---
  builtin/submodule--helper.c |   15 +++++++++++++--
  1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index c72931e..50bb692 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'"),
@@ -793,11 +796,19 @@ static void status_submodule(const char *path, 
const struct object_id *ce_oid,
  		print_status(flags, 'U', path, &null_oid, displaypath);
  		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", "--",
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-02-02 23:33 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 14:02 [PATCH] Fix submodule status of dirs initialized but empty Peter Kästle
2020-01-21 10:12 ` [PATCH v2] Fix status of initialized but not cloned submodules Peter Kaestle
2020-01-23 21:12   ` 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

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).