summaryrefslogtreecommitdiff
path: root/builtin/worktree.c
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2015-07-17 23:00:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-07-20 18:29:51 (GMT)
commit5c942570fe2a48d8fde348e89392c2e9e23aa483 (patch)
tree1be8561173a8f4d7f33066ee3158f1549b8b968e /builtin/worktree.c
parentab0b2c53ed853e34def18e7b84acd7da7e2ddd49 (diff)
downloadgit-5c942570fe2a48d8fde348e89392c2e9e23aa483.zip
git-5c942570fe2a48d8fde348e89392c2e9e23aa483.tar.gz
git-5c942570fe2a48d8fde348e89392c2e9e23aa483.tar.bz2
worktree: add: suppress auto-vivication with --detach and no <branch>
Fix oversight where branch auto-vivication incorrectly kicks in when --detach is specified and <branch> omitted. Instead, treat: git worktree add --detach <path> as shorthand for: git worktree add --detach <path> HEAD Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/worktree.c')
-rw-r--r--builtin/worktree.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 813e016..83484ad 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -308,7 +308,7 @@ static int add(int ac, const char **av, const char *prefix)
if (opts.force_new_branch)
opts.new_branch = new_branch_force;
- if (ac < 2 && !opts.new_branch) {
+ if (ac < 2 && !opts.new_branch && !opts.detach) {
int n;
const char *s = worktree_basename(path, &n);
opts.new_branch = xstrndup(s, n);