git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
From: Stefan Beller <sbeller@google.com>
To: git@vger.kernel.org
Cc: Stefan Beller <sbeller@google.com>
Subject: [PATCH 2/2] submodule.c: warn about missing submodule commit in recursive actions
Date: Wed,  5 Sep 2018 16:19:52 -0700
Message-ID: <20180905231952.28145-2-sbeller@google.com> (raw)
In-Reply-To: <20180905231952.28145-1-sbeller@google.com>

By checking if a submodule commit exists before attempting the update
we can improve the error message from the
    error(_("Submodule '%s' could not be updated."), path);
to the new and more specific
    error(_("Submodule '%s' doesn't have commit '%s'"),
          path, oid_to_hex(new_oid));

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 submodule.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/submodule.c b/submodule.c
index da2ed8696f5..56104af1c7c 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1605,6 +1605,7 @@ int submodule_move_head(const char *path,
 	struct child_process cp = CHILD_PROCESS_INIT;
 	const struct submodule *sub;
 	int *error_code_ptr, error_code;
+	struct repository subrepo;
 
 	if (!is_submodule_active(the_repository, path))
 		return 0;
@@ -1627,6 +1628,13 @@ int submodule_move_head(const char *path,
 	if (!sub)
 		BUG("could not get submodule information for '%s'", path);
 
+	if (repo_submodule_init(&subrepo, the_repository, path) < 0)
+		warning(_("Could not get submodule repository for submodule 's'"), path);
+	else if (new_oid && !lookup_commit(subrepo, new_oid)) {
+		return error(_("Submodule '%s' doesn't have commit '%s'"),
+			     path, oid_to_hex(new_oid));
+	}
+
 	if (old_head && !(flags & SUBMODULE_MOVE_HEAD_FORCE)) {
 		/* Check if the submodule has a dirty index. */
 		if (submodule_has_dirty_index(sub))
-- 
2.19.0.rc2.392.g5ba43deb5a-goog


  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05 23:19 [PATCH 1/2] submodule.c: convert submodule_move_head new argument to object id Stefan Beller
2018-09-05 23:19 ` Stefan Beller [this message]
2018-09-05 23:32   ` [PATCH 2/2] submodule.c: warn about missing submodule commit in recursive actions Jonathan Nieder
2018-09-06  6:22   ` Martin Ågren
2018-09-05 23:40 ` [PATCH 1/2] submodule.c: convert submodule_move_head new argument to object id Jonathan Nieder
2018-09-06 21:18 ` Junio C Hamano

Reply instructions:

You may reply publically 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180905231952.28145-2-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=git@vger.kernel.org \
    /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

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox