Re: [PATCH v3 22/23] worktree: add: auto-vivify new branch when <branch> is omitted

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eric Sunshine <sunshine@xxxxxxxxxxxxxx> 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 <new-branch>] <path> <branch>
> +'git worktree add' [-f] [--detach] [-b <new-branch>] <path> [<branch>]

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 <branch> omitted' '
>  	test_cmp_rev HEAD burble
>  '
>  
> +test_expect_success '"add" with <branch> omitted' '
> +	git worktree add wiffle/bat &&
> +	test_cmp_rev HEAD bat
> +'
> +
>  test_done
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]