Re: [PATCH v2 3/8] refs: new ref types to make per-worktree refs visible to all worktrees
On Sat, Sep 29, 2018 at 3:10 PM Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> The main worktree has to be treated specially because well.. it's
Show 11 quoted lines
> special from the beginning. So HEAD from the main worktree is
> acccessible via the name "main-worktree/HEAD" instead of
> "worktrees/main/HEAD" because "main" could be just another secondary
> worktree.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
> @@ -216,6 +217,18 @@ directly under GIT_DIR instead of inside GIT_DIR/refs. There are one
> +Refs that are per working tree can still be accessed from another
> +working tree via two special paths main-worktree and worktrees. The
> +former gives access to per-worktree refs of the main working tree,
> +while the former to all linked working trees.
Show 6 quoted lines
> diff --git a/t/t1415-worktree-refs.sh b/t/t1415-worktree-refs.sh
> @@ -30,4 +30,50 @@ test_expect_success 'refs/worktree are per-worktree' '
> +test_expect_success 'ambiguous main-worktree/HEAD' '
> + mkdir -p .git/refs/heads/main-worktree &&
> + test_when_finished rm .git/refs/heads/main-worktree/HEAD &&
> + cp .git/HEAD .git/refs/heads/main-worktree/HEAD &&
Better to use "rm -f" for cleanup in case this 'cp' fails for some reason.
> + git rev-parse main-worktree/HEAD 2>warn >/dev/null &&
You could probably omit the /dev/null redirect.
Show 6 quoted lines
> + grep "main-worktree/HEAD.*ambiguous" warn
> +'
> +
> +test_expect_success 'ambiguous worktrees/xx/HEAD' '
> + mkdir -p .git/refs/heads/worktrees/wt1 &&
> + test_when_finished rm .git/refs/heads/worktrees/wt1/HEAD &&
> + cp .git/HEAD .git/refs/heads/worktrees/wt1/HEAD &&
> + git rev-parse worktrees/wt1/HEAD 2>warn >/dev/null &&
> + grep "worktrees/wt1/HEAD.*ambiguous" warn
> +'