From 5c942570fe2a48d8fde348e89392c2e9e23aa483 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Fri, 17 Jul 2015 19:00:09 -0400 Subject: worktree: add: suppress auto-vivication with --detach and no Fix oversight where branch auto-vivication incorrectly kicks in when --detach is specified and omitted. Instead, treat: git worktree add --detach as shorthand for: git worktree add --detach HEAD Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- builtin/worktree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/worktree.c') diff --git a/builtin/worktree.c b/builtin/worktree.c index 813e016130..83484ad502 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); -- cgit v1.2.1