diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2015-07-06 20:30:46 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-07-06 21:07:44 +0300 |
commit | 9559ce8368b533862584b2717532e3c25232f1c9 (patch) | |
tree | 2b3536bb3b757ed39bca08040e53f0b6bd381ebb /builtin/checkout.c | |
parent | c990a4c11dd7bb671da1b30e14568ad986621488 (diff) |
checkout: relocate --to's "no branch specified" check
The plan is to relocate "git checkout --to" functionality to "git
worktree add", however, this check expects a 'struct branch_info' which
git-worktree won't have at hand. It will, however, have access to its
own command-line from which it can pick up the branch name. Therefore,
as a preparatory step, rather than having prepare_linked_checkout()
perform this check, make it the caller's responsibility.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r-- | builtin/checkout.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index 5ada22a390..162c822263 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -865,8 +865,6 @@ static int prepare_linked_checkout(const struct checkout_opts *opts, int counter = 0, len, ret; unsigned char rev[20]; - if (!new->commit) - die(_("no branch specified")); if (file_exists(path) && !is_empty_dir(path)) die(_("'%s' already exists"), path); @@ -1303,8 +1301,11 @@ static int checkout_branch(struct checkout_opts *opts, free(head_ref); } - if (opts->new_worktree) + if (opts->new_worktree) { + if (!new->commit) + die(_("no branch specified")); return prepare_linked_checkout(opts, new); + } if (!new->commit && opts->new_branch) { unsigned char rev[20]; |