aboutsummaryrefslogtreecommitdiff
path: root/builtin/worktree.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-02-15 20:35:32 +0700
committerJunio C Hamano <gitster@pobox.com>2016-02-15 15:49:33 -0800
commit0ebf4a2af3b72847327e977c5710fd123926570e (patch)
tree91fe7ca79b551c22bb5e87bee1898b6db0f59e81 /builtin/worktree.c
parent494398473714dcbedb38b1ac79b531c7384b3bc4 (diff)
downloadgit-0ebf4a2af3b72847327e977c5710fd123926570e.tar.gz
git-0ebf4a2af3b72847327e977c5710fd123926570e.tar.xz
worktree: fix "add -B"
Current code does not update "symref" when -B is used. This string contains the new HEAD. Because it's empty "git worktree add -B" fails at symbolic-ref step. Because branch creation is already done before calling add_worktree(), -B is equivalent to -b from add_worktree() point of view. We do not need the special case for -B. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/worktree.c')
-rw-r--r--builtin/worktree.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 475b9581a..6b9c94669 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -201,9 +201,7 @@ static int add_worktree(const char *path, const char *refname,
die(_("'%s' already exists"), path);
/* is 'refname' a branch or commit? */
- if (opts->force_new_branch) /* definitely a branch */
- ;
- else if (!opts->detach && !strbuf_check_branch_ref(&symref, refname) &&
+ if (!opts->detach && !strbuf_check_branch_ref(&symref, refname) &&
ref_exists(symref.buf)) { /* it's a branch */
if (!opts->force)
die_if_checked_out(symref.buf);