Skip to content

Commit 46e87b5

Browse files
avarttaylorr
authored andcommitted
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 <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent d50d848 commit 46e87b5

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

submodule.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,6 +2310,23 @@ static void relocate_single_git_dir_into_superproject(const char *path)
23102310
strbuf_release(&new_gitdir);
23112311
}
23122312

2313+
static void absorb_git_dir_into_superproject_recurse(const char *path)
2314+
{
2315+
2316+
struct child_process cp = CHILD_PROCESS_INIT;
2317+
2318+
cp.dir = path;
2319+
cp.git_cmd = 1;
2320+
cp.no_stdin = 1;
2321+
strvec_pushf(&cp.args, "--super-prefix=%s%s/",
2322+
get_super_prefix_or_empty(), path);
2323+
strvec_pushl(&cp.args, "submodule--helper",
2324+
"absorbgitdirs", NULL);
2325+
prepare_submodule_repo_env(&cp.env);
2326+
if (run_command(&cp))
2327+
die(_("could not recurse into submodule '%s'"), path);
2328+
}
2329+
23132330
/*
23142331
* Migrate the git directory of the submodule given by path from
23152332
* 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,
23662383
strbuf_release(&gitdir);
23672384

23682385
if (flags & ABSORB_GITDIR_RECURSE_SUBMODULES) {
2369-
struct child_process cp = CHILD_PROCESS_INIT;
2370-
23712386
if (flags & ~ABSORB_GITDIR_RECURSE_SUBMODULES)
23722387
BUG("we don't know how to pass the flags down?");
23732388

2374-
cp.dir = path;
2375-
cp.git_cmd = 1;
2376-
cp.no_stdin = 1;
2377-
strvec_pushf(&cp.args, "--super-prefix=%s%s/",
2378-
get_super_prefix_or_empty(), path);
2379-
strvec_pushl(&cp.args, "submodule--helper",
2380-
"absorbgitdirs", NULL);
2381-
prepare_submodule_repo_env(&cp.env);
2382-
if (run_command(&cp))
2383-
die(_("could not recurse into submodule '%s'"), path);
2389+
absorb_git_dir_into_superproject_recurse(path);
23842390
}
23852391
}
23862392

0 commit comments

Comments
 (0)