From: Junio C Hamano Date: Mon, 06 Jul 2015 19:19:14 GMT Subject: Re: [PATCH v3 22/23] worktree: add: auto-vivify new branch when is omitted Message-ID: In-Reply-To: <1436203860-846-23-git-send-email-sunshine@sunshineco.com> Eric Sunshine writes: > diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt > index 377ae0f..da71f50 100644 > --- a/Documentation/git-worktree.txt > +++ b/Documentation/git-worktree.txt > @@ -9,7 +9,7 @@ git-worktree - Manage multiple worktrees > SYNOPSIS > -------- > [verse] > -'git worktree add' [-f] [--detach] [-b ] > +'git worktree add' [-f] [--detach] [-b ] [] Ahh, OK, this answers my previous question. > + if (ac < 2 && !new_branch && !new_branch_force) { > + int n; > + const char *s = worktree_basename(path, &n); > + new_branch = xstrndup(s, n); > + } > + and because this is new_branch, not new_branch_force, we will not accidentally clobber an existing branch. The "hotfix" time is when the end-user tends to be less careful, and it is a good thing to make sure "git worktree add ../hotfix" will not clobber an unrelated "hotfix" branch. Good. Which may be something we would want to have a test for, though. > diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh > index 8964dec..8fe242f 100755 > --- a/t/t2025-worktree-add.sh > +++ b/t/t2025-worktree-add.sh > @@ -145,4 +145,9 @@ test_expect_success '"add -b" with omitted' ' > test_cmp_rev HEAD burble > ' > > +test_expect_success '"add" with omitted' ' > + git worktree add wiffle/bat && > + test_cmp_rev HEAD bat > +' > + > test_done