From: Sven Verdoolaege <skimo@kotnet.org>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
---
entry.c | 42 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/entry.c b/entry.c
index 82bf725..96a4a60 100644
--- a/entry.c
+++ b/entry.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "blob.h"
+#include "run-command.h"
static void create_directories(const char *path, const struct checkout *state)
{
@@ -163,6 +164,44 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
return 0;
}
+static int checkout_submodule(const char *path, struct cache_entry *ce, const struct checkout *state)
+{
+ static char cwd[PATH_MAX];
+ const char *gitdirenv;
+ const char *args[10];
+ int argc;
+ int err;
+
+ if (!state->submodules)
+ return 0;
+
+ if (!getcwd(cwd, sizeof(cwd)) || cwd[0] != '/')
+ die("Unable to read current working directory");
+
+ if (chdir(path))
+ die("Cannot move to '%s'", path);
+
+ argc = 0;
+ args[argc++] = "checkout";
+ if (state->force)
+ args[argc++] = "-f";
+ args[argc++] = sha1_to_hex(ce->sha1);
+ args[argc] = NULL;
+
+ gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
+ unsetenv(GIT_DIR_ENVIRONMENT);
+ err = run_command_v_opt(args, RUN_GIT_CMD);
+ setenv(GIT_DIR_ENVIRONMENT, gitdirenv, 1);
+
+ if (chdir(cwd))
+ die("Cannot come back to cwd");
+
+ if (err)
+ return error("failed to run git-checkout in submodule '%s'", path);
+
+ return 0;
+}
+
int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath)
{
static char path[PATH_MAX + 1];
@@ -193,9 +232,8 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *t
*/
unlink(path);
if (S_ISDIR(st.st_mode)) {
- /* If it is a gitlink, leave it alone! */
if (S_ISDIRLNK(ntohl(ce->ce_mode)))
- return 0;
+ return checkout_submodule(path, ce, state);
if (!state->force)
return error("%s is a directory", path);
remove_subtree(path);
--
1.5.2.rc3.783.gc7476-dirty
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
| Con Kolivas | Re: [ANNOUNCE] RSDL completely fair starvation free interactive cpu scheduler |
| David Miller | [GIT]: Networking |
| Alan Stern | Re: [linux-pm] Re: Hibernation considerations |
git: | |
| Junio C Hamano | Re: git-diff on touched files: bug or feature? |
| Johannes Schindelin | Re: MinGW port - initial work uploaded |
| Kay Sievers | Re: Rss produced by git is not valid xml? |
| Marek Zawirski | [EGIT PATCH 00/31] Push GUI, GUI improvements, various jgit stuff |
| frantisek holop | nptd regression in 4.2 |
| Thilo Pfennig | OpenBSD project goals |
| Luca Dell'Oca | Authenticate squid in Active Directory |
| Richard Stallman | Real men don't attack straw men |
| Julius Volz | [PATCHv3 00/24] Add first IPv6 support to IPVS |
| Paul Moore | [RFC PATCH v4 01/14] netlabel: Remove unneeded in-kernel API functions |
| David Miller | Re: [PATCH net-2.6.25 1/10][NETNS][FRAGS]: Move ctl tables around. |
| Wenji Wu | Re: RE: A Linux TCP SACK Question |
