worktree: add_worktree: construct worktree-population command locally
commit80a0548f6c12f43e9bd62e13eacb033f05e2b001
authorEric Sunshine <sunshine@sunshineco.com>
Fri, 17 Jul 2015 23:00:12 +0000 (17 19:00 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Jul 2015 18:29:52 +0000 (20 11:29 -0700)
tree05cf608fee704b88993928bcc684fab7d27fd960
parentae2a38271f778522ceb9182b94e0024a816e3338
worktree: add_worktree: construct worktree-population command locally

The caller of add_worktree() provides it with a command to invoke to
populate the new worktree. This was a useful abstraction during the
conversion of "git checkout --to" functionality to "git worktree add"
since git-checkout and git-worktree constructed the population command
differently. However, now that "git checkout --to" has been retired, and
add_worktree() has access to the options given to "worktree add", this
extra indirection is no longer useful and makes the code a bit
convoluted.

Moreover, the eventual goal is for git-worktree to make setting of HEAD
and worktree population distinct operations, whereas they are currently
conflated into a single git-checkout invocation. As such, add_worktree()
will eventually invoke other commands in addition to the worktree
population command, so it will be doing command construction itself
anyhow.

Therefore, relocate construction of the worktree population command from
add() to add_worktree().

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/worktree.c