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

[PATCH] submodule: separate out not-found and not-empty errors

From
Ian Wienand <iwienand@redhat.com>
Date
Nov 16, 2021, 23:06 UTC
Message-ID
<YZQ5Zk0ItWvfr8sF@fedora19.localdomain>

After upgrading past 505a2765963 a long-working script to cache git repos started failing with

 Could not access submodule '...'
for every updated submodule on each fetch [1].

Ultimately this turned out to be using "--git-dir=" from outside the repo; i.e. we really wanted "-C" in this script (the man page does warn about this -- but it was working for a long time).

Although obvious in hindsight, this was very difficult to diagnose from the error message. It required me adding debugging to these functions to determine why it was falling into this path when everything looked right on disk.

This proposes separate messages for the directory missing v. being present but having unexpected contents. Both messages are modified to give the path that is being examined.

[1] https://review.opendev.org/c/openstack/diskimage-builder/+/818053
Signed-off-by: Ian Wienand <iwienand@redhat.com>
---
 submodule.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/submodule.c b/submodule.c
index c689070524..910ee6ba7d 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1521,9 +1521,16 @@ static int get_next_submodule(struct child_process *cp,
 			if (S_ISGITLINK(ce->ce_mode) &&
 			    !is_empty_dir(empty_submodule_path.buf)) {
 				spf->result = 1;
-				strbuf_addf(err,
-					    _("Could not access submodule '%s'\n"),
-					    ce->name);
+				/* is_empty_dir also catches missing dirtectories, but report separately */
+				if (!is_directory(empty_submodule_path.buf)) {
+				  strbuf_addf(err,
+					      _("Submodule directory '%s' not found (incorrect --git-dir?)\n"),
+					      empty_submodule_path.buf);
+				} else {
+				  strbuf_addf(err,
+					      _("Submodule directory '%s' is not empty\n"),
+					      empty_submodule_path.buf);
+				}
 			}
 			strbuf_release(&empty_submodule_path);
 		}
-- 
2.33.1
Next: Junio C Hamano
Message 1 of 3 in “submodule: separate out not-found and not-empty errors”
  1. submodule: separate out not-found and not-empty errorsIan Wienand, Nov 16, 2021
  2. Junio C HamanoNov 17, 2021
  3. Ian WienandNov 18, 2021

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.