From: Ian Wienand <iwienand@redhat.com>
To: git@vger.kernel.org
Cc: Peter Kaestle <peter.kaestle@nokia.com>,
Philippe Blain <levraiphilippeblain@gmail.com>,
Ian Wienand <iwienand@redhat.com>
Subject: [PATCH] submodule: separate out not-found and not-empty errors
Date: Wed, 17 Nov 2021 10:06:14 +1100 [thread overview]
Message-ID: <YZQ5Zk0ItWvfr8sF@fedora19.localdomain> (raw)
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 reply other threads:[~2021-11-16 23:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-16 23:06 Ian Wienand [this message]
2021-11-17 9:39 ` [PATCH] submodule: separate out not-found and not-empty errors Junio C Hamano
2021-11-18 4:06 ` Ian Wienand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YZQ5Zk0ItWvfr8sF@fedora19.localdomain \
--to=iwienand@redhat.com \
--cc=git@vger.kernel.org \
--cc=levraiphilippeblain@gmail.com \
--cc=peter.kaestle@nokia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox