Thread (3 messages) flat view 3 messages, 2 authors, 2021-11-18
STALE1736d

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

From: Ian Wienand <hidden>
Date: 2021-11-16 23:06:28
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help