git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] Fix status of initialized but not cloned submodules

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 23, 2020, 21:12 UTC
Message-ID
<xmqq4kwl512y.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<1579601532-10694-1-git-send-email-peter.kaestle@nokia.com>
Peter Kaestle <peter.kaestle@nokia.com> writes:
Show 11 quoted lines
> 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(-)
I wonder if this is easily protectable with an additional test.

In general, do we have a good coverage of "git status" output that involves submodules in various states?

Thanks.
Show 34 quoted lines
> 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", "--",
Previous: Peter KaestleNext: Peter Kaestle
Message 3 of 16 in “Fix submodule status of dirs initialized but empty”
  1. Fix submodule status of dirs initialized but emptyPeter Kästle, Jan 14, 2020
  2. Fix status of initialized but not cloned submodulesPeter Kaestle, Jan 21, 2020
  3. Junio C HamanoJan 23, 2020
  4. 1/2 Testcase for submodule status on empty dirsPeter Kaestle, Jan 24, 2020
  5. 2/2 Fix status of initialized but not cloned submodulesPeter Kaestle, Jan 24, 2020
  6. Junio C HamanoJan 24, 2020
  7. 1/2 t7400: add a testcase for submodule status on empty dirsPeter Kaestle, Jan 27, 2020
  8. 2/2 Fix status of initialized but not cloned submodulesPeter Kaestle, Jan 27, 2020
  9. Junio C HamanoJan 27, 2020
  10. Peter KästleJan 28, 2020
  11. t7400: testcase for submodule status on unregistered inner git reposPeter Kaestle, Feb 2, 2020
  12. Peter KästleJan 24, 2020
  13. Junio C HamanoJan 24, 2020
  14. Peter KästleJan 27, 2020
  15. Junio C HamanoJan 27, 2020
  16. Peter KästleFeb 2, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.