Skip to content

Commit bdf0f37

Browse files
sunshinecogitster
authored andcommitted
checkout: drop 'checkout_opts' dependency from prepare_linked_checkout
The plan is to relocate "git checkout --to" functionality to "git worktree add", however, worktree.c won't have access to the 'struct checkout_opts' passed to prepare_linked_worktree(), which it consults for the pathname of the new worktree and the argv[] of the command it should run to populate the new worktree. Facilitate relocation of prepare_linked_worktree() by instead having it accept the pathname and argv[] directly, thus eliminating the final references to 'struct checkout_opts'. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 338dfd0 commit bdf0f37

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

builtin/checkout.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,11 +854,11 @@ static void remove_junk_on_signal(int signo)
854854
raise(signo);
855855
}
856856

857-
static int prepare_linked_checkout(const struct checkout_opts *opts)
857+
static int prepare_linked_checkout(const char *path, const char **child_argv)
858858
{
859859
struct strbuf sb_git = STRBUF_INIT, sb_repo = STRBUF_INIT;
860860
struct strbuf sb = STRBUF_INIT;
861-
const char *path = opts->new_worktree, *name;
861+
const char *name;
862862
struct stat st;
863863
struct child_process cp;
864864
int counter = 0, len, ret;
@@ -943,7 +943,7 @@ static int prepare_linked_checkout(const struct checkout_opts *opts)
943943
setenv(GIT_WORK_TREE_ENVIRONMENT, path, 1);
944944
memset(&cp, 0, sizeof(cp));
945945
cp.git_cmd = 1;
946-
cp.argv = opts->saved_argv;
946+
cp.argv = child_argv;
947947
ret = run_command(&cp);
948948
if (!ret) {
949949
is_junk = 0;
@@ -1302,7 +1302,8 @@ static int checkout_branch(struct checkout_opts *opts,
13021302
if (opts->new_worktree) {
13031303
if (!new->commit)
13041304
die(_("no branch specified"));
1305-
return prepare_linked_checkout(opts);
1305+
return prepare_linked_checkout(opts->new_worktree,
1306+
opts->saved_argv);
13061307
}
13071308

13081309
if (!new->commit && opts->new_branch) {

0 commit comments

Comments
 (0)