From: Alex Riesen Date: Fri, 18 May 2007 22:48:07 GMT Subject: [PATCH] Use run_command_v_opt_cd when checking out a submodule Message-ID: <20070518224807.GH10475@steel.home> In-Reply-To: <20070518222015.GE10475@steel.home> Signed-off-by: Alex Riesen --- entry.c | 12 +----------- 1 files changed, 1 insertions(+), 11 deletions(-) diff --git a/entry.c b/entry.c index 96a4a60..0316c74 100644 --- a/entry.c +++ b/entry.c @@ -166,7 +166,6 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout 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; @@ -175,12 +174,6 @@ static int checkout_submodule(const char *path, struct cache_entry *ce, const st 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) @@ -190,12 +183,9 @@ static int checkout_submodule(const char *path, struct cache_entry *ce, const st gitdirenv = getenv(GIT_DIR_ENVIRONMENT); unsetenv(GIT_DIR_ENVIRONMENT); - err = run_command_v_opt(args, RUN_GIT_CMD); + err = run_command_v_opt_cd(args, RUN_GIT_CMD, path); 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); -- 1.5.2.rc3.83.gbbb0