git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: bmwill@google.com
Cc: git@vger.kernel.org, jrnieder@gmail.com, gitster@pobox.com,
	jonathantanmy@google.com, philipoakley@iee.org,
	Stefan Beller <sbeller@google.com>
Subject: [PATCHv2 2/4] submodule.c: uninitialized submodules are ignored in recursive commands
Date: Tue, 18 Apr 2017 14:37:23 -0700	[thread overview]
Message-ID: <20170418213725.7901-3-sbeller@google.com> (raw)
In-Reply-To: <20170418213725.7901-1-sbeller@google.com>

This was an oversight when working on the working tree modifying commands
recursing into submodules.

To test for uninitialized submodules, introduce another submodule
"uninitialized_sub". Adding it via `submodule add` will activate the
submodule in the preparation area (in create_lib_submodule_repo we
setup all the things in submodule_update_repo), but the later tests
will use a new testing repo that clones the preparation repo
in which the new submodule is not initialized.

By adding it to the branch "add_sub1", which is the starting point of
all other branches, we have wide coverage.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 submodule.c               | 3 +++
 t/lib-submodule-update.sh | 1 +
 2 files changed, 4 insertions(+)

diff --git a/submodule.c b/submodule.c
index 7c3c4b17fb..ccf8932731 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1333,6 +1333,9 @@ int submodule_move_head(const char *path,
 	struct child_process cp = CHILD_PROCESS_INIT;
 	const struct submodule *sub;
 
+	if (!is_submodule_initialized(path))
+		return 0;
+
 	sub = submodule_from_path(null_sha1, path);
 
 	if (!sub)
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index fb4f7b014e..22dd9e060c 100755
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -73,6 +73,7 @@ create_lib_submodule_repo () {
 
 		git checkout -b "add_sub1" &&
 		git submodule add ../submodule_update_sub1 sub1 &&
+		git submodule add ../submodule_update_sub1 uninitialized_sub &&
 		git config -f .gitmodules submodule.sub1.ignore all &&
 		git config submodule.sub1.ignore all &&
 		git add .gitmodules &&
-- 
2.12.2.642.g1b8cc69eee.dirty


  parent reply	other threads:[~2017-04-18 21:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-18 21:37 [PATCHv2 0/4] recursive submodules: git-reset! Stefan Beller
2017-04-18 21:37 ` [PATCHv2 1/4] entry.c: submodule recursing: respect force flag correctly Stefan Beller
2017-04-18 21:37 ` Stefan Beller [this message]
2017-04-18 21:37 ` [PATCHv2 3/4] submodule.c: submodule_move_head works with broken submodules Stefan Beller
2017-04-18 21:37 ` [PATCHv2 4/4] builtin/reset: add --recurse-submodules switch Stefan Beller
2017-04-19  4:18   ` Junio C Hamano
2017-04-19 19:08     ` Stefan Beller
2017-04-21 17:39       ` [PATCHv3 " Stefan Beller
2017-04-20 19:41 ` [PATCHv2 0/4] recursive submodules: git-reset! Brandon Williams
2017-04-20 20:00   ` Stefan Beller

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

  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=20170418213725.7901-3-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jonathantanmy@google.com \
    --cc=jrnieder@gmail.com \
    --cc=philipoakley@iee.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).