Skip to content

Commit cdc3db3

Browse files
rscharfegitster
authored andcommitted
submodule: use strvec_pushf() for --super-prefix
absorb_git_dir_into_superproject() uses a strbuf and strvec_pushl() to build and add the --super-prefix option and its argument. Use a single strvec_pushf() call to add the stuck form instead, which reduces the code size and avoids a strbuf allocation and release. The same is already done in submodule_reset_index() and submodule_move_head(). Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d5b4139 commit cdc3db3

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

submodule.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,26 +2361,20 @@ void absorb_git_dir_into_superproject(const char *path,
23612361

23622362
if (flags & ABSORB_GITDIR_RECURSE_SUBMODULES) {
23632363
struct child_process cp = CHILD_PROCESS_INIT;
2364-
struct strbuf sb = STRBUF_INIT;
23652364

23662365
if (flags & ~ABSORB_GITDIR_RECURSE_SUBMODULES)
23672366
BUG("we don't know how to pass the flags down?");
23682367

2369-
strbuf_addstr(&sb, get_super_prefix_or_empty());
2370-
strbuf_addstr(&sb, path);
2371-
strbuf_addch(&sb, '/');
2372-
23732368
cp.dir = path;
23742369
cp.git_cmd = 1;
23752370
cp.no_stdin = 1;
2376-
strvec_pushl(&cp.args, "--super-prefix", sb.buf,
2377-
"submodule--helper",
2371+
strvec_pushf(&cp.args, "--super-prefix=%s%s/",
2372+
get_super_prefix_or_empty(), path);
2373+
strvec_pushl(&cp.args, "submodule--helper",
23782374
"absorbgitdirs", NULL);
23792375
prepare_submodule_repo_env(&cp.env);
23802376
if (run_command(&cp))
23812377
die(_("could not recurse into submodule '%s'"), path);
2382-
2383-
strbuf_release(&sb);
23842378
}
23852379
}
23862380

0 commit comments

Comments
 (0)