submodule.c: refactor recursive block out of absorb function
A move and indentation-only change to move the ABSORB_GITDIR_RECURSE_SUBMODULES case into its own function, which as we'll see makes the subsequent commit changing this code much smaller. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Taylor Blau <me@ttaylorr.com>
This commit is contained in:
parent
d50d8485ef
commit
46e87b5482
30
submodule.c
30
submodule.c
@ -2310,6 +2310,23 @@ static void relocate_single_git_dir_into_superproject(const char *path)
|
|||||||
strbuf_release(&new_gitdir);
|
strbuf_release(&new_gitdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void absorb_git_dir_into_superproject_recurse(const char *path)
|
||||||
|
{
|
||||||
|
|
||||||
|
struct child_process cp = CHILD_PROCESS_INIT;
|
||||||
|
|
||||||
|
cp.dir = path;
|
||||||
|
cp.git_cmd = 1;
|
||||||
|
cp.no_stdin = 1;
|
||||||
|
strvec_pushf(&cp.args, "--super-prefix=%s%s/",
|
||||||
|
get_super_prefix_or_empty(), path);
|
||||||
|
strvec_pushl(&cp.args, "submodule--helper",
|
||||||
|
"absorbgitdirs", NULL);
|
||||||
|
prepare_submodule_repo_env(&cp.env);
|
||||||
|
if (run_command(&cp))
|
||||||
|
die(_("could not recurse into submodule '%s'"), path);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Migrate the git directory of the submodule given by path from
|
* Migrate the git directory of the submodule given by path from
|
||||||
* having its git directory within the working tree to the git dir nested
|
* having its git directory within the working tree to the git dir nested
|
||||||
@ -2366,21 +2383,10 @@ void absorb_git_dir_into_superproject(const char *path,
|
|||||||
strbuf_release(&gitdir);
|
strbuf_release(&gitdir);
|
||||||
|
|
||||||
if (flags & ABSORB_GITDIR_RECURSE_SUBMODULES) {
|
if (flags & ABSORB_GITDIR_RECURSE_SUBMODULES) {
|
||||||
struct child_process cp = CHILD_PROCESS_INIT;
|
|
||||||
|
|
||||||
if (flags & ~ABSORB_GITDIR_RECURSE_SUBMODULES)
|
if (flags & ~ABSORB_GITDIR_RECURSE_SUBMODULES)
|
||||||
BUG("we don't know how to pass the flags down?");
|
BUG("we don't know how to pass the flags down?");
|
||||||
|
|
||||||
cp.dir = path;
|
absorb_git_dir_into_superproject_recurse(path);
|
||||||
cp.git_cmd = 1;
|
|
||||||
cp.no_stdin = 1;
|
|
||||||
strvec_pushf(&cp.args, "--super-prefix=%s%s/",
|
|
||||||
get_super_prefix_or_empty(), path);
|
|
||||||
strvec_pushl(&cp.args, "submodule--helper",
|
|
||||||
"absorbgitdirs", NULL);
|
|
||||||
prepare_submodule_repo_env(&cp.env);
|
|
||||||
if (run_command(&cp))
|
|
||||||
die(_("could not recurse into submodule '%s'"), path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user