[PATCH 20/22] checkout_submodule: checkout submodule on forced checkout of submodule dir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Sven Verdoolaege <skimo@xxxxxxxxxx>

Signed-off-by: Sven Verdoolaege <skimo@xxxxxxxxxx>
---
 entry.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/entry.c b/entry.c
index f3e0c59..9c093ac 100644
--- a/entry.c
+++ b/entry.c
@@ -82,10 +82,20 @@ static int checkout_submodule(struct cache_entry *ce, const char *path, const st
 	const char *args[10];
 	int argc;
 	int err;
+	struct stat st;
+	char *gitdir;
 
-	if (!state->submodules && !is_checkedout_submodule(ce->name))
+	if (!state->force && !is_checkedout_submodule(ce->name))
 		return 0;
 
+	gitdir = mkpath("%s/.git", ce->name);
+	if (lstat(gitdir, &st)) {
+		if (clone_submodule(ce->name))
+			return -1;
+		if (attach_submodule(ce->name))
+			return -1;
+	}
+
 	argc = 0;
 	args[argc++] = "checkout";
 	if (state->force)
@@ -220,6 +230,13 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *t
 
 	if (!lstat(path, &st)) {
 		unsigned changed = ce_match_stat(ce, &st, 1);
+		/*
+		 *  If submodule has not been checked out, then force
+		 *  forces a check-out.
+		 */
+		if (state->force && S_ISGITLINK(ntohl(ce->ce_mode)) &&
+		    !is_checkedout_submodule(ce->name))
+			changed = 1;
 		if (!changed)
 			return 0;
 		if (!state->force) {
-- 
1.5.2.784.g5532e

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux