Update to the "linked checkout" in 2.5.0-rc1.
Instead of "checkout --to" that does not do what "checkout"
normally does, move the functionality to "git worktree add".
* es/worktree-add: (24 commits)
Revert "checkout: retire --ignore-other-worktrees in favor of --force"
checkout: retire --ignore-other-worktrees in favor of --force
worktree: add: auto-vivify new branch when <branch> is omitted
worktree: add: make -b/-B default to HEAD when <branch> is omitted
worktree: extract basename computation to new function
checkout: require worktree unconditionally
checkout: retire --to option
tests: worktree: retrofit "checkout --to" tests for "worktree add"
worktree: add -b/-B options
worktree: add --detach option
worktree: add --force option
worktree: introduce "add" command
checkout: drop 'checkout_opts' dependency from prepare_linked_checkout
checkout: make --to unconditionally verbose
checkout: prepare_linked_checkout: drop now-unused 'new' argument
checkout: relocate --to's "no branch specified" check
checkout: fix bug with --to and relative HEAD
Documentation/git-worktree: add EXAMPLES section
Documentation/git-worktree: add high-level 'lock' overview
Documentation/git-worktree: split technical info from general description
...
@ -229,13 +229,6 @@ This means that you can use `git checkout -p` to selectively discard
@@ -229,13 +229,6 @@ This means that you can use `git checkout -p` to selectively discard
edits from your current working tree. See the ``Interactive Mode''
section of linkgit:git-add[1] to learn how to operate the `--patch` mode.
--to=<path>::
Check out a branch in a separate working directory at
`<path>`. A new working directory is linked to the current
repository, sharing everything except working directory
specific files such as HEAD, index... See "MULTIPLE WORKING
TREES" section for more information.
--ignore-other-worktrees::
`git checkout` refuses when the wanted ref is already checked
out by another worktree. This option makes it check the ref
@ -405,71 +398,6 @@ $ git reflog -2 HEAD # or
@@ -405,71 +398,6 @@ $ git reflog -2 HEAD # or
$ git log -g -2 HEAD
------------
MULTIPLE WORKING TREES
----------------------
A git repository can support multiple working trees, allowing you to check
out more than one branch at a time. With `git checkout --to` a new working
tree is associated with the repository. This new working tree is called a
"linked working tree" as opposed to the "main working tree" prepared by "git
init" or "git clone". A repository has one main working tree (if it's not a
bare repository) and zero or more linked working trees.
Each linked working tree has a private sub-directory in the repository's
$GIT_DIR/worktrees directory. The private sub-directory's name is usually
the base name of the linked working tree's path, possibly appended with a
number to make it unique. For example, when `$GIT_DIR=/path/main/.git` the
command `git checkout --to /path/other/test-next next` creates the linked
working tree in `/path/other/test-next` and also creates a
test_expect_success 'checkout --to an existing empty worktree' '
test_expect_success '"add" an existing empty worktree' '
mkdir existing_empty &&
git checkout --detach --to existing_empty master
git worktree add --detach existing_empty master
'
test_expect_success 'checkout --to refuses to checkout locked branch' '
test_must_fail git checkout --to zere master &&
test_expect_success '"add" refuses to checkout locked branch' '
test_must_fail git worktree add zere master &&
! test -d zere &&
! test -d .git/worktrees/zere
'
@ -36,9 +32,9 @@ test_expect_success 'checking out paths not complaining about linked checkouts'
@@ -36,9 +32,9 @@ test_expect_success 'checking out paths not complaining about linked checkouts'
)
'
test_expect_success 'checkout --to a new worktree' '
test_expect_success '"add" worktree' '
git rev-parse HEAD >expect &&
git checkout --detach --to here master &&
git worktree add --detach here master &&
(
cd here &&
test_cmp ../init.t init.t &&
@ -49,27 +45,27 @@ test_expect_success 'checkout --to a new worktree' '
@@ -49,27 +45,27 @@ test_expect_success 'checkout --to a new worktree' '
)
'
test_expect_success 'checkout --to a new worktree from a subdir' '
test_expect_success '"add" worktree from a subdir' '
(
mkdir sub &&
cd sub &&
git checkout --detach --to here master &&
git worktree add --detach here master &&
cd here &&
test_cmp ../../init.t init.t
)
'
test_expect_success 'checkout --to from a linked checkout' '
test_expect_success '"add" from a linked checkout' '
(
cd here &&
git checkout --detach --to nested-here master &&
git worktree add --detach nested-here master &&
cd nested-here &&
git fsck
)
'
test_expect_success 'checkout --to a new worktree creating new branch' '
git checkout --to there -b newmaster master &&
test_expect_success '"add" worktree creating new branch' '
git worktree add -b newmaster there master &&
(
cd there &&
test_cmp ../init.t init.t &&
@ -90,7 +86,7 @@ test_expect_success 'die the same branch is already checked out' '
@@ -90,7 +86,7 @@ test_expect_success 'die the same branch is already checked out' '
test_expect_success 'not die the same branch is already checked out' '
@ -101,15 +97,15 @@ test_expect_success 'not die on re-checking out current branch' '
@@ -101,15 +97,15 @@ test_expect_success 'not die on re-checking out current branch' '
)
'
test_expect_success 'checkout --to from a bare repo' '
test_expect_success '"add" from a bare repo' '
(
git clone --bare . bare &&
cd bare &&
git checkout --to ../there2 -b bare-master master
git worktree add -b bare-master ../there2 master
)
'
test_expect_success 'checkout from a bare repo without --to' '
test_expect_success 'checkout from a bare repo without "add"' '
(
cd bare &&
test_must_fail git checkout master
@ -129,9 +125,38 @@ test_expect_success 'checkout with grafts' '
@@ -129,9 +125,38 @@ test_expect_success 'checkout with grafts' '
@ -41,7 +41,7 @@ test_expect_failure 'can see submodule diffs just after checkout' \
@@ -41,7 +41,7 @@ test_expect_failure 'can see submodule diffs just after checkout' \
test_expect_success 'checkout main and initialize independed clones' \