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>
This commit is contained in:

committed by
Junio C Hamano

parent
ab0b2c53ed
commit
5c942570fe
@ -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);
|
||||
|
Reference in New Issue
Block a user