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 <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Sunshine committed Jul 6, 2015 at 13:30 UTC bdf0f375b9cf1c272233583a03eddef1772da99e
1 file changed +5 -4
builtin/checkout.c
+5 -4
@@ -854,11 +854,11 @@ static void remove_junk_on_signal(int signo)
854 raise(signo);
855 }
856
857 -static int prepare_linked_checkout(const struct checkout_opts *opts)
857 +static int prepare_linked_checkout(const char *path, const char **child_argv)
858 {
859 struct strbuf sb_git = STRBUF_INIT, sb_repo = STRBUF_INIT;
860 struct strbuf sb = STRBUF_INIT;
861 - const char *path = opts->new_worktree, *name;
861 + const char *name;
862 struct stat st;
863 struct child_process cp;
864 int counter = 0, len, ret;
@@ -943,7 +943,7 @@ static int prepare_linked_checkout(const struct checkout_opts *opts)
943 setenv(GIT_WORK_TREE_ENVIRONMENT, path, 1);
944 memset(&cp, 0, sizeof(cp));
945 cp.git_cmd = 1;
946 - cp.argv = opts->saved_argv;
946 + cp.argv = child_argv;
947 ret = run_command(&cp);
948 if (!ret) {
949 is_junk = 0;
@@ -1302,7 +1302,8 @@ static int checkout_branch(struct checkout_opts *opts,
1302 if (opts->new_worktree) {
1303 if (!new->commit)
1304 die(_("no branch specified"));
1305 - return prepare_linked_checkout(opts);
1305 + return prepare_linked_checkout(opts->new_worktree,
1306 + opts->saved_argv);
1307 }
1308
1309 if (!new->commit && opts->new_branch) {